source: main/waeup.kofa/trunk/src/waeup/kofa/browser/browser.txt @ 12697

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

Show flash message on general search page for the academics section.

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