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

Last change on this file since 14976 was 14648, checked in by Henrik Bettermann, 8 years ago

Redirect to manage page after editing of certificate courses.

File size: 44.0 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  available items:
659    <TextControl(form.title=My Course 1)>
660    ...
661
662
663Let's set a new title and save the form:
664
665  >>> browser.getControl(name='form.title').value = "My test course"
666  >>> browser.getControl(name='form.actions.save').click()
667
668Clicking 'Save' we will stay on the settings form. So we can change
669the course again. If we click ``Cancel`` nothing will be
670changed:
671
672  >>> browser.getControl(name='form.title').value = "Blah"
673  >>> browser.getControl('Cancel').click()
674
675Our course was not renamed to ``Blah``:
676
677  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
678  >>> print browser.contents
679  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
680  ...<td>My test course</td>...
681  ...
682
683Searching courses
684-----------------
685
686  >>> browser.open('http://localhost/myuniversity/faculties/search')
687  >>> browser.getControl(name='query').value = "My test course"
688  >>> browser.getControl('Search').click()
689  >>> print browser.contents
690  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
691  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
692  ...
693
694  >>> browser.open('http://localhost/myuniversity/faculties/search')
695  >>> browser.getControl(name='query').value = "COURSE1"
696  >>> browser.getControl('Search').click()
697  >>> print browser.contents
698  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
699  ...faculties/TF/TD/courses/COURSE1">COURSE1</a>
700  ...
701
702  >>> browser.getControl(name='query').value = "Nonsense"
703  >>> browser.getControl('Search').click()
704  >>> 'Search Results' in browser.contents
705  False
706  >>> '<div class="alert alert-warning">No object found.</div>' in browser.contents
707  True
708
709  >>> browser.getControl(name='query').value = ""
710  >>> browser.getControl('Search').click()
711  >>> 'Empty search string' in browser.contents
712  True
713
714We can grant local roles:
715
716  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
717  >>> browser.getControl(name="user").value = ['bob']
718  >>> browser.getControl(
719  ...     name="local_role").value = ['waeup.local.Lecturer']
720  >>> browser.getControl("Add local role").click()
721  >>> print browser.contents
722  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
723  ...<td>bob</td>
724  ...
725
726On the portal user page the new local role is displayed:
727
728  >>> browser.getLink("Officers").click()
729  >>> print browser.contents
730  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
731  ...<td>Lecturer:...
732  ...
733
734The local role can be removed again:
735
736  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
737  >>> ctrl = browser.getControl(name='role_id')
738  >>> browser.getControl("Remove selected local roles").click()
739  >>> print browser.contents
740  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
741  ...No local role selected...
742  ...
743
744  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
745  >>> ctrl = browser.getControl(name='role_id')
746  >>> ctrl.getControl(value='bob|waeup.local.Lecturer').selected = True
747  >>> browser.getControl("Remove selected local roles").click()
748  >>> print browser.contents
749  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
750  ...Local role successfully removed...
751  ...
752
753Deleting courses
754----------------
755
756We can delete courses by browsing the manage page of the containing
757department and checking the appropriate select box and clicking the
758´´Remove selected´´ button.
759
760  >>> browser.open(
761  ...     'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2')
762  >>> 'My test course' in browser.contents
763  True
764
765  >>> browser.getControl('Cancel', index=0).click()
766  >>> browser.getLink('Manage department').click()
767  >>> browser.getControl('Remove selected courses').click()
768  >>> 'No item selected' in browser.contents
769  True
770
771  >>> browser.getControl(
772  ...    name='val_id').getControl(value='COURSE1').selected = True
773  >>> browser.getControl('Remove selected courses').click()
774
775  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
776  >>> 'My renamed course' in browser.contents
777  False
778
779
780Deleting departments with courses
781---------------------------------
782
783  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
784  >>> browser.getControl('Cancel', index=0).click()
785  >>> browser.getLink('Manage faculty').click()
786  >>> browser.getControl('Add department').click()
787  >>> ctrl = browser.getControl(name='form.title')
788  >>> ctrl.value = 'Third Department'
789  >>> browser.getControl(name='form.code').value = 'TD3'
790  >>> browser.getControl('Add department').click()
791  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD3/manage')
792  >>> browser.getControl('Add course').click()
793  >>> ctrl = browser.getControl(name='form.title')
794  >>> ctrl.value = 'My Course 5'
795  >>> browser.getControl(name='form.code').value = 'COURSE5'
796  >>> browser.getControl('Add course').click()
797  >>> browser.open('http://localhost/myuniversity/faculties/TF/manage')
798  >>> ctrl = browser.getControl(name='val_id')
799  >>> ctrl.getControl(value='TD3').selected = True
800  >>> browser.getControl("Remove selected", index=0).click()
801  >>> print browser.contents
802  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
803  ...Successfully removed:...
804  ...
805
806Certificates
807============
808
809Once we have a department, we can add also certificates.
810
811Adding certificates
812-------------------
813
814Certificates are stored in :class:`ICertificatesContainer` instances
815with their code as key. CertificatesContainers are normally availabe as
816`certificates` attribute of
817:class:`waeup.kofa.university.department.Department` instances.
818
819To ease the life of officers we do not require to browse the
820certificatescontainers (which have in fact no user interface), but
821provide adding of certificates in department views.
822
823Each department provides a ``Add certificate`` action button near top.
824
825Departments provide an add-form to add new certificates:
826
827  >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD'
828  >>> browser.open(dept_url + '/manage')
829  >>> browser.getControl('Add certificate').click()
830  >>> print browser.contents
831  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
832  ...*</span>
833  ...<span>Title</span>:
834  ...
835
836We fill in a name for our new cert:
837
838  >>> ctrl = browser.getControl(name='form.title')
839  >>> ctrl.value = 'My Certificate 1'
840
841Furthermore we add a code (kind of abbreviation):
842
843  >>> browser.getControl(name='form.code').value = 'CERT1'
844
845Set the remaining required fields:
846
847  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
848  >>> browser.getControl(name='form.start_level').value = ['100']
849  >>> browser.getControl(name='form.end_level').value = ['400']
850  >>> browser.getControl(name='form.application_category').value = ['basic']
851
852Finally, we create the certificate:
853
854  >>> browser.getControl('Add certificate').click()
855
856If we try to register a certificate under the same code twice we will
857get an error:
858
859  >>> browser.open(dept_url + '/addcertificate')
860  >>> ctrl = browser.getControl(name='form.title')
861  >>> ctrl.value = 'Another cert with same code'
862  >>> browser.getControl(name='form.code').value = 'CERT1'
863  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
864  >>> browser.getControl(name='form.start_level').value = ['100']
865  >>> browser.getControl(name='form.end_level').value = ['400']
866  >>> browser.getControl(name='form.application_category').value = ['basic']
867
868  >>> browser.getControl('Add certificate').click()
869  >>> print browser.contents
870  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
871  ...A certificate with same code already exists:...
872  ...
873
874Our certificate will be linked under the code on the department page:
875
876  >>> browser.open(dept_url)
877  >>> browser.getLink('CERT1').click()
878  >>> browser.url
879  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
880
881Before we really add a certificate we can cancel the action and will be
882redirected to the department page:
883
884  >>> browser.open(dept_url + '/addcertificate')
885  >>> browser.getControl('Cancel').click()
886  >>> browser.url
887  'http://localhost/myuniversity/faculties/TF/TD'
888
889
890Modifying certificates
891----------------------
892
893We can change the settings for a cert by clicking on the provided
894'Edit certificate' link:
895
896  >>> browser.open(dept_url + '/certificates/CERT1')
897  >>> browser.getLink('Manage certificate').click()
898
899When modifying a certificate, we cannot change the code any more:
900
901  >>> browser.getControl(name='form.code')
902  Traceback (most recent call last):
903  ...
904  LookupError: name 'form.code'
905  available items:
906    <TextControl(form.title=My Certificate 1)>
907    ...
908
909
910Let's set a new title and save the form:
911
912  >>> browser.getControl(name='form.title').value = "My test cert"
913  >>> browser.getControl(name='form.actions.save').click()
914
915Clicking 'Save' we will stay on the settings form. So we can change
916the cert again.
917
918  >>> browser.getControl(name='form.title').value = "My renamed cert"
919  >>> ctrl = browser.getControl("Save",index=0)
920  >>> ctrl.click()
921
922If we go to the settings page and click ``Cancel`` nothing will be
923changed:
924
925  >>> browser.getControl(name='form.title').value = "Blah"
926  >>> browser.getControl('Cancel',index=0).click()
927
928Our certificate was indeed renamed to ``My renamed cert`` and not to
929``Blah``:
930
931  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
932  >>> print browser.contents
933  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
934  ...<td>My renamed cert</td>...
935  ...
936
937Searching certificates
938----------------------
939
940  >>> browser.open('http://localhost/myuniversity/faculties/search')
941  >>> browser.getControl(name='query').value = "My renamed cert"
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
948  >>> browser.open('http://localhost/myuniversity/faculties/search')
949  >>> browser.getControl(name='query').value = "CERT1"
950  >>> browser.getControl('Search').click()
951  >>> print browser.contents
952  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
953  ...faculties/TF/TD/certificates/CERT1">CERT1</a>
954  ...
955
956Deleting certificates
957---------------------
958
959We can delete certificates by browsing the manage page of the
960containing department and checking the appropriate select box and
961clicking the ´´Remove selected´´ button.
962
963  >>> browser.open(
964  ...    'http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3')
965  >>> 'My renamed cert' in browser.contents
966  True
967
968  >>> browser.getControl('Remove selected certificates').click()
969  >>> 'No item selected' in browser.contents
970  True
971
972  >>> browser.getControl(name='val_id').getControl(
973  ...    value='CERT1').selected = True
974  >>> browser.getControl('Remove selected certificates').click()
975  >>> 'My renamed cert' in browser.contents
976  False
977
978
979Certificate Courses
980===================
981
982Once we have a certificate, we can add also certificate courses. These
983are referrers of courses with some extra data.
984
985Before we can work with certificate courses, we need some certificates
986and courses to be available.
987
988  >>> browser.open(dept_url + '/addcourse')
989  >>> ctrl = browser.getControl(name='form.title')
990  >>> ctrl.value = 'Another course with same code'
991  >>> browser.getControl(name='form.code').value = 'COURSE1'
992  >>> browser.getControl(name='form.title').value = 'Course 1'
993  >>> browser.getControl('Add course').click()
994
995  >>> browser.open(dept_url + '/addcourse')
996  >>> ctrl = browser.getControl(name='form.title')
997  >>> ctrl.value = 'Another course with same code'
998  >>> browser.getControl(name='form.code').value = 'COURSE2'
999  >>> browser.getControl(name='form.title').value = 'Course 2'
1000  >>> browser.getControl('Add course').click()
1001
1002  >>> browser.open(dept_url + '/addcertificate')
1003  >>> ctrl = browser.getControl(name='form.title')
1004  >>> ctrl.value = 'Another cert with same code'
1005  >>> browser.getControl(name='form.code').value = 'CERT1'
1006  >>> browser.getControl(name='form.title').value = 'Certificate 1'
1007  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1008  >>> browser.getControl(name='form.start_level').value = ['100']
1009  >>> browser.getControl(name='form.end_level').value = ['400']
1010  >>> browser.getControl(name='form.application_category').value = ['basic']
1011  >>> browser.getControl('Add certificate').click()
1012
1013  >>> browser.open(dept_url + '/addcertificate')
1014  >>> ctrl = browser.getControl(name='form.title')
1015  >>> ctrl.value = 'Another cert with same code'
1016  >>> browser.getControl(name='form.code').value = 'CERT2'
1017  >>> browser.getControl(name='form.title').value = 'Certificate 2'
1018  >>> browser.getControl(name='form.study_mode').value = ['ug_ft']
1019  >>> browser.getControl(name='form.start_level').value = ['100']
1020  >>> browser.getControl(name='form.end_level').value = ['400']
1021  >>> browser.getControl(name='form.application_category').value = ['basic']
1022  >>> browser.getControl('Add certificate').click()
1023
1024
1025Adding certificate courses
1026--------------------------
1027
1028Certcourses are stored in :class:`ICertificate` instances
1029with their code as key.
1030
1031Each certificate provides a ``Add certificate course`` action button near top.
1032
1033Certificates provide an add-form to add new certcourses:
1034
1035  >>> cert_url = dept_url + '/certificates/CERT1'
1036  >>> browser.open(cert_url + '/manage')
1037  >>> browser.getControl('Add certificate course').click()
1038  >>> print browser.contents
1039  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1040  ...*</span>
1041  ...<span>Level</span>:
1042  ...
1043
1044In the add-form we will get a list of available courses to select
1045from. This list will contain all courses stored in the site, not only
1046the ones from local department:
1047
1048  >>> ctrl = browser.getControl(name='form.course')
1049  >>> ctrl.displayOptions
1050  ['--', 'COURSE1 - Course 1', 'COURSE2 - Course 2']
1051
1052We select the first course and create our certificate course:
1053
1054  >>> ctrl.getControl('COURSE1').selected = True
1055  >>> browser.getControl(name='form.level').value = ['100']
1056  >>> browser.getControl('Add certificate course').click()
1057
1058Our certificate course will be linked on the parent certificate page:
1059
1060  >>> browser.open(cert_url)
1061  >>> browser.getLink('COURSE1_100').click()
1062  >>> browser.url
1063  'http://localhost/my...sity/faculties/TF/TD/certificates/CERT1/COURSE1_100'
1064
1065We can't add the same certificate course twice:
1066
1067  >>> cert_url = dept_url + '/certificates/CERT1'
1068  >>> browser.open(cert_url + '/manage')
1069  >>> browser.getControl('Add certificate course').click()
1070  >>> ctrl = browser.getControl(name='form.course')
1071  >>> ctrl.getControl('COURSE1').selected = True
1072  >>> browser.getControl(name='form.level').value = ['100']
1073  >>> browser.getControl('Add certificate course').click()
1074  >>> 'The chosen certificate course is already' in browser.contents
1075  True
1076
1077When we started to add a new certificate course, we can also cancel the
1078process before submitting. This will bring us back to the certificate
1079page:
1080
1081  >>> browser.open(cert_url + '/addcertificatecourse')
1082  >>> browser.getControl('Cancel').click()
1083  >>> browser.url
1084  'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1'
1085
1086
1087Modifying certificate courses
1088-----------------------------
1089
1090We can change the settings for a certcourse by clicking on the
1091provided 'Edit certificate course' link:
1092
1093  >>> browser.open(cert_url + '/COURSE1_100')
1094  >>> browser.getLink('Edit certificate course').click()
1095
1096If we just click 'Save and return' nothing will change:
1097
1098  >>> browser.getControl("Save").click()
1099  >>> browser.url
1100  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_100/@@manage'
1101
1102Let's set a new level (it was 100 before) and save the form. The entire
1103certificate course will be replaced and we will be redirected to manage
1104page afterwards:
1105
1106  >>> browser.getControl(name='form.level').value = ['200']
1107  >>> browser.getControl("Save").click()
1108  >>> browser.url
1109  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200/@@manage'
1110
1111Nothing will be changed if click ``Cancel``:
1112
1113  >>> browser.getControl(name='form.level').value = ['400']
1114  >>> browser.getControl('Cancel').click()
1115  >>> browser.url
1116  'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200'
1117
1118Searching certificate courses
1119-----------------------------
1120
1121  >>> browser.open('http://localhost/myuniversity/faculties/search')
1122  >>> browser.getControl(name='query').value = "COURSE1"
1123  >>> browser.getControl('Search').click()
1124  >>> print browser.contents
1125  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1126  ...faculties/TF/TD/certificates/CERT1/COURSE1_200">COURSE1</a>
1127  ...
1128
1129  >>> browser.getControl(name='query').value = "*"
1130  >>> browser.getControl('Search').click()
1131  >>> 'Search string not allowed' in browser.contents
1132  True
1133
1134Deleting certificate courses
1135----------------------------
1136
1137We can delete certcourses by browsing the containing certificate manage page:
1138
1139  >>> browser.open(cert_url + '/manage#tab-2')
1140  >>> 'COURSE1_200</a>' in browser.contents
1141  True
1142  >>> browser.getControl('Remove selected certificate courses').click()
1143  >>> 'No item selected' in browser.contents
1144  True
1145  >>> browser.getControl(name='val_id').getControl(
1146  ...    value='COURSE1_200').selected = True
1147  >>> browser.getControl('Remove selected certificate courses').click()
1148  >>> 'Successfully removed: COURSE1_200' in browser.contents
1149  True
1150
1151  >>> 'COURSE1_200</a>' in browser.contents
1152  False
1153
1154
1155
1156Data Center
1157===========
1158
1159The data center helps us uploading files for later import or similar.
1160
1161  >>> browser.open('http://localhost/myuniversity')
1162  >>> browser.getLink('Data Center').click()
1163
1164Setting the file path
1165---------------------
1166
1167A datacenter stores files in a path in filesystem. By default this is
1168a directory in the sources:
1169
1170  >>> print browser.contents
1171  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1172  ...
1173  <b>Storage path:</b> <span>.../parts/test/datacenter</span>
1174  ...
1175
1176Going to 'Settings` we can change the path:
1177
1178  >>> browser.getLink('Edit settings').click()
1179  >>> pathsetting = browser.getControl(name='newpath')
1180
1181We create a directory and set it as our upload path:
1182
1183  >>> import os
1184  >>> cwd = os.getcwd()
1185  >>> uploadpath = os.path.join(cwd, 'testfiles')
1186  >>> os.mkdir(uploadpath)
1187  >>> pathsetting.value = uploadpath
1188
1189And submit the form:
1190
1191  >>> browser.getControl(name='save').click()
1192
1193We clean up the set directory path, as there might be some files be
1194copied some files from installation:
1195
1196  >>> files = os.listdir(uploadpath)
1197  >>> for filename in files:
1198  ...   if os.path.isdir(os.path.join(uploadpath, filename)):
1199  ...     continue
1200  ...   os.unlink(os.path.join(uploadpath, filename))
1201
1202We also remove any existing 'accesscodes' subdir:
1203
1204  >>> import shutil
1205  >>> for filename in files:
1206  ...   if not os.path.isdir(os.path.join(uploadpath, filename)):
1207  ...     continue
1208  ...   if filename != 'accesscodes':
1209  ...     continue
1210  ...   shutil.rmtree(os.path.join(uploadpath, filename))
1211
1212The new upload directory is now empty, except from the logs and other
1213standard dirs, which are created automatically:
1214
1215  >>> sorted(os.listdir(uploadpath))
1216  ['deleted', 'finished', 'logs', 'unfinished']
1217
1218
1219Uploading files
1220---------------
1221
1222Now we can upload files. Most interesting files might be CSV files,
1223that can be imported lateron. We create a CSV file containing faculty
1224descriptions:
1225
1226  >>> open('faculties.csv', 'wb').write(
1227  ... """code,title,title_prefix
1228  ... FA,Arts,faculty
1229  ... FS,Sciences,faculty
1230  ... """)
1231
1232Now we can upload this file. To do this, we first go to the upload
1233page:
1234
1235  >>> browser.getLink('Upload data').click()
1236
1237and enter the appropriate data in the form:
1238
1239  >>> filewidget = browser.getControl(name='uploadfile:file')
1240  >>> filewidget
1241  <Control name='uploadfile:file' type='file'>
1242
1243A sidenote for developers: by marking the filewidget with the
1244``:file`` extension, we tell Zope to handle this field as a file
1245widget.
1246
1247  >>> import cStringIO
1248  >>> filecontents = cStringIO.StringIO(
1249  ...   open('faculties.csv', 'rb').read())
1250  >>> filewidget.add_file(filecontents, 'text/plain', 'myfaculties.csv')
1251
1252  >>> browser.getControl(name='SUBMIT').click()
1253
1254The file was indeed uploaded, with the current userid inserted:
1255
1256  >>> sorted(os.listdir(uploadpath))
1257  ['deleted', 'finished', 'logs', 'myfaculties_zope.mgr.csv', 'unfinished']
1258
1259We create and upload also a CSV file containing departments:
1260
1261  >>> open('departments.csv', 'wb').write(
1262  ... """code,title,title_prefix,faculty_code
1263  ... LIT,Literature,department,FA
1264  ... SOC,Sociology,department,FA
1265  ... PHY,Physics,department,FS
1266  ... INF,Informatics,department,FS
1267  ... MAT,Math,department,FS
1268  ... """)
1269
1270  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1271  >>> browser.getControl(name='uploadfile:file').add_file(
1272  ...   cStringIO.StringIO(open('departments.csv', 'rb').read()),
1273  ...   'text/plain', 'mydepartments.csv')
1274  >>> browser.getControl(name='SUBMIT').click()
1275
1276We create and upload also a CSV file containing courses:
1277
1278  >>> open('courses.csv', 'wb').write(
1279  ... """code,level,title,passmark,credits,semester,faculty,department
1280  ... LI1,,Introduction to Literature I,40,2,1,FA,LIT
1281  ... LI2,,Introduction to Literature II,40,2,2,FA,LIT
1282  ... AN1,000,Analysis I,40,2,1,FS,MAT
1283  ... AN2,000,Analysis II,40,2,2,FS,MAT
1284  ... """)
1285
1286  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1287  >>> browser.getControl(name='uploadfile:file').add_file(
1288  ...   cStringIO.StringIO(open('courses.csv', 'rb').read()),
1289  ...   'text/plain', 'mycourses.csv')
1290  >>> browser.getControl(name='SUBMIT').click()
1291
1292We create and upload also a CSV file containing certificates:
1293
1294  >>> open('certificates.csv', 'wb').write(
1295  ... """code,title,faculty_code,department_code,study_mode,end_level,m_prefix,start_level,application_category
1296  ... LBA,BACHELOR OF LITERATURE,FA,LIT,UG,ug_ft,500,LIT,100,basic
1297  ... LMA,MASTER OF LITERATURE,FA,LIT,UG,ug_pt,500,LIT,100,cest
1298  ... DME,DIPLOMA OF MATH,FS,MAT,DP,dp_ft,200,DME,100,cest
1299  ... """)
1300
1301  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1302  >>> browser.getControl(name='uploadfile:file').add_file(
1303  ...   cStringIO.StringIO(open('certificates.csv', 'rb').read()),
1304  ...   'text/plain', 'mycertificates.csv')
1305  >>> browser.getControl(name='SUBMIT').click()
1306
1307We create and upload also a CSV file containing certificate courses:
1308
1309  >>> open('certcourses.csv', 'wb').write(
1310  ... """code,faculty_code,department_code,certificate_code,level,mandatory
1311  ... LI1,FA,LIT,LBA,100,True
1312  ... LI2,FA,LIT,LBA,200,True
1313  ... """)
1314
1315  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
1316  >>> browser.getControl(name='uploadfile:file').add_file(
1317  ...   cStringIO.StringIO(open('certcourses.csv', 'rb').read()),
1318  ...   'text/plain', 'mycertcourses.csv')
1319  >>> browser.getControl(name='SUBMIT').click()
1320
1321
1322Importing a CSV file
1323--------------------
1324
1325The import of CSV files is described in batchprocessing.txt.
1326
1327
1328Clean up:
1329
1330  >>> import os
1331  >>> import shutil
1332  >>> shutil.rmtree(uploadpath)
1333
Note: See TracBrowser for help on using the repository browser.