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

Last change on this file since 13480 was 12966, checked in by Henrik Bettermann, 10 years ago

Fix typos.

File size: 44.2 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="password").value = 'secret'
170  >>> browser.getControl(name="control_password").value = 'secret'
171  >>> browser.getControl(name="form.email").value = 'xx@yy.zz'
172  >>> browser.getControl(name="form.phone.country").value = ['+234']
173  >>> browser.getControl(name="form.phone.area").value = '123'
174  >>> browser.getControl(name="form.phone.ext").value = '45678'
175  >>> browser.getControl("Add officer").click()
176  >>> print browser.contents
177  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
178  ...<td>bob</td>
179  ...
180
181We can edit user bob:
182
183  >>> browser.getControl("Manage", index=0).click()
184  >>> browser.getControl("Save", index=0).click()
185  >>> browser.getControl("Cancel", index=0).click()
186
187We can add site roles which are then displayed on the user container page.
188Since the test browser does not use javascript, we have to add site roles
189manually by setting the roles attribute:
190
191  >>> print root['myuniversity']['users']['bob'].roles
192  []
193  >>> root['myuniversity']['users']['bob'].roles = ['waeup.ApplicationsOfficer']
194  >>> print root['myuniversity']['users']['bob'].roles
195  ['waeup.ApplicationsOfficer']
196  >>> browser.open('http://localhost/myuniversity/users')
197  >>> print browser.contents
198  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
199  ...<td nowrap>Applications Officer (view only) <br /></td>
200  ...
201
202Officers can't be added twice:
203
204  >>> browser.open('http://localhost/myuniversity/users/add')
205  >>> browser.getControl(name="form.name").value = 'bob'
206  >>> browser.getControl(name="form.title").value = 'Bob The User'
207  >>> browser.getControl(name="password").value = 'secret'
208  >>> browser.getControl(name="control_password").value = 'secret'
209  >>> browser.getControl(name="form.email").value = 'xx@yy.zz'
210  >>> browser.getControl(name="form.phone.country").value = ['+234']
211  >>> browser.getControl(name="form.phone.area").value = '123'
212  >>> browser.getControl(name="form.phone.ext").value = '45678'
213  >>> browser.getControl("Add officer").click()
214  >>> 'The userid chosen already exists' in browser.contents
215  True
216
217Officers can be deleted:
218
219  >>> browser.open('http://localhost/myuniversity/users')
220  >>> browser.getControl("Remove", index=0).click()
221  >>> 'User account bob successfully deleted' in browser.contents
222  True
223
224
225
226Contact Form
227============
228
229Let's enter the contact form::
230
231  >>> browser.open('http://localhost/myuniversity/contactadmin')
232  >>> print browser.contents
233  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
234  ...Contact
235  ...
236
237We fill the form  (this will send a real message to
238contact@waeup.org)::
239
240  >>> browser.open('http://localhost/myuniversity/contactadmin')
241  >>> browser.getControl(name='form.body').value = "test message"
242  >>> browser.getControl('Send').click()
243  >>> print browser.contents
244  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
245  ...Your message has been sent...
246  ...
247
248If this test fails, chances are, that the local machine has no SMTP
249server installed.
250
251
252
253Faculties
254=========
255
256Faculties are stored in a special container of `IUniversity`
257instances. The container is called ``faculties`` and provides an
258add-form to add new faculties::
259
260  >>> browser.open('http://localhost/myuniversity/faculties/manage')
261  >>> browser.getControl('Add faculty').click()
262  >>> print browser.contents
263  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
264  ...*...
265  ...<span>Name of faculty</span>:
266  ...
267  >>> browser.getControl('Cancel').click()
268  >>> browser.open('http://localhost/myuniversity/faculties/add')
269
270We fill in a new name for our new faculty::
271
272  >>> ctrl = browser.getControl(name='form.title')
273  >>> ctrl.value = 'TestFac'
274
275Furthermore we add a prefix and a code (kind of abbreviation):
276
277  >>> browser.getControl(name='form.code').value = 'TF'
278
279Finally we click on 'Add Faculty' to add the new thing::
280
281  >>> browser.getControl('Add faculty').click()
282
283We can view a faculty by browsing a URL like this::
284
285  >>> browser.open('http://localhost/myuniversity/faculties/TF')
286
287Afterwards, the faculty should be visible:
288
289  >>> browser.open('http://localhost/myuniversity/faculties')
290  >>> print browser.contents
291  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
292  ...<h1 class="kofa-content-label">Academic Section</h1>
293  ...<td> <a href="http://localhost/myuniversity/faculties/TF"> <span>TF</span></a></td>
294  ...
295
296We can 'visit' each faculty by clicking on the appropriate link:
297
298  >>> browser.getLink('TF').click()
299  >>> print browser.contents
300  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
301  ...Faculty of TestFac (TF)...
302  ...
303
304If we add the same faculty twice, an error message will occur:
305
306  >>> browser.open('http://localhost/myuniversity/faculties/add')
307  >>> ctrl = browser.getControl(name='form.title')
308  >>> ctrl.value = 'TestFac'
309  >>> browser.getControl(name='form.code').value = 'TF'
310  >>> browser.getControl('Add faculty').click()
311  >>> 'The faculty code chosen already exists.' in browser.contents
312  True
313
314Modifying faculties
315-------------------
316
317A faculty can directly be reached by its code:
318
319  >>> browser.open('http://localhost/myuniversity/faculties/TF')
320
321We can change the settings for a faculty by clicking on the
322provided 'Manage  faculty' button:
323
324  >>> browser.getLink('Manage faculty').click()
325
326Let's set a new title and save the form:
327
328  >>> browser.getControl(name='form.title').value = "My renamed faculty"
329  >>> browser.getControl(name='form.actions.save').click()
330
331Our faculty was indeed renamed to ``My renamed faculty``:
332
333  >>> browser.open('http://localhost/myuniversity/faculties')
334  >>> print browser.contents
335  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
336  ...<h1 class="kofa-content-label">Academic Section</h1>
337  ...<td> <a href="http://localhost/myuniversity/faculties/TF"> <span>TF</span></a></td>
338  ...<td>Faculty of My renamed faculty (TF)</td>
339  ...
340
341We can grant local roles:
342
343  >>> root['myuniversity']['users'].addUser('bob', 'secret',title='Bob',
344  ...                               description='A sample user')
345  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
346  >>> browser.getControl(name="user").value = ['bob']
347  >>> browser.getControl(
348  ...     name="local_role").value = ['waeup.local.DepartmentManager']
349  >>> browser.getControl("Add local role").click()
350  >>> print browser.contents
351  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
352  ...<td>bob</td>
353  ...
354
355On the officers page the new local role is displayed:
356
357  >>> browser.getLink("Officers").click()
358  >>> print browser.contents
359  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
360  ...<td>Department Manager:...
361  ...
362
363The local role can be removed again:
364
365  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
366  >>> ctrl = browser.getControl(name='role_id')
367  >>> browser.getControl("Remove selected local roles").click()
368  >>> print browser.contents
369  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
370  ...No local role selected...
371  ...
372
373  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
374  >>> ctrl = browser.getControl(name='role_id')
375  >>> ctrl.getControl(value='bob|waeup.local.DepartmentManager').selected = True
376  >>> browser.getControl("Remove selected local roles").click()
377  >>> print browser.contents
378  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
379  ...Local role successfully removed...
380  ...
381
382Deleting faculties
383------------------
384
385  >>> browser.open('http://localhost/myuniversity/faculties/manage')
386  >>> browser.getControl('Cancel').click()
387  >>> print browser.url
388  http://localhost/myuniversity/faculties
389  >>> browser.getLink('Manage academic section').click()
390  >>> browser.getControl('Add faculty').click()
391  >>> ctrl = browser.getControl(name='form.title')
392  >>> ctrl.value = 'Second Faculty'
393  >>> browser.getControl(name='form.code').value = 'TF2'
394  >>> browser.getControl('Add faculty').click()
395  >>> browser.open('http://localhost/myuniversity/faculties/manage')
396  >>> browser.getControl("Remove selected", index=0).click()
397  >>> 'No item selected' in browser.contents
398  True
399  >>> browser.open('http://localhost/myuniversity/faculties/manage')
400  >>> ctrl = browser.getControl(name='val_id')
401  >>> ctrl.getControl(value='TF2').selected = True
402  >>> browser.getControl("Remove selected", index=0).click()
403  >>> print browser.contents
404  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
405  ...Successfully removed:...
406  ...
407
408Departments
409===========
410
411Adding departments
412------------------
413
414Departments are stored in :class:`IFaculty` instances with their code
415as key. Faculties therefore are also department containers. Faculties
416provides an add-form to add new departments:
417
418  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
419  >>> print browser.contents
420  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
421  ...*</span>
422  ...<span>Name of department</span>:
423  ...
424  >>> browser.getControl('Cancel').click()
425  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
426
427We fill in a new name for our new department:
428
429  >>> ctrl = browser.getControl(name='form.title')
430  >>> ctrl.value = 'TestDept'
431
432Furthermore we add a code (kind of abbreviation):
433
434  >>> browser.getControl(name='form.code').value = 'TD'
435
436Finally we click on 'Add Department' to add the new thing::
437
438  >>> browser.getControl('Add department').click()
439
440If we try to register a department under the same code twice we will
441get an error:
442
443  >>> browser.open('http://localhost/myuniversity/faculties/TF/add')
444  >>> ctrl = browser.getControl(name='form.title')
445  >>> ctrl.value = 'Another TestDept with same code'
446  >>> browser.getControl(name='form.code').value = 'TD'
447  >>> browser.getControl('Add department').click()
448  >>> print browser.contents
449  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
450  ...The code chosen already exists in this faculty...
451  ...
452
453We can view a department by browsing a URL like this::
454
455  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
456
457Afterwards, the department should be visible::
458
459  >>> browser.open('http://localhost/myuniversity/faculties/TF')
460  >>> print browser.contents
461  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
462  ...<h1 class="kofa-content-label">Departments</h1>
463  ...<td> <a href="http://localhost/myuniversity/faculties/TF/TD"> <span>TD</span></a></td>
464  ...<td>Department of TestDept (TD)</td>
465  ...
466
467
468Modifying departments
469---------------------
470
471We can change the settings for a department by clicking on the
472provided 'Edit department' button:
473
474  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
475  >>> browser.getLink('Manage department').click()
476
477Let's set a new title and save the form:
478
479  >>> browser.getControl(name='form.title').value = "My test dept"
480  >>> browser.getControl(name='form.actions.save').click()
481
482Clicking 'Save' we will stay on the settings form. So we can change
483the department again.
484
485  >>> browser.getControl(name='form.title').value = "My renamed dept"
486  >>> ctrl = browser.getControl("Save")
487  >>> ctrl.click()
488
489
490Our department was indeed renamed to ``My renamed dept``:
491
492  >>> browser.open('http://localhost/myuniversity/faculties/TF')
493  >>> print browser.contents
494  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
495  ...<h1 class="kofa-content-label">Departments</h1>
496  ...<td> <a href="http://localhost/myuniversity/faculties/TF/TD"> <span>TD</span></a></td>
497  ...<td>Department of My renamed dept (TD)</td>
498  ...
499
500We can grant local roles:
501
502  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
503  >>> browser.getControl(name="user").value = ['bob']
504  >>> browser.getControl(
505  ...     name="local_role").value = ['waeup.local.DepartmentManager']
506  >>> browser.getControl("Add local role").click()
507  >>> print browser.contents
508  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
509  ...<td>bob</td>
510  ...
511
512The local role can be removed again:
513
514  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
515  >>> ctrl = browser.getControl(name='role_id')
516  >>> browser.getControl("Remove selected local roles").click()
517  >>> print browser.contents
518  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
519  ...No local role selected...
520  ...
521
522  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/manage')
523  >>> ctrl = browser.getControl(name='role_id')
524  >>> ctrl.getControl(
525  ...     value='bob|waeup.local.DepartmentManager').selected = True
526  >>> browser.getControl("Remove selected local roles").click()
527  >>> print browser.contents
528  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
529  ...Local role successfully removed...
530  ...
531
532Deleting departments
533--------------------
534
535  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
536  >>> browser.getControl('Cancel', index=0).click()
537  >>> print browser.url
538  http://localhost/myuniversity/faculties/TF
539  >>> browser.getLink('Manage faculty').click()
540  >>> browser.getControl('Add department').click()
541  >>> ctrl = browser.getControl(name='form.title')
542  >>> ctrl.value = 'Second Department'
543  >>> browser.getControl(name='form.code').value = 'TD2'
544  >>> browser.getControl('Add department').click()
545  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
546  >>> browser.getControl("Remove selected", index=0).click()
547  >>> 'No item selected' in browser.contents
548  True
549  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
550  >>> ctrl = browser.getControl(name='val_id')
551  >>> ctrl.getControl(value='TD2').selected = True
552  >>> browser.getControl("Remove selected", index=0).click()
553  >>> print browser.contents
554  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
555  ...Successfully removed:...
556  ...
557
558
559Courses
560=======
561
562Once we have a department, we can add courses.
563
564Adding courses
565--------------
566
567Courses are stored in :class:`ICoursesContainer` instances with their
568code as key. CoursesContainers are normally availabe as `course`
569attribute of :class:`waeup.kofa.university.department.Department`
570instances.
571
572To ease the life of officers we do not require to browse the
573coursescontainers (which have a rather flat user interface), but
574provide adding of courses in department views.
575
576Each department provides a ``Add course`` action button near top.
577
578Departments provide an add-form to add new courses:
579
580  >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD'
581  >>> browser.open(dept_url + '/manage')
582  >>> browser.getControl('Add course').click()
583  >>> print browser.contents
584  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
585  ...*</span>
586  ...<span>Title of course</span>:
587  ...
588
589We fill in a name for our new course:
590
591  >>> ctrl = browser.getControl(name='form.title')
592  >>> ctrl.value = 'My Course 1'
593
594Furthermore we add a code (kind of abbreviation):
595
596  >>> browser.getControl(name='form.code').value = 'COURSE1'
597
598This course will take place in the the first semester, so we set the
599`semester` value to 1:
600
601  >>> ctrl = browser.getControl(name='form.semester')
602  >>> ctrl.options
603  ['1', '2', '3', '9']
604
605  >>> ctrl.displayOptions
606  ['1st Semester', '2nd Semester', 'Combined', 'N/A']
607
608  >>> ctrl.value = ['1']
609
610Finally, we create the course:
611
612  >>> browser.getControl('Add course').click()
613
614If we try to register a course under the same code twice we will
615get an error:
616
617  >>> browser.open(dept_url + '/addcourse')
618  >>> ctrl = browser.getControl(name='form.title')
619  >>> ctrl.value = 'Another course with same code'
620  >>> browser.getControl(name='form.code').value = 'COURSE1'
621  >>> browser.getControl('Add course').click()
622  >>> print browser.contents
623  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
624  ...A course with same code already exists:...
625  ...
626
627Our course will be linked under the code on the department page:
628
629  >>> browser.open(dept_url)
630  >>> browser.getLink('COURSE1').click()
631  >>> browser.url
632  'http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1'
633
634Before we really add a course we can cancel the action and will be
635redirected to the department page:
636
637  >>> browser.open(dept_url + '/addcourse')
638  >>> browser.getControl('Cancel').click()
639  >>> browser.url
640  'http://localhost/myuniversity/faculties/TF/TD'
641
642
643Modifying courses
644-----------------
645
646We can change the settings for a course by clicking on the provided
647'Edit settings' link:
648
649  >>> browser.open(dept_url + '/courses/COURSE1')
650  >>> browser.getLink('Edit course').click()
651
652When modifying a course, we cannot change the code any more:
653
654  >>> browser.getControl(name='form.code')
655  Traceback (most recent call last):
656  ...
657  LookupError: name 'form.code'
658
659Let's set a new title and save the form:
660
661  >>> browser.getControl(name='form.title').value = "My test course"
662  >>> browser.getControl(name='form.actions.save').click()
663
664Clicking 'Save' we will stay on the settings form. So we can change
665the course again. If we click ``Cancel`` nothing will be
666changed:
667
668  >>> browser.getControl(name='form.title').value = "Blah"
669  >>> browser.getControl('Cancel').click()
670
671Our course was not renamed to ``Blah``:
672
673  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
674  >>> print browser.contents
675  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
676  ...<td>My test course</td>...
677  ...
678
679Searching courses
680-----------------
681
682  >>> browser.open('http://localhost/myuniversity/faculties/search')
683  >>> browser.getControl(name='query').value = "My test course"
684  >>> browser.getControl('Search').click()
685  >>> print browser.contents
686  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
687  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
688  ...
689
690  >>> browser.open('http://localhost/myuniversity/faculties/search')
691  >>> browser.getControl(name='query').value = "COURSE1"
692  >>> browser.getControl('Search').click()
693  >>> print browser.contents
694  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
695  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
696  ...
697
698  >>> browser.getControl(name='query').value = "Nonsense"
699  >>> browser.getControl('Search').click()
700  >>> 'Search Results' in browser.contents
701  False
702  >>> '<div class="alert alert-warning">No object found.</div>' in browser.contents
703  True
704
705  >>> browser.getControl(name='query').value = ""
706  >>> browser.getControl('Search').click()
707  >>> 'Empty search string' in browser.contents
708  True
709
710We can grant local roles:
711
712  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
713  >>> browser.getControl(name="user").value = ['bob']
714  >>> browser.getControl(
715  ...     name="local_role").value = ['waeup.local.Lecturer']
716  >>> browser.getControl("Add local role").click()
717  >>> print browser.contents
718  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
719  ...<td>bob</td>
720  ...
721
722On the portal user page the new local role is displayed:
723
724  >>> browser.getLink("Officers").click()
725  >>> print browser.contents
726  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
727  ...<td>Lecturer:...
728  ...
729
730The local role can be removed again:
731
732  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
733  >>> ctrl = browser.getControl(name='role_id')
734  >>> browser.getControl("Remove selected local roles").click()
735  >>> print browser.contents
736  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
737  ...No local role selected...
738  ...
739
740  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
741  >>> ctrl = browser.getControl(name='role_id')
742  >>> ctrl.getControl(value='bob|waeup.local.Lecturer').selected = True
743  >>> browser.getControl("Remove selected local roles").click()
744  >>> print browser.contents
745  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
746  ...Local role successfully removed...
747  ...
748
749Deleting courses
750----------------
751
752We can delete courses by browsing the manage page of the containing
753department and checking the appropriate select box and clicking the
754´´Remove selected´´ button.
755
756  >>> browser.open(
757  ...     'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2')
758  >>> 'My test course' in browser.contents
759  True
760
761  >>> browser.getControl('Cancel', index=0).click()
762  >>> browser.getLink('Manage department').click()
763  >>> browser.getControl('Remove selected courses').click()
764  >>> 'No item selected' in browser.contents
765  True
766
767  >>> browser.getControl(
768  ...    name='val_id').getControl(value='COURSE1').selected = True
769  >>> browser.getControl('Remove selected courses').click()
770
771  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
772  >>> 'My renamed course' in browser.contents
773  False
774
775
776Deleting departments with courses
777---------------------------------
778
779  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
780  >>> browser.getControl('Cancel', index=0).click()
781  >>> browser.getLink('Manage faculty').click()
782  >>> browser.getControl('Add department').click()
783  >>> ctrl = browser.getControl(name='form.title')
784  >>> ctrl.value = 'Third Department'
785  >>> browser.getControl(name='form.code').value = 'TD3'
786  >>> browser.getControl('Add department').click()
787  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD3/manage')
788  >>> browser.getControl('Add course').click()
789  >>> ctrl = browser.getControl(name='form.title')
790  >>> ctrl.value = 'My Course 5'
791  >>> browser.getControl(name='form.code').value = 'COURSE5'
792  >>> browser.getControl('Add course').click()
793  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
794  >>> ctrl = browser.getControl(name='val_id')
795  >>> ctrl.getControl(value='TD3').selected = True
796  >>> browser.getControl("Remove selected", index=0).click()
797  >>> print browser.contents
798  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
799  ...Successfully removed:...
800  ...
801
802Certificates
803============
804
805Once we have a department, we can add also certificates.
806
807Adding certificates
808-------------------
809
810Certificates are stored in :class:`ICertificatesContainer` instances
811with their code as key. CertificatesContainers are normally availabe as
812`certificates` attribute of
813:class:`waeup.kofa.university.department.Department` instances.
814
815To ease the life of officers we do not require to browse the
816certificatescontainers (which have in fact no user interface), but
817provide adding of certificates in department views.
818
819Each department provides a ``Add certificate`` action button near top.
820
821Departments provide an add-form to add new certificates:
822
823  >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD'
824  >>> browser.open(dept_url + '/manage')
825  >>> browser.getControl('Add certificate').click()
826  >>> print browser.contents
827  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
828  ...*</span>
829  ...<span>Title</span>:
830  ...
831
832We fill in a name for our new cert:
833
834  >>> ctrl = browser.getControl(name='form.title')
835  >>> ctrl.value = 'My Certificate 1'
836
837Furthermore we add a code (kind of abbreviation):
838
839  >>> browser.getControl(name='form.code').value = 'CERT1'
840
841Set the remaining required fields:
842
843  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
844  >>> browser.getControl(name='form.start_level').value = ['100']
845  >>> browser.getControl(name='form.end_level').value = ['400']
846  >>> browser.getControl(name='form.application_category').value = ['basic']
847
848Finally, we create the certificate:
849
850  >>> browser.getControl('Add certificate').click()
851
852If we try to register a certificate under the same code twice we will
853get an error:
854
855  >>> browser.open(dept_url + '/addcertificate')
856  >>> ctrl = browser.getControl(name='form.title')
857  >>> ctrl.value = 'Another cert with same code'
858  >>> browser.getControl(name='form.code').value = 'CERT1'
859  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
860  >>> browser.getControl(name='form.start_level').value = ['100']
861  >>> browser.getControl(name='form.end_level').value = ['400']
862  >>> browser.getControl(name='form.application_category').value = ['basic']
863
864  >>> browser.getControl('Add certificate').click()
865  >>> print browser.contents
866  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
867  ...A certificate with same code already exists:...
868  ...
869
870Our certificate will be linked under the code on the department page:
871
872  >>> browser.open(dept_url)
873  >>> browser.getLink('CERT1').click()
874  >>> browser.url
875  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
876
877Before we really add a certificate we can cancel the action and will be
878redirected to the department page:
879
880  >>> browser.open(dept_url + '/addcertificate')
881  >>> browser.getControl('Cancel').click()
882  >>> browser.url
883  'http://localhost/myuniversity/faculties/TF/TD'
884
885
886Modifying certificates
887----------------------
888
889We can change the settings for a cert by clicking on the provided
890'Edit certificate' link:
891
892  >>> browser.open(dept_url + '/certificates/CERT1')
893  >>> browser.getLink('Manage certificate').click()
894
895When modifying a certificate, we cannot change the code any more:
896
897  >>> browser.getControl(name='form.code')
898  Traceback (most recent call last):
899  ...
900  LookupError: name 'form.code'
901
902Let's set a new title and save the form:
903
904  >>> browser.getControl(name='form.title').value = "My test cert"
905  >>> browser.getControl(name='form.actions.save').click()
906
907Clicking 'Save' we will stay on the settings form. So we can change
908the cert again.
909
910  >>> browser.getControl(name='form.title').value = "My renamed cert"
911  >>> ctrl = browser.getControl("Save",index=0)
912  >>> ctrl.click()
913
914If we go to the settings page and click ``Cancel`` nothing will be
915changed:
916
917  >>> browser.getControl(name='form.title').value = "Blah"
918  >>> browser.getControl('Cancel',index=0).click()
919
920Our certificate was indeed renamed to ``My renamed cert`` and not to
921``Blah``:
922
923  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
924  >>> print browser.contents
925  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
926  ...<td>My renamed cert</td>...
927  ...
928
929Searching certificates
930----------------------
931
932  >>> browser.open('http://localhost/myuniversity/faculties/search')
933  >>> browser.getControl(name='query').value = "My renamed cert"
934  >>> browser.getControl('Search').click()
935  >>> print browser.contents
936  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
937  ...faculties/TF/TD/certificates/CERT1">CERT1</a>
938  ...
939
940  >>> browser.open('http://localhost/myuniversity/faculties/search')
941  >>> browser.getControl(name='query').value = "CERT1"
942  >>> browser.getControl('Search').click()
943  >>> print browser.contents
944  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
945  ...faculties/TF/TD/certificates/CERT1">CERT1</a>
946  ...
947
948Deleting certificates
949---------------------
950
951We can delete certificates by browsing the manage page of the
952containing department and checking the appropriate select box and
953clicking the ´´Remove selected´´ button.
954
955  >>> browser.open(
956  ...    'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3')
957  >>> 'My renamed cert' in browser.contents
958  True
959
960  >>> browser.getControl('Remove selected certificates').click()
961  >>> 'No item selected' in browser.contents
962  True
963
964  >>> browser.getControl(name='val_id').getControl(
965  ...    value='CERT1').selected = True
966  >>> browser.getControl('Remove selected certificates').click()
967  >>> 'My renamed cert' in browser.contents
968  False
969
970
971Certificate Courses
972===================
973
974Once we have a certificate, we can add also certificate courses. These
975are referrers of courses with some extra data.
976
977Before we can work with certificate courses, we need some certificates
978and courses to be available.
979
980  >>> browser.open(dept_url + '/addcourse')
981  >>> ctrl = browser.getControl(name='form.title')
982  >>> ctrl.value = 'Another course with same code'
983  >>> browser.getControl(name='form.code').value = 'COURSE1'
984  >>> browser.getControl(name='form.title').value = 'Course 1'
985  >>> browser.getControl('Add course').click()
986
987  >>> browser.open(dept_url + '/addcourse')
988  >>> ctrl = browser.getControl(name='form.title')
989  >>> ctrl.value = 'Another course with same code'
990  >>> browser.getControl(name='form.code').value = 'COURSE2'
991  >>> browser.getControl(name='form.title').value = 'Course 2'
992  >>> browser.getControl('Add course').click()
993
994  >>> browser.open(dept_url + '/addcertificate')
995  >>> ctrl = browser.getControl(name='form.title')
996  >>> ctrl.value = 'Another cert with same code'
997  >>> browser.getControl(name='form.code').value = 'CERT1'
998  >>> browser.getControl(name='form.title').value = 'Certificate 1'
999  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1000  >>> browser.getControl(name='form.start_level').value = ['100']
1001  >>> browser.getControl(name='form.end_level').value = ['400']
1002  >>> browser.getControl(name='form.application_category').value = ['basic']
1003  >>> browser.getControl('Add certificate').click()
1004
1005  >>> browser.open(dept_url + '/addcertificate')
1006  >>> ctrl = browser.getControl(name='form.title')
1007  >>> ctrl.value = 'Another cert with same code'
1008  >>> browser.getControl(name='form.code').value = 'CERT2'
1009  >>> browser.getControl(name='form.title').value = 'Certificate 2'
1010  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1011  >>> browser.getControl(name='form.start_level').value = ['100']
1012  >>> browser.getControl(name='form.end_level').value = ['400']
1013  >>> browser.getControl(name='form.application_category').value = ['basic']
1014  >>> browser.getControl('Add certificate').click()
1015
1016
1017Adding certificate courses
1018--------------------------
1019
1020Certcourses are stored in :class:`ICertificate` instances
1021with their code as key.
1022
1023Each certificate provides a ``Add certificate course`` action button near top.
1024
1025Certificates provide an add-form to add new certcourses:
1026
1027  >>> cert_url = dept_url + '/certificates/CERT1'
1028  >>> browser.open(cert_url + '/manage')
1029  >>> browser.getControl('Add certificate course').click()
1030  >>> print browser.contents
1031  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1032  ...*</span>
1033  ...<span>Level</span>:
1034  ...
1035
1036In the add-form we will get a list of available courses to select
1037from. This list will contain all courses stored in the site, not only
1038the ones from local department:
1039
1040  >>> ctrl = browser.getControl(name='form.course')
1041  >>> ctrl.displayOptions
1042  ['--', 'COURSE1 - Course 1', 'COURSE2 - Course 2']
1043
1044We select the first course and create our certificate course:
1045
1046  >>> ctrl.getControl('COURSE1').selected = True
1047  >>> browser.getControl(name='form.level').value = ['100']
1048  >>> browser.getControl('Add certificate course').click()
1049
1050Our certificate course will be linked on the parent certificate page:
1051
1052  >>> browser.open(cert_url)
1053  >>> browser.getLink('COURSE1_100').click()
1054  >>> browser.url
1055  'http://localhost/my...sity/faculties/TF/TD/certificates/CERT1/COURSE1_100'
1056
1057We can't add the same certificate course twice:
1058
1059  >>> cert_url = dept_url + '/certificates/CERT1'
1060  >>> browser.open(cert_url + '/manage')
1061  >>> browser.getControl('Add certificate course').click()
1062  >>> ctrl = browser.getControl(name='form.course')
1063  >>> ctrl.getControl('COURSE1').selected = True
1064  >>> browser.getControl(name='form.level').value = ['100']
1065  >>> browser.getControl('Add certificate course').click()
1066  >>> 'The chosen certificate course is already' in browser.contents
1067  True
1068
1069When we started to add a new certificate course, we can also cancel the
1070process before submitting. This will bring us back to the certificate
1071page:
1072
1073  >>> browser.open(cert_url + '/addcertificatecourse')
1074  >>> browser.getControl('Cancel').click()
1075  >>> browser.url
1076  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
1077
1078
1079Modifying certificate courses
1080-----------------------------
1081
1082We can change the settings for a certcourse by clicking on the
1083provided 'Edit certificate course' link:
1084
1085  >>> browser.open(cert_url + '/COURSE1_100')
1086  >>> browser.getLink('Edit certificate course').click()
1087
1088If we just click 'Save and return' nothing will change:
1089
1090  >>> browser.getControl("Save and return").click()
1091  >>> browser.getLink('COURSE1_100').click()
1092  >>> browser.url
1093  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_100'
1094
1095Let's set a new level (it was 100 before) and save the form. This will
1096bring us to the certificate index page afterwards:
1097
1098  >>> browser.open(cert_url + '/COURSE1_100/manage')
1099  >>> browser.getControl(name='form.level').value = ['200']
1100  >>> browser.getControl("Save and return").click()
1101
1102As we changed the level, also the URL will change:
1103
1104  >>> browser.getLink('COURSE1_200').click()
1105  >>> browser.url
1106  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200'
1107
1108If we go to the settings page and click ``Cancel`` nothing will be
1109changed:
1110
1111  >>> browser.getLink('Edit certificate course').click()
1112  >>> browser.getControl(name='form.level').value = ['400']
1113  >>> browser.getControl('Cancel').click()
1114
1115Our certcourse provides a new level of 200 and not 400:
1116
1117  >>> browser.open(cert_url + '/COURSE1_200')
1118  >>> print browser.contents
1119  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1120  ...<td>Level:</td>
1121  ...<td>200 (Year 2)</td>
1122  ...
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', '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', '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.