source: main/waeup.kofa/trunk/src/waeup/kofa/doctests/pages.txt @ 16812

Last change on this file since 16812 was 16812, checked in by Henrik Bettermann, 3 years ago

Add 'Modules Level'.

File size: 44.6 KB
Line 
1Browsing Kofa
2*************
3
4Here we visit parts of a Kofa portal using a browser.
5
6University
7==========
8
9We can watch universities in the browser.
10
11We create an university object and put into the ZODB root::
12
13  >>> root = getRootFolder()
14  >>> list(root)
15  []
16
17  >>> from waeup.kofa.app import University
18  >>> u = University()
19  >>> root['myuniversity'] = u
20  >>> list(root)
21  [u'myuniversity']
22
23  >>> from zope.component.hooks import setSite
24  >>> setSite(root['myuniversity'])
25
26To make sure, we can 'watch' pages, we first have to initialize out
27test browser::
28
29  >>> from zope.testbrowser.testing import Browser
30  >>> browser = Browser()
31
32Let's get the default view of a university::
33
34  >>> browser.open('http://localhost/myuniversity')
35  >>> print browser.contents
36  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
37  ...Welcome to WAeUP.Kofa...
38  ...
39
40We can change to German::
41
42  >>> browser.getLink('de').click()
43  >>> print browser.contents
44  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
45  ...Anfragen...
46  ...
47
48And then change back to English by clicking on the third link containing 'en'
49behind 'Anfragen' and 'Einloggen'::
50
51  >>> browser.getLink('en', index=2).click()
52  >>> print browser.contents
53  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
54  ...Enquiries...
55  ...
56
57The contact form for anonymous users is called 'Enquiries'::
58
59  >>> browser.open('http://localhost/myuniversity')
60  >>> browser.getLink('Enquiries').click()
61  >>> browser.getControl('Send').click()
62  >>> print browser.contents
63  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
64  ...Required input is missing...
65  ...
66
67  >>> browser.getControl(name='form.fullname').value = "Bob Tester"
68  >>> browser.getControl(name='form.email_from').value = "xx@yy.zz"
69  >>> browser.getControl(name='form.body').value = u'test message'
70  >>> browser.getControl('Send').click()
71  >>> print browser.contents
72  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
73  ...Your message has been sent...
74  ...
75
76Registered users with an email address can request a password change:
77
78  >>> root['myuniversity']['users'].addUser('forgetful', 'secret',title='Bob Forgetful',
79  ...                               description='A forgetful user', email='aa@aa.ng')
80  >>> browser.open('http://localhost/myuniversity/changepw')
81  >>> browser.getControl(name="form.identifier").value = 'forgetful'
82  >>> browser.getControl(name="form.email").value = 'aa@aa.ng'
83  >>> browser.getControl("Send login credentials").click()
84  >>> print browser.contents
85  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
86  ...An email with your user name and password has been sent to aa@aa.ng...
87
88Now we login as manager::
89
90  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
91  >>> browser.handleErrors = False
92
93We can then get an edit view of the configuration container::
94
95  >>> browser.open('http://localhost/myuniversity/configuration')
96  >>> print browser.contents
97  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
98  ...<form action="http://localhost/myuniversity/configuration/@@index"
99  ...
100
101The edit form contains the default value for the university name::
102
103  >>> 'Sample University' in browser.contents
104  True
105
106We can perform several actions on the edit form::
107
108  >>> browser.getControl("Save", index=0).click()
109  >>> print browser.contents
110  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
111  ...Form has been saved...
112  ...
113
114  >>> browser.open('http://localhost/myuniversity/configuration')
115  >>> browser.getControl("Update plugins").click()
116  >>> print browser.contents
117  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
118  ...Plugins were updated. See log file for details...
119  ...
120
121The default frontpage HTML has been saved in a dictionary
122and is properly rendered on the frontpage of the portal:
123
124  >>> browser.open('http://localhost/myuniversity')
125  >>> print browser.contents
126  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
127  ...<h1>Welcome to WAeUP.Kofa...</h1>
128  ...
129
130The German part is really not being rendered:
131
132  >>> 'Willkommen' in browser.contents
133  False
134
135
136If we change to German so that the German part of frontpage.rst is rendered:
137
138  >>> browser.open('http://localhost/myuniversity//@@change_language?lang=de')
139  >>> print browser.contents
140  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
141  ...<h1>Willkommen auf WAeUP.Kofa...</h1>
142  ...
143
144The English part is really not being rendered:
145
146  >>> 'Welcome' in browser.contents
147  False
148
149Switch back to English:
150
151  >>> browser.open('http://localhost/myuniversity//@@change_language?lang=en')
152
153
154Officers
155========
156
157  >>> browser.open('http://localhost/myuniversity')
158  >>> browser.getLink('Officers').click()
159  >>> print browser.contents
160  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
161  ...Officers...
162  ...
163
164We can add officers:
165
166  >>> browser.getLink("Add officer").click()
167  >>> browser.getControl(name="form.name").value = 'bob'
168  >>> browser.getControl(name="form.title").value = 'Bob The User'
169  >>> browser.getControl(name="form.email").value = 'xx@yy.zz'
170  >>> browser.getControl(name="form.phone.country").value = ['+234']
171  >>> browser.getControl(name="form.phone.area").value = '123'
172  >>> browser.getControl(name="form.phone.ext").value = '45678'
173  >>> browser.getControl(name="password").value = 'secret'
174  >>> browser.getControl(name="control_password").value = 'secret'
175  >>> browser.getControl("Add officer").click()
176  >>> print browser.contents
177  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
178  ...Passwords must be at least 8 characters long...
179  >>> browser.getControl(name="password").value = 'TOP4secret'
180  >>> browser.getControl(name="control_password").value = 'TOP4secret'
181  >>> browser.getControl("Add officer").click()
182
183We have been redirected to the Send Password page:
184
185  >>> print browser.contents
186  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
187  ...Send user a new password...
188  ...
189
190We can edit user bob:
191
192  >>> browser.open('http://localhost/myuniversity/users')
193  >>> browser.getControl("Manage", index=0).click()
194  >>> browser.getControl("Save", index=0).click()
195  >>> browser.getControl("Cancel", index=0).click()
196
197We can add site roles which are then displayed on the user container page.
198Since the test browser does not use javascript, we have to add site roles
199manually by setting the roles attribute:
200
201  >>> print root['myuniversity']['users']['bob'].roles
202  []
203  >>> root['myuniversity']['users']['bob'].roles = ['waeup.ApplicationsOfficer']
204  >>> print root['myuniversity']['users']['bob'].roles
205  ['waeup.ApplicationsOfficer']
206  >>> browser.open('http://localhost/myuniversity/users')
207  >>> print browser.contents
208  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
209  ...<td nowrap>Applications Officer (view only) <br /></td>
210  ...
211
212Officers can't be added twice:
213
214  >>> browser.open('http://localhost/myuniversity/users/add')
215  >>> browser.getControl(name="form.name").value = 'bob'
216  >>> browser.getControl(name="form.title").value = 'Bob The User'
217  >>> browser.getControl(name="password").value = 'TOP4secret'
218  >>> browser.getControl(name="control_password").value = 'TOP4secret'
219  >>> browser.getControl(name="form.email").value = 'xx@yy.zz'
220  >>> browser.getControl(name="form.phone.country").value = ['+234']
221  >>> browser.getControl(name="form.phone.area").value = '123'
222  >>> browser.getControl(name="form.phone.ext").value = '45678'
223  >>> browser.getControl("Add officer").click()
224  >>> 'The userid chosen already exists' in browser.contents
225  True
226
227Officers can be deleted:
228
229  >>> browser.open('http://localhost/myuniversity/users')
230  >>> browser.getControl("Remove", index=0).click()
231  >>> 'User account bob successfully deleted' in browser.contents
232  True
233
234
235
236Contact Form
237============
238
239Let's enter the contact form::
240
241  >>> browser.open('http://localhost/myuniversity/contactadmin')
242  >>> print browser.contents
243  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
244  ...Contact
245  ...
246
247We fill the form  (this will send a real message to
248contact@waeup.org)::
249
250  >>> browser.open('http://localhost/myuniversity/contactadmin')
251  >>> browser.getControl(name='form.body').value = "test message"
252  >>> browser.getControl('Send').click()
253  >>> print browser.contents
254  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
255  ...Your message has been sent...
256  ...
257
258If this test fails, chances are, that the local machine has no SMTP
259server installed.
260
261
262
263Faculties
264=========
265
266Faculties are stored in a special container of `IUniversity`
267instances. The container is called ``faculties`` and provides an
268add-form to add new faculties::
269
270  >>> browser.open('http://localhost/myuniversity/faculties/manage')
271  >>> browser.getControl('Add faculty').click()
272  >>> print browser.contents
273  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
274  ...*...
275  ...<span>Name of faculty</span>:
276  ...
277  >>> browser.getControl('Cancel').click()
278  >>> browser.open('http://localhost/myuniversity/faculties/add')
279
280We fill in a new name for our new faculty::
281
282  >>> ctrl = browser.getControl(name='form.title')
283  >>> ctrl.value = 'TestFac'
284
285Furthermore we add a prefix and a code (kind of abbreviation):
286
287  >>> browser.getControl(name='form.code').value = 'TF'
288
289Finally we click on 'Add Faculty' to add the new thing::
290
291  >>> browser.getControl('Add faculty').click()
292
293We can view a faculty by browsing a URL like this::
294
295  >>> browser.open('http://localhost/myuniversity/faculties/TF')
296
297Afterwards, the faculty should be visible:
298
299  >>> browser.open('http://localhost/myuniversity/faculties')
300  >>> print browser.contents
301  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
302  ...<h1 class="kofa-content-label">Academic Section</h1>
303  ...<td> <a href="http://localhost/myuniversity/faculties/TF"> <span>TF</span></a></td>
304  ...
305
306We can 'visit' each faculty by clicking on the appropriate link:
307
308  >>> browser.getLink('TF').click()
309  >>> print browser.contents
310  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
311  ...Faculty of TestFac (TF)...
312  ...
313
314If we add the same faculty twice, an error message will occur:
315
316  >>> browser.open('http://localhost/myuniversity/faculties/add')
317  >>> ctrl = browser.getControl(name='form.title')
318  >>> ctrl.value = 'TestFac'
319  >>> browser.getControl(name='form.code').value = 'TF'
320  >>> browser.getControl('Add faculty').click()
321  >>> 'The faculty code chosen already exists.' in browser.contents
322  True
323
324Modifying faculties
325-------------------
326
327A faculty can directly be reached by its code:
328
329  >>> browser.open('http://localhost/myuniversity/faculties/TF')
330
331We can change the settings for a faculty by clicking on the
332provided 'Manage  faculty' button:
333
334  >>> browser.getLink('Manage faculty').click()
335
336Let's set a new title and save the form:
337
338  >>> browser.getControl(name='form.title').value = "My renamed faculty"
339  >>> browser.getControl(name='form.actions.save').click()
340
341Our faculty was indeed renamed to ``My renamed faculty``:
342
343  >>> browser.open('http://localhost/myuniversity/faculties')
344  >>> print browser.contents
345  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
346  ...<h1 class="kofa-content-label">Academic Section</h1>
347  ...<td> <a href="http://localhost/myuniversity/faculties/TF"> <span>TF</span></a></td>
348  ...<td>Faculty of My renamed faculty (TF)</td>
349  ...
350
351We can grant local roles:
352
353  >>> root['myuniversity']['users'].addUser('bob', 'secret',title='Bob',
354  ...                               description='A sample user')
355  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
356  >>> browser.getControl(name="user").value = ['bob']
357  >>> browser.getControl(
358  ...     name="local_role").value = ['waeup.local.DepartmentManager']
359  >>> browser.getControl("Add local role").click()
360  >>> print browser.contents
361  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
362  ...<td>bob</td>
363  ...
364
365On the officers page the new local role is displayed:
366
367  >>> browser.getLink("Officers").click()
368  >>> print browser.contents
369  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
370  ...<td>Department Manager:...
371  ...
372
373The local role can be removed again:
374
375  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
376  >>> ctrl = browser.getControl(name='role_id')
377  >>> browser.getControl("Remove selected local roles").click()
378  >>> print browser.contents
379  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
380  ...No local role selected...
381  ...
382
383  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
384  >>> ctrl = browser.getControl(name='role_id')
385  >>> ctrl.getControl(value='bob|waeup.local.DepartmentManager').selected = True
386  >>> browser.getControl("Remove selected local roles").click()
387  >>> print browser.contents
388  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
389  ...Local role successfully removed...
390  ...
391
392Deleting faculties
393------------------
394
395  >>> browser.open('http://localhost/myuniversity/faculties/manage')
396  >>> browser.getControl('Cancel').click()
397  >>> print browser.url
398  http://localhost/myuniversity/faculties
399  >>> browser.getLink('Manage academic section').click()
400  >>> browser.getControl('Add faculty').click()
401  >>> ctrl = browser.getControl(name='form.title')
402  >>> ctrl.value = 'Second Faculty'
403  >>> browser.getControl(name='form.code').value = 'TF2'
404  >>> browser.getControl('Add faculty').click()
405  >>> browser.open('http://localhost/myuniversity/faculties/manage')
406  >>> browser.getControl("Remove selected", index=0).click()
407  >>> 'No item selected' in browser.contents
408  True
409  >>> browser.open('http://localhost/myuniversity/faculties/manage')
410  >>> ctrl = browser.getControl(name='val_id')
411  >>> ctrl.getControl(value='TF2').selected = True
412  >>> browser.getControl("Remove selected", index=0).click()
413  >>> print browser.contents
414  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
415  ...Successfully removed:...
416  ...
417
418Departments
419===========
420
421Adding departments
422------------------
423
424Departments are stored in :class:`IFaculty` instances with their code
425as key. Faculties therefore are also department containers. Faculties
426provides an add-form to add new departments:
427
428  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
429  >>> print browser.contents
430  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
431  ...*</span>
432  ...<span>Name of department</span>:
433  ...
434  >>> browser.getControl('Cancel').click()
435  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
436
437We fill in a new name for our new department:
438
439  >>> ctrl = browser.getControl(name='form.title')
440  >>> ctrl.value = 'TestDept'
441
442Furthermore we add a code (kind of abbreviation):
443
444  >>> browser.getControl(name='form.code').value = 'TD'
445
446Finally we click on 'Add Department' to add the new thing::
447
448  >>> browser.getControl('Add department').click()
449
450If we try to register a department under the same code twice we will
451get an error:
452
453  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
454  >>> ctrl = browser.getControl(name='form.title')
455  >>> ctrl.value = 'Another TestDept with same code'
456  >>> browser.getControl(name='form.code').value = 'TD'
457  >>> browser.getControl('Add department').click()
458  >>> print browser.contents
459  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
460  ...The code chosen already exists in this faculty...
461  ...
462
463We can view a department by browsing a URL like this::
464
465  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
466
467Afterwards, the department should be visible::
468
469  >>> browser.open('http://localhost/myuniversity/faculties/TF')
470  >>> print browser.contents
471  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
472  ...<h1 class="kofa-content-label">Faculty of My renamed faculty (TF)</h1>
473  ...<td> <a href="http://localhost/myuniversity/faculties/TF/TD"> <span>TD</span></a></td>
474  ...<td>Department of TestDept (TD)</td>
475  ...
476
477
478Modifying departments
479---------------------
480
481We can change the settings for a department by clicking on the
482provided 'Edit department' button:
483
484  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
485  >>> browser.getLink('Manage department').click()
486
487Let's set a new title and save the form:
488
489  >>> browser.getControl(name='form.title').value = "My test dept"
490  >>> browser.getControl(name='form.actions.save').click()
491
492Clicking 'Save' we will stay on the settings form. So we can change
493the department again.
494
495  >>> browser.getControl(name='form.title').value = "My renamed dept"
496  >>> ctrl = browser.getControl("Save")
497  >>> ctrl.click()
498
499
500Our department was indeed renamed to ``My renamed dept``:
501
502  >>> browser.open('http://localhost/myuniversity/faculties/TF')
503  >>> print browser.contents
504  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
505  ...<h1 class="kofa-content-label">Faculty of My renamed faculty (TF)</h1>
506  ...<td> <a href="http://localhost/myuniversity/faculties/TF/TD"> <span>TD</span></a></td>
507  ...<td>Department of My renamed dept (TD)</td>
508  ...
509
510We can grant local roles:
511
512  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
513  >>> browser.getControl(name="user").value = ['bob']
514  >>> browser.getControl(
515  ...     name="local_role").value = ['waeup.local.DepartmentManager']
516  >>> browser.getControl("Add local role").click()
517  >>> print browser.contents
518  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
519  ...<td>bob</td>
520  ...
521
522The local role can be removed again:
523
524  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
525  >>> ctrl = browser.getControl(name='role_id')
526  >>> browser.getControl("Remove selected local roles").click()
527  >>> print browser.contents
528  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
529  ...No local role selected...
530  ...
531
532  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
533  >>> ctrl = browser.getControl(name='role_id')
534  >>> ctrl.getControl(
535  ...     value='bob|waeup.local.DepartmentManager').selected = True
536  >>> browser.getControl("Remove selected local roles").click()
537  >>> print browser.contents
538  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
539  ...Local role successfully removed...
540  ...
541
542Deleting departments
543--------------------
544
545  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
546  >>> browser.getControl('Cancel', index=0).click()
547  >>> print browser.url
548  http://localhost/myuniversity/faculties/TF
549  >>> browser.getLink('Manage faculty').click()
550  >>> browser.getControl('Add department').click()
551  >>> ctrl = browser.getControl(name='form.title')
552  >>> ctrl.value = 'Second Department'
553  >>> browser.getControl(name='form.code').value = 'TD2'
554  >>> browser.getControl('Add department').click()
555  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
556  >>> browser.getControl("Remove selected", index=0).click()
557  >>> 'No item selected' in browser.contents
558  True
559  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
560  >>> ctrl = browser.getControl(name='val_id')
561  >>> ctrl.getControl(value='TD2').selected = True
562  >>> browser.getControl("Remove selected", index=0).click()
563  >>> print browser.contents
564  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
565  ...Successfully removed:...
566  ...
567
568
569Courses
570=======
571
572Once we have a department, we can add courses.
573
574Adding courses
575--------------
576
577Courses are stored in :class:`ICoursesContainer` instances with their
578code as key. CoursesContainers are normally availabe as `course`
579attribute of :class:`waeup.kofa.university.department.Department`
580instances.
581
582To ease the life of officers we do not require to browse the
583coursescontainers (which have a rather flat user interface), but
584provide adding of courses in department views.
585
586Each department provides a ``Add course`` action button near top.
587
588Departments provide an add-form to add new courses:
589
590  >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD'
591  >>> browser.open(dept_url + '/manage')
592  >>> browser.getControl('Add course').click()
593  >>> print browser.contents
594  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
595  ...*</span>
596  ...<span>Title of course</span>:
597  ...
598
599We fill in a name for our new course:
600
601  >>> ctrl = browser.getControl(name='form.title')
602  >>> ctrl.value = 'My Course 1'
603
604Furthermore we add a code (kind of abbreviation):
605
606  >>> browser.getControl(name='form.code').value = 'COURSE1'
607
608This course will take place in the the first semester, so we set the
609`semester` value to 1:
610
611  >>> ctrl = browser.getControl(name='form.semester')
612  >>> ctrl.options
613  ['1', '4', '2', '5', '6', '3', '11', '12', '13', '9']
614
615  >>> ctrl.displayOptions
616  ['1st Semester', '1st Term', '2nd Semester', '2nd Term', '3rd Term', 'Combined', 'Module I', 'Module II', 'Module III', 'N/A']
617
618  >>> ctrl.value = ['1']
619
620Finally, we create the course:
621
622  >>> browser.getControl('Add course').click()
623
624If we try to register a course under the same code twice we will
625get an error:
626
627  >>> browser.open(dept_url + '/addcourse')
628  >>> ctrl = browser.getControl(name='form.title')
629  >>> ctrl.value = 'Another course with same code'
630  >>> browser.getControl(name='form.code').value = 'COURSE1'
631  >>> browser.getControl('Add course').click()
632  >>> print browser.contents
633  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
634  ...A course with same code already exists:...
635  ...
636
637Our course will be linked under the code on the department page:
638
639  >>> browser.open(dept_url)
640  >>> browser.getLink('COURSE1').click()
641  >>> browser.url
642  'http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1'
643
644Before we really add a course we can cancel the action and will be
645redirected to the department page:
646
647  >>> browser.open(dept_url + '/addcourse')
648  >>> browser.getControl('Cancel').click()
649  >>> browser.url
650  'http://localhost/myuniversity/faculties/TF/TD'
651
652
653Modifying courses
654-----------------
655
656We can change the settings for a course by clicking on the provided
657'Edit settings' link:
658
659  >>> browser.open(dept_url + '/courses/COURSE1')
660  >>> browser.getLink('Edit course').click()
661
662When modifying a course, we cannot change the code any more:
663
664  >>> browser.getControl(name='form.code')
665  Traceback (most recent call last):
666  ...
667  LookupError: name 'form.code'
668  available items:
669    <TextControl(form.title=My Course 1)>
670    ...
671
672
673Let's set a new title and save the form:
674
675  >>> browser.getControl(name='form.title').value = "My test course"
676  >>> browser.getControl(name='form.actions.save').click()
677
678Clicking 'Save' we will stay on the settings form. So we can change
679the course again. If we click ``Cancel`` nothing will be
680changed:
681
682  >>> browser.getControl(name='form.title').value = "Blah"
683  >>> browser.getControl('Cancel').click()
684
685Our course was not renamed to ``Blah``:
686
687  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
688  >>> print browser.contents
689  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
690  ...<td>My test course</td>...
691  ...
692
693Searching courses
694-----------------
695
696  >>> browser.open('http://localhost/myuniversity/faculties/search')
697  >>> browser.getControl(name='query').value = "My test course"
698  >>> browser.getControl('Search').click()
699  >>> print browser.contents
700  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
701  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
702  ...
703
704  >>> browser.open('http://localhost/myuniversity/faculties/search')
705  >>> browser.getControl(name='query').value = "COURSE1"
706  >>> browser.getControl('Search').click()
707  >>> print browser.contents
708  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
709  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
710  ...
711
712  >>> browser.getControl(name='query').value = "Nonsense"
713  >>> browser.getControl('Search').click()
714  >>> 'Search Results' in browser.contents
715  False
716  >>> '<div class="alert alert-warning">No object found.</div>' in browser.contents
717  True
718
719  >>> browser.getControl(name='query').value = ""
720  >>> browser.getControl('Search').click()
721  >>> 'Empty search string' in browser.contents
722  True
723
724We can grant local roles:
725
726  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
727  >>> browser.getControl(name="user").value = ['bob']
728  >>> browser.getControl(
729  ...     name="local_role").value = ['waeup.local.Lecturer']
730  >>> browser.getControl("Add local role").click()
731  >>> print browser.contents
732  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
733  ...<td>bob</td>
734  ...
735
736On the portal user page the new local role is displayed:
737
738  >>> browser.getLink("Officers").click()
739  >>> print browser.contents
740  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
741  ...<td>Lecturer:...
742  ...
743
744The local role can be removed again:
745
746  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
747  >>> ctrl = browser.getControl(name='role_id')
748  >>> browser.getControl("Remove selected local roles").click()
749  >>> print browser.contents
750  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
751  ...No local role selected...
752  ...
753
754  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
755  >>> ctrl = browser.getControl(name='role_id')
756  >>> ctrl.getControl(value='bob|waeup.local.Lecturer').selected = True
757  >>> browser.getControl("Remove selected local roles").click()
758  >>> print browser.contents
759  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
760  ...Local role successfully removed...
761  ...
762
763Deleting courses
764----------------
765
766We can delete courses by browsing the manage page of the containing
767department and checking the appropriate select box and clicking the
768´´Remove selected´´ button.
769
770  >>> browser.open(
771  ...     'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2')
772  >>> 'My test course' in browser.contents
773  True
774
775  >>> browser.getControl('Cancel', index=0).click()
776  >>> browser.getLink('Manage department').click()
777  >>> browser.getControl('Remove selected courses').click()
778  >>> 'No item selected' in browser.contents
779  True
780
781  >>> browser.getControl(
782  ...    name='val_id').getControl(value='COURSE1').selected = True
783  >>> browser.getControl('Remove selected courses').click()
784
785  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
786  >>> 'My renamed course' in browser.contents
787  False
788
789
790Deleting departments with courses
791---------------------------------
792
793  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
794  >>> browser.getControl('Cancel', index=0).click()
795  >>> browser.getLink('Manage faculty').click()
796  >>> browser.getControl('Add department').click()
797  >>> ctrl = browser.getControl(name='form.title')
798  >>> ctrl.value = 'Third Department'
799  >>> browser.getControl(name='form.code').value = 'TD3'
800  >>> browser.getControl('Add department').click()
801  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD3/manage')
802  >>> browser.getControl('Add course').click()
803  >>> ctrl = browser.getControl(name='form.title')
804  >>> ctrl.value = 'My Course 5'
805  >>> browser.getControl(name='form.code').value = 'COURSE5'
806  >>> browser.getControl('Add course').click()
807  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
808  >>> ctrl = browser.getControl(name='val_id')
809  >>> ctrl.getControl(value='TD3').selected = True
810  >>> browser.getControl("Remove selected", index=0).click()
811  >>> print browser.contents
812  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
813  ...Successfully removed:...
814  ...
815
816Certificates
817============
818
819Once we have a department, we can add also certificates.
820
821Adding certificates
822-------------------
823
824Certificates are stored in :class:`ICertificatesContainer` instances
825with their code as key. CertificatesContainers are normally availabe as
826`certificates` attribute of
827:class:`waeup.kofa.university.department.Department` instances.
828
829To ease the life of officers we do not require to browse the
830certificatescontainers (which have in fact no user interface), but
831provide adding of certificates in department views.
832
833Each department provides a ``Add certificate`` action button near top.
834
835Departments provide an add-form to add new certificates:
836
837  >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD'
838  >>> browser.open(dept_url + '/manage')
839  >>> browser.getControl('Add certificate').click()
840  >>> print browser.contents
841  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
842  ...*</span>
843  ...<span>Title</span>:
844  ...
845
846We fill in a name for our new cert:
847
848  >>> ctrl = browser.getControl(name='form.title')
849  >>> ctrl.value = 'My Certificate 1'
850
851Furthermore we add a code (kind of abbreviation):
852
853  >>> browser.getControl(name='form.code').value = 'CERT1'
854
855Set the remaining required fields:
856
857  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
858  >>> browser.getControl(name='form.start_level').value = ['100']
859  >>> browser.getControl(name='form.end_level').value = ['400']
860  >>> browser.getControl(name='form.application_category').value = ['basic']
861
862Finally, we create the certificate:
863
864  >>> browser.getControl('Add certificate').click()
865
866If we try to register a certificate under the same code twice we will
867get an error:
868
869  >>> browser.open(dept_url + '/addcertificate')
870  >>> ctrl = browser.getControl(name='form.title')
871  >>> ctrl.value = 'Another cert with same code'
872  >>> browser.getControl(name='form.code').value = 'CERT1'
873  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
874  >>> browser.getControl(name='form.start_level').value = ['100']
875  >>> browser.getControl(name='form.end_level').value = ['400']
876  >>> browser.getControl(name='form.application_category').value = ['basic']
877
878  >>> browser.getControl('Add certificate').click()
879  >>> print browser.contents
880  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
881  ...A certificate with same code already exists:...
882  ...
883
884Our certificate will be linked under the code on the department page:
885
886  >>> browser.open(dept_url)
887  >>> browser.getLink('CERT1').click()
888  >>> browser.url
889  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
890
891Before we really add a certificate we can cancel the action and will be
892redirected to the department page:
893
894  >>> browser.open(dept_url + '/addcertificate')
895  >>> browser.getControl('Cancel').click()
896  >>> browser.url
897  'http://localhost/myuniversity/faculties/TF/TD'
898
899
900Modifying certificates
901----------------------
902
903We can change the settings for a cert by clicking on the provided
904'Edit certificate' link:
905
906  >>> browser.open(dept_url + '/certificates/CERT1')
907  >>> browser.getLink('Manage certificate').click()
908
909When modifying a certificate, we cannot change the code any more:
910
911  >>> browser.getControl(name='form.code')
912  Traceback (most recent call last):
913  ...
914  LookupError: name 'form.code'
915  available items:
916    <TextControl(form.title=My Certificate 1)>
917    ...
918
919
920Let's set a new title and save the form:
921
922  >>> browser.getControl(name='form.title').value = "My test cert"
923  >>> browser.getControl(name='form.actions.save').click()
924
925Clicking 'Save' we will stay on the settings form. So we can change
926the cert again.
927
928  >>> browser.getControl(name='form.title').value = "My renamed cert"
929  >>> ctrl = browser.getControl("Save",index=0)
930  >>> ctrl.click()
931
932If we go to the settings page and click ``Cancel`` nothing will be
933changed:
934
935  >>> browser.getControl(name='form.title').value = "Blah"
936  >>> browser.getControl('Cancel',index=0).click()
937
938Our certificate was indeed renamed to ``My renamed cert`` and not to
939``Blah``:
940
941  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
942  >>> print browser.contents
943  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
944  ...<td>My renamed cert</td>...
945  ...
946
947Searching certificates
948----------------------
949
950  >>> browser.open('http://localhost/myuniversity/faculties/search')
951  >>> browser.getControl(name='query').value = "My renamed cert"
952  >>> browser.getControl('Search').click()
953  >>> print browser.contents
954  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
955  ...faculties/TF/TD/certificates/CERT1">CERT1</a>
956  ...
957
958  >>> browser.open('http://localhost/myuniversity/faculties/search')
959  >>> browser.getControl(name='query').value = "CERT1"
960  >>> browser.getControl('Search').click()
961  >>> print browser.contents
962  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
963  ...faculties/TF/TD/certificates/CERT1">CERT1</a>
964  ...
965
966Deleting certificates
967---------------------
968
969We can delete certificates by browsing the manage page of the
970containing department and checking the appropriate select box and
971clicking the ´´Remove selected´´ button.
972
973  >>> browser.open(
974  ...    'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3')
975  >>> 'My renamed cert' in browser.contents
976  True
977
978  >>> browser.getControl('Remove selected certificates').click()
979  >>> 'No item selected' in browser.contents
980  True
981
982  >>> browser.getControl(name='val_id').getControl(
983  ...    value='CERT1').selected = True
984  >>> browser.getControl('Remove selected certificates').click()
985  >>> 'My renamed cert' in browser.contents
986  False
987
988
989Certificate Courses
990===================
991
992Once we have a certificate, we can add also certificate courses. These
993are referrers of courses with some extra data.
994
995Before we can work with certificate courses, we need some certificates
996and courses to be available.
997
998  >>> browser.open(dept_url + '/addcourse')
999  >>> ctrl = browser.getControl(name='form.title')
1000  >>> ctrl.value = 'Another course with same code'
1001  >>> browser.getControl(name='form.code').value = 'COURSE1'
1002  >>> browser.getControl(name='form.title').value = 'Course 1'
1003  >>> browser.getControl('Add course').click()
1004
1005  >>> browser.open(dept_url + '/addcourse')
1006  >>> ctrl = browser.getControl(name='form.title')
1007  >>> ctrl.value = 'Another course with same code'
1008  >>> browser.getControl(name='form.code').value = 'COURSE2'
1009  >>> browser.getControl(name='form.title').value = 'Course 2'
1010  >>> browser.getControl('Add course').click()
1011
1012  >>> browser.open(dept_url + '/addcertificate')
1013  >>> ctrl = browser.getControl(name='form.title')
1014  >>> ctrl.value = 'Another cert with same code'
1015  >>> browser.getControl(name='form.code').value = 'CERT1'
1016  >>> browser.getControl(name='form.title').value = 'Certificate 1'
1017  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1018  >>> browser.getControl(name='form.start_level').value = ['100']
1019  >>> browser.getControl(name='form.end_level').value = ['400']
1020  >>> browser.getControl(name='form.application_category').value = ['basic']
1021  >>> browser.getControl('Add certificate').click()
1022
1023  >>> browser.open(dept_url + '/addcertificate')
1024  >>> ctrl = browser.getControl(name='form.title')
1025  >>> ctrl.value = 'Another cert with same code'
1026  >>> browser.getControl(name='form.code').value = 'CERT2'
1027  >>> browser.getControl(name='form.title').value = 'Certificate 2'
1028  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1029  >>> browser.getControl(name='form.start_level').value = ['100']
1030  >>> browser.getControl(name='form.end_level').value = ['400']
1031  >>> browser.getControl(name='form.application_category').value = ['basic']
1032  >>> browser.getControl('Add certificate').click()
1033
1034
1035Adding certificate courses
1036--------------------------
1037
1038Certcourses are stored in :class:`ICertificate` instances
1039with their code as key.
1040
1041Each certificate provides a ``Add certificate course`` action button near top.
1042
1043Certificates provide an add-form to add new certcourses:
1044
1045  >>> cert_url = dept_url + '/certificates/CERT1'
1046  >>> browser.open(cert_url + '/manage')
1047  >>> browser.getControl('Add certificate course').click()
1048  >>> print browser.contents
1049  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1050  ...*</span>
1051  ...<span>Level</span>:
1052  ...
1053
1054In the add-form we will get a list of available courses to select
1055from. This list will contain all courses stored in the site, not only
1056the ones from local department:
1057
1058  >>> ctrl = browser.getControl(name='form.course')
1059  >>> ctrl.displayOptions
1060  ['--', 'COURSE1 - Course 1', 'COURSE2 - Course 2']
1061
1062We select the first course and create our certificate course:
1063
1064  >>> ctrl.getControl('COURSE1').selected = True
1065  >>> browser.getControl(name='form.level').value = ['100']
1066  >>> browser.getControl('Add certificate course').click()
1067
1068Our certificate course will be linked on the parent certificate page:
1069
1070  >>> browser.open(cert_url)
1071  >>> browser.getLink('COURSE1_100').click()
1072  >>> browser.url
1073  'http://localhost/my...sity/faculties/TF/TD/certificates/CERT1/COURSE1_100'
1074
1075We can't add the same certificate course twice:
1076
1077  >>> cert_url = dept_url + '/certificates/CERT1'
1078  >>> browser.open(cert_url + '/manage')
1079  >>> browser.getControl('Add certificate course').click()
1080  >>> ctrl = browser.getControl(name='form.course')
1081  >>> ctrl.getControl('COURSE1').selected = True
1082  >>> browser.getControl(name='form.level').value = ['100']
1083  >>> browser.getControl('Add certificate course').click()
1084  >>> 'The chosen certificate course is already' in browser.contents
1085  True
1086
1087When we started to add a new certificate course, we can also cancel the
1088process before submitting. This will bring us back to the certificate
1089page:
1090
1091  >>> browser.open(cert_url + '/addcertificatecourse')
1092  >>> browser.getControl('Cancel').click()
1093  >>> browser.url
1094  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
1095
1096
1097Modifying certificate courses
1098-----------------------------
1099
1100We can change the settings for a certcourse by clicking on the
1101provided 'Edit certificate course' link:
1102
1103  >>> browser.open(cert_url + '/COURSE1_100')
1104  >>> browser.getLink('Edit certificate course').click()
1105
1106If we just click 'Save and return' nothing will change:
1107
1108  >>> browser.getControl("Save").click()
1109  >>> browser.url
1110  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_100/@@manage'
1111
1112Let's set a new level (it was 100 before) and save the form. The entire
1113certificate course will be replaced and we will be redirected to manage
1114page afterwards:
1115
1116  >>> browser.getControl(name='form.level').value = ['200']
1117  >>> browser.getControl("Save").click()
1118  >>> browser.url
1119  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200/@@manage'
1120
1121Nothing will be changed if click ``Cancel``:
1122
1123  >>> browser.getControl(name='form.level').value = ['400']
1124  >>> browser.getControl('Cancel').click()
1125  >>> browser.url
1126  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200'
1127
1128Searching certificate courses
1129-----------------------------
1130
1131  >>> browser.open('http://localhost/myuniversity/faculties/search')
1132  >>> browser.getControl(name='query').value = "COURSE1"
1133  >>> browser.getControl('Search').click()
1134  >>> print browser.contents
1135  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1136  ...faculties/TF/TD/certificates/CERT1/COURSE1_200">COURSE1</a>
1137  ...
1138
1139  >>> browser.getControl(name='query').value = "*"
1140  >>> browser.getControl('Search').click()
1141  >>> 'Search string not allowed' in browser.contents
1142  True
1143
1144Deleting certificate courses
1145----------------------------
1146
1147We can delete certcourses by browsing the containing certificate manage page:
1148
1149  >>> browser.open(cert_url + '/manage#tab-2')
1150  >>> 'COURSE1_200</a>' in browser.contents
1151  True
1152  >>> browser.getControl('Remove selected certificate courses').click()
1153  >>> 'No item selected' in browser.contents
1154  True
1155  >>> browser.getControl(name='val_id').getControl(
1156  ...    value='COURSE1_200').selected = True
1157  >>> browser.getControl('Remove selected certificate courses').click()
1158  >>> 'Successfully removed: COURSE1_200' in browser.contents
1159  True
1160
1161  >>> 'COURSE1_200</a>' in browser.contents
1162  False
1163
1164
1165
1166Data Center
1167===========
1168
1169The data center helps us uploading files for later import or similar.
1170
1171  >>> browser.open('http://localhost/myuniversity')
1172  >>> browser.getLink('Data Center').click()
1173
1174Setting the file path
1175---------------------
1176
1177A datacenter stores files in a path in filesystem. By default this is
1178a directory in the sources:
1179
1180  >>> print browser.contents
1181  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1182  ...
1183  <b>Storage path:</b> <span>.../parts/test/datacenter</span>
1184  ...
1185
1186Going to 'Settings` we can change the path:
1187
1188  >>> browser.getLink('Edit settings').click()
1189  >>> pathsetting = browser.getControl(name='newpath')
1190
1191We create a directory and set it as our upload path:
1192
1193  >>> import os
1194  >>> cwd = os.getcwd()
1195  >>> uploadpath = os.path.join(cwd, 'testfiles')
1196  >>> os.mkdir(uploadpath)
1197  >>> pathsetting.value = uploadpath
1198
1199And submit the form:
1200
1201  >>> browser.getControl(name='save').click()
1202
1203We clean up the set directory path, as there might be some files be
1204copied some files from installation:
1205
1206  >>> files = os.listdir(uploadpath)
1207  >>> for filename in files:
1208  ...   if os.path.isdir(os.path.join(uploadpath, filename)):
1209  ...     continue
1210  ...   os.unlink(os.path.join(uploadpath, filename))
1211
1212We also remove any existing 'accesscodes' subdir:
1213
1214  >>> import shutil
1215  >>> for filename in files:
1216  ...   if not os.path.isdir(os.path.join(uploadpath, filename)):
1217  ...     continue
1218  ...   if filename != 'accesscodes':
1219  ...     continue
1220  ...   shutil.rmtree(os.path.join(uploadpath, filename))
1221
1222The new upload directory is now empty, except from the logs and other
1223standard dirs, which are created automatically:
1224
1225  >>> sorted(os.listdir(uploadpath))
1226  ['deleted', 'finished', 'graduated', 'logs', 'unfinished']
1227
1228
1229Uploading files
1230---------------
1231
1232Now we can upload files. Most interesting files might be CSV files,
1233that can be imported lateron. We create a CSV file containing faculty
1234descriptions:
1235
1236  >>> open('faculties.csv', 'wb').write(
1237  ... """code,title,title_prefix
1238  ... FA,Arts,faculty
1239  ... FS,Sciences,faculty
1240  ... """)
1241
1242Now we can upload this file. To do this, we first go to the upload
1243page:
1244
1245  >>> browser.getLink('Upload data').click()
1246
1247and enter the appropriate data in the form:
1248
1249  >>> filewidget = browser.getControl(name='uploadfile:file')
1250  >>> filewidget
1251  <Control name='uploadfile:file' type='file'>
1252
1253A sidenote for developers: by marking the filewidget with the
1254``:file`` extension, we tell Zope to handle this field as a file
1255widget.
1256
1257  >>> import cStringIO
1258  >>> filecontents = cStringIO.StringIO(
1259  ...   open('faculties.csv', 'rb').read())
1260  >>> filewidget.add_file(filecontents, 'text/plain', 'myfaculties.csv')
1261
1262  >>> browser.getControl(name='SUBMIT').click()
1263
1264The file was indeed uploaded, with the current userid inserted:
1265
1266  >>> sorted(os.listdir(uploadpath))
1267  ['deleted', 'finished', 'graduated', 'logs', 'myfaculties_zope.mgr.csv', 'unfinished']
1268
1269We create and upload also a CSV file containing departments:
1270
1271  >>> open('departments.csv', 'wb').write(
1272  ... """code,title,title_prefix,faculty_code
1273  ... LIT,Literature,department,FA
1274  ... SOC,Sociology,department,FA
1275  ... PHY,Physics,department,FS
1276  ... INF,Informatics,department,FS
1277  ... MAT,Math,department,FS
1278  ... """)
1279
1280  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1281  >>> browser.getControl(name='uploadfile:file').add_file(
1282  ...   cStringIO.StringIO(open('departments.csv', 'rb').read()),
1283  ...   'text/plain', 'mydepartments.csv')
1284  >>> browser.getControl(name='SUBMIT').click()
1285
1286We create and upload also a CSV file containing courses:
1287
1288  >>> open('courses.csv', 'wb').write(
1289  ... """code,level,title,passmark,credits,semester,faculty,department
1290  ... LI1,,Introduction to Literature I,40,2,1,FA,LIT
1291  ... LI2,,Introduction to Literature II,40,2,2,FA,LIT
1292  ... AN1,000,Analysis I,40,2,1,FS,MAT
1293  ... AN2,000,Analysis II,40,2,2,FS,MAT
1294  ... """)
1295
1296  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1297  >>> browser.getControl(name='uploadfile:file').add_file(
1298  ...   cStringIO.StringIO(open('courses.csv', 'rb').read()),
1299  ...   'text/plain', 'mycourses.csv')
1300  >>> browser.getControl(name='SUBMIT').click()
1301
1302We create and upload also a CSV file containing certificates:
1303
1304  >>> open('certificates.csv', 'wb').write(
1305  ... """code,title,faculty_code,department_code,study_mode,end_level,m_prefix,start_level,application_category
1306  ... LBA,BACHELOR OF LITERATURE,FA,LIT,UG,ug_ft,500,LIT,100,basic
1307  ... LMA,MASTER OF LITERATURE,FA,LIT,UG,ug_pt,500,LIT,100,cest
1308  ... DME,DIPLOMA OF MATH,FS,MAT,DP,dp_ft,200,DME,100,cest
1309  ... """)
1310
1311  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1312  >>> browser.getControl(name='uploadfile:file').add_file(
1313  ...   cStringIO.StringIO(open('certificates.csv', 'rb').read()),
1314  ...   'text/plain', 'mycertificates.csv')
1315  >>> browser.getControl(name='SUBMIT').click()
1316
1317We create and upload also a CSV file containing certificate courses:
1318
1319  >>> open('certcourses.csv', 'wb').write(
1320  ... """code,faculty_code,department_code,certificate_code,level,mandatory
1321  ... LI1,FA,LIT,LBA,100,True
1322  ... LI2,FA,LIT,LBA,200,True
1323  ... """)
1324
1325  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1326  >>> browser.getControl(name='uploadfile:file').add_file(
1327  ...   cStringIO.StringIO(open('certcourses.csv', 'rb').read()),
1328  ...   'text/plain', 'mycertcourses.csv')
1329  >>> browser.getControl(name='SUBMIT').click()
1330
1331
1332Importing a CSV file
1333--------------------
1334
1335The import of CSV files is described in batchprocessing.txt.
1336
1337
1338Clean up:
1339
1340  >>> import os
1341  >>> import shutil
1342  >>> shutil.rmtree(uploadpath)
1343
Note: See TracBrowser for help on using the repository browser.