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

Last change on this file since 15790 was 15416, checked in by Henrik Bettermann, 6 years ago

Backup deleted graduated student data somewhere else to ease graduated student data migration.

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