1 | Browsing the WAeUP portal |
---|
2 | ************************* |
---|
3 | |
---|
4 | Here we visit all parts of a WAeUP portal using a browser. |
---|
5 | |
---|
6 | :Test-Layer: functional |
---|
7 | |
---|
8 | University |
---|
9 | ========== |
---|
10 | |
---|
11 | We can watch universities in the browser. |
---|
12 | |
---|
13 | To make sure, we can 'watch' pages, we first have to initialize out |
---|
14 | test browser:: |
---|
15 | |
---|
16 | >>> from zope.testbrowser.testing import Browser |
---|
17 | >>> browser = Browser() |
---|
18 | >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
19 | >>> browser.handleErrors = False |
---|
20 | |
---|
21 | We create an university object and put into the ZODB root:: |
---|
22 | |
---|
23 | >>> root = getRootFolder() |
---|
24 | >>> list(root) |
---|
25 | [] |
---|
26 | |
---|
27 | >>> from waeup.sirp.app import University |
---|
28 | >>> u = University() |
---|
29 | >>> root['myuniversity'] = u |
---|
30 | >>> list(root) |
---|
31 | [u'myuniversity'] |
---|
32 | |
---|
33 | |
---|
34 | Let's get the default view of a university:: |
---|
35 | |
---|
36 | >>> browser.open('http://localhost/myuniversity') |
---|
37 | >>> print browser.contents |
---|
38 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
39 | ...Welcome to the... |
---|
40 | ... |
---|
41 | |
---|
42 | We can also get an edit view of a university:: |
---|
43 | |
---|
44 | >>> browser.open('http://localhost/myuniversity/manage') |
---|
45 | >>> print browser.contents |
---|
46 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
47 | ...<form action="http://localhost/myuniversity/manage" |
---|
48 | ... |
---|
49 | |
---|
50 | The edit form contains the default value for the university name:: |
---|
51 | |
---|
52 | >>> 'Sample University' in browser.contents |
---|
53 | True |
---|
54 | |
---|
55 | The edit form contains the default value for the portal skin:: |
---|
56 | |
---|
57 | >>> 'waeuptheme-gray1.css' in browser.contents |
---|
58 | True |
---|
59 | |
---|
60 | We can export a university as XML:: |
---|
61 | |
---|
62 | >>> browser.open('http://localhost/myuniversity/export.xml') |
---|
63 | >>> print browser.contents |
---|
64 | <?xml version="1.0" encoding="utf-8" ?> |
---|
65 | <pickle> |
---|
66 | ... |
---|
67 | </pickle> |
---|
68 | |
---|
69 | >>> print browser.headers |
---|
70 | Status: 200 Ok |
---|
71 | Content-Length: ... |
---|
72 | Content-Type: text/xml; charset=UTF-8 |
---|
73 | X-Powered-By: Zope (www.zope.org), Python (www.python.org) |
---|
74 | |
---|
75 | Contact Form |
---|
76 | ============ |
---|
77 | |
---|
78 | Let's enter the contact form:: |
---|
79 | |
---|
80 | >>> browser.open('http://localhost/myuniversity/contactadmin') |
---|
81 | >>> print browser.contents |
---|
82 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
83 | ...<h2>Contact</h2> |
---|
84 | ... |
---|
85 | |
---|
86 | We fill in a wrong email address:: |
---|
87 | |
---|
88 | >>> browser.getControl(name='email').value = "xx@yy" |
---|
89 | >>> browser.getControl(name='descr').value = "test message" |
---|
90 | >>> browser.getControl('Submit').click() |
---|
91 | >>> print browser.contents |
---|
92 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
93 | ...<li class="message">Error: xx@yy is not a valid email address.</li> |
---|
94 | ... |
---|
95 | |
---|
96 | Now we fill the form properly (this will send a real message to |
---|
97 | contact@waeup.org): |
---|
98 | |
---|
99 | >>> browser.open('http://localhost/myuniversity/contactadmin') |
---|
100 | >>> browser.getControl(name='email').value = "xx@yy.zz" |
---|
101 | >>> browser.getControl(name='descr').value = "test message" |
---|
102 | >>> browser.getControl('Submit').click() |
---|
103 | >>> print browser.contents |
---|
104 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
105 | ...<li class="message">Your message has been sent.</li> |
---|
106 | ... |
---|
107 | |
---|
108 | If this test fails, chances are, that the local machine has no SMTP |
---|
109 | server installed. |
---|
110 | |
---|
111 | Faculties |
---|
112 | ========= |
---|
113 | |
---|
114 | Faculties are stored in a special container of `IUniversity` |
---|
115 | instances. The container is called ``faculties`` and provides an |
---|
116 | add-form to add new faculties:: |
---|
117 | |
---|
118 | >>> browser.open('http://localhost/myuniversity/faculties/add') |
---|
119 | >>> print browser.contents |
---|
120 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
121 | ...<span class="required">*</span><span>Name of faculty</span>: |
---|
122 | ... |
---|
123 | |
---|
124 | We fill in a new name for our new faculty:: |
---|
125 | |
---|
126 | >>> ctrl = browser.getControl(name='form.title') |
---|
127 | >>> ctrl.value = 'TestFac' |
---|
128 | |
---|
129 | Furthermore we add a prefix and a code (kind of abbreviation): |
---|
130 | |
---|
131 | >>> browser.getControl(name='form.code').value = 'TF' |
---|
132 | |
---|
133 | Finally we click on 'Add Faculty' to add the new thing:: |
---|
134 | |
---|
135 | >>> browser.getControl('Add faculty').click() |
---|
136 | |
---|
137 | We can view a faculty by browsing a URL like this:: |
---|
138 | |
---|
139 | >>> browser.open('http://localhost/myuniversity/faculties/TF') |
---|
140 | |
---|
141 | Afterwards, the faculty should be visible: |
---|
142 | |
---|
143 | >>> browser.open('http://localhost/myuniversity/faculties') |
---|
144 | >>> print browser.contents |
---|
145 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
146 | ...<h2>Academic Section</h2> |
---|
147 | ...<td> <a href="TF"> <span>TF</span></a></td> |
---|
148 | ... |
---|
149 | |
---|
150 | We can 'visit' each faculty by clicking on the appropriate link: |
---|
151 | |
---|
152 | >>> browser.getLink('TF').click() |
---|
153 | >>> print browser.contents |
---|
154 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
155 | ...<h2>Faculty of TestFac (TF)</h2>... |
---|
156 | ... |
---|
157 | |
---|
158 | Modifying faculties |
---|
159 | ------------------- |
---|
160 | |
---|
161 | A faculty can directly be reached by its code: |
---|
162 | |
---|
163 | >>> browser.open('http://localhost/myuniversity/faculties/TF') |
---|
164 | |
---|
165 | We can change the settings for a faculty by clicking on the |
---|
166 | provided 'Manage faculty' button: |
---|
167 | |
---|
168 | >>> browser.getLink('Manage faculty').click() |
---|
169 | |
---|
170 | Let's set a new title and save the form: |
---|
171 | |
---|
172 | >>> browser.getControl(name='form.title').value = "My renamed faculty" |
---|
173 | >>> browser.getControl(name='form.actions.save').click() |
---|
174 | |
---|
175 | Our faculty was indeed renamed to ``My renamed faculty``: |
---|
176 | |
---|
177 | >>> browser.open('http://localhost/myuniversity/faculties') |
---|
178 | >>> print browser.contents |
---|
179 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
180 | ...<h2>Academic Section</h2> |
---|
181 | ...<td> <a href="TF"> <span>TF</span></a></td> |
---|
182 | ...<td>Faculty of My renamed faculty (TF)</td> |
---|
183 | ... |
---|
184 | |
---|
185 | |
---|
186 | Departments |
---|
187 | =========== |
---|
188 | |
---|
189 | Adding departments |
---|
190 | ------------------ |
---|
191 | |
---|
192 | Departments are stored in :class:`IFaculty` instances with their code |
---|
193 | as key. Faculties therefore are also department containers. Faculties |
---|
194 | provides an add-form to add new departments: |
---|
195 | |
---|
196 | >>> browser.open('http://localhost/myuniversity/faculties/TF/add') |
---|
197 | >>> print browser.contents |
---|
198 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
199 | ...<span class="required">*</span><span>Name of department</span>: |
---|
200 | ... |
---|
201 | |
---|
202 | We fill in a new name for our new department: |
---|
203 | |
---|
204 | >>> ctrl = browser.getControl(name='form.title') |
---|
205 | >>> ctrl.value = 'TestDept' |
---|
206 | |
---|
207 | Furthermore we add a code (kind of abbreviation): |
---|
208 | |
---|
209 | >>> browser.getControl(name='form.code').value = 'TD' |
---|
210 | |
---|
211 | Finally we click on 'Add Department' to add the new thing:: |
---|
212 | |
---|
213 | >>> browser.getControl('Add department').click() |
---|
214 | |
---|
215 | If we try to register a department under the same code twice we will |
---|
216 | get an error: |
---|
217 | |
---|
218 | >>> browser.open('http://localhost/myuniversity/faculties/TF/add') |
---|
219 | >>> ctrl = browser.getControl(name='form.title') |
---|
220 | >>> ctrl.value = 'Another TestDept with same code' |
---|
221 | >>> browser.getControl(name='form.code').value = 'TD' |
---|
222 | >>> browser.getControl('Add department').click() |
---|
223 | >>> print browser.contents |
---|
224 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
225 | ...<li class="message">The code chosen already exists in this faculty.</li> |
---|
226 | ... |
---|
227 | |
---|
228 | We can view a department by browsing a URL like this: |
---|
229 | |
---|
230 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') |
---|
231 | |
---|
232 | Afterwards, the department should be visible: |
---|
233 | |
---|
234 | >>> browser.open('http://localhost/myuniversity/faculties/TF') |
---|
235 | >>> print browser.contents |
---|
236 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
237 | ...<h2>Departments</h2> |
---|
238 | ...<td> <a href="TD"> <span>TD</span></a></td> |
---|
239 | ...<td>Department of TestDept (TD)</td> |
---|
240 | ... |
---|
241 | |
---|
242 | |
---|
243 | Modifying departments |
---|
244 | --------------------- |
---|
245 | |
---|
246 | We can change the settings for a department by clicking on the |
---|
247 | provided 'Edit department' button: |
---|
248 | |
---|
249 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') |
---|
250 | >>> browser.getLink('Manage department').click() |
---|
251 | |
---|
252 | Let's set a new title and save the form: |
---|
253 | |
---|
254 | >>> browser.getControl(name='form.title').value = "My test dept" |
---|
255 | >>> browser.getControl(name='form.actions.save').click() |
---|
256 | |
---|
257 | Clicking 'Save' we will stay on the settings form. So we can change |
---|
258 | the department again. |
---|
259 | |
---|
260 | >>> browser.getControl(name='form.title').value = "My renamed dept" |
---|
261 | >>> ctrl = browser.getControl("Save") |
---|
262 | >>> ctrl.click() |
---|
263 | |
---|
264 | |
---|
265 | Our department was indeed renamed to ``My renamed dept``: |
---|
266 | |
---|
267 | >>> browser.open('http://localhost/myuniversity/faculties/TF') |
---|
268 | >>> print browser.contents |
---|
269 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
270 | ...<h2>Departments</h2> |
---|
271 | ...<td> <a href="TD"> <span>TD</span></a></td> |
---|
272 | ...<td>Department of My renamed dept (TD)</td> |
---|
273 | ... |
---|
274 | |
---|
275 | |
---|
276 | Courses |
---|
277 | ======= |
---|
278 | |
---|
279 | Once we have a department, we can add courses. |
---|
280 | |
---|
281 | Adding courses |
---|
282 | -------------- |
---|
283 | |
---|
284 | Courses are stored in :class:`ICourseContainer` instances with their |
---|
285 | code as key. CourseContainers are normally availabe as `course` |
---|
286 | attribute of :class:`waeup.sirp.university.department.Department` |
---|
287 | instances. |
---|
288 | |
---|
289 | To ease the life of users we do not require to browse the |
---|
290 | coursecontainers (which have a rather flat user interface), but |
---|
291 | provide adding of courses in department views. |
---|
292 | |
---|
293 | Each department provides a ``Add course`` action button near top. |
---|
294 | |
---|
295 | Departments provide an add-form to add new courses: |
---|
296 | |
---|
297 | >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD' |
---|
298 | >>> browser.open(dept_url + '/addcourse') |
---|
299 | >>> print browser.contents |
---|
300 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
301 | ...<span class="required">*</span><span>Title of course</span>: |
---|
302 | ... |
---|
303 | |
---|
304 | We fill in a name for our new course: |
---|
305 | |
---|
306 | >>> ctrl = browser.getControl(name='form.title') |
---|
307 | >>> ctrl.value = 'My Course 1' |
---|
308 | |
---|
309 | Furthermore we add a code (kind of abbreviation): |
---|
310 | |
---|
311 | >>> browser.getControl(name='form.code').value = 'COURSE1' |
---|
312 | |
---|
313 | This course will take place in the the first semester, so we set the |
---|
314 | `semester` value to 1: |
---|
315 | |
---|
316 | >>> ctrl = browser.getControl(name='form.semester') |
---|
317 | >>> ctrl.options |
---|
318 | ['0', '1', '2', '3'] |
---|
319 | |
---|
320 | >>> ctrl.displayOptions |
---|
321 | ['N/A', 'First Semester', 'Second Semester', 'Combined'] |
---|
322 | |
---|
323 | >>> ctrl.value = ['1'] |
---|
324 | |
---|
325 | Finally, we create the course: |
---|
326 | |
---|
327 | >>> browser.getControl('Add course').click() |
---|
328 | |
---|
329 | If we try to register a course under the same code twice we will |
---|
330 | get an error: |
---|
331 | |
---|
332 | >>> browser.open(dept_url + '/addcourse') |
---|
333 | >>> ctrl = browser.getControl(name='form.title') |
---|
334 | >>> ctrl.value = 'Another course with same code' |
---|
335 | >>> browser.getControl(name='form.code').value = 'COURSE1' |
---|
336 | >>> browser.getControl('Add course').click() |
---|
337 | >>> print browser.contents |
---|
338 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
339 | ...<li class="message">A course with same code already exists:...</li> |
---|
340 | ... |
---|
341 | |
---|
342 | Our course will be linked under the code on the department page: |
---|
343 | |
---|
344 | >>> browser.open(dept_url) |
---|
345 | >>> browser.getLink('COURSE1').click() |
---|
346 | >>> browser.url |
---|
347 | 'http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1' |
---|
348 | |
---|
349 | Before we really add a course we can cancel the action and will be |
---|
350 | redirected to the department page: |
---|
351 | |
---|
352 | >>> browser.open(dept_url + '/addcourse') |
---|
353 | >>> browser.getControl('Cancel').click() |
---|
354 | >>> browser.url |
---|
355 | 'http://localhost/myuniversity/faculties/TF/TD' |
---|
356 | |
---|
357 | |
---|
358 | Modifying courses |
---|
359 | ----------------- |
---|
360 | |
---|
361 | We can change the settings for a course by clicking on the provided |
---|
362 | 'Edit settings' link: |
---|
363 | |
---|
364 | >>> browser.open(dept_url + '/courses/COURSE1') |
---|
365 | >>> browser.getLink('Edit course').click() |
---|
366 | |
---|
367 | When modifying a course, we cannot change the code any more: |
---|
368 | |
---|
369 | >>> browser.getControl(name='form.code') |
---|
370 | Traceback (most recent call last): |
---|
371 | ... |
---|
372 | LookupError: name 'form.code' |
---|
373 | |
---|
374 | Let's set a new title and save the form: |
---|
375 | |
---|
376 | >>> browser.getControl(name='form.title').value = "My test course" |
---|
377 | >>> browser.getControl(name='form.actions.save').click() |
---|
378 | |
---|
379 | Clicking 'Save' we will stay on the settings form. So we can change |
---|
380 | the course again. This time we will return to the overview page |
---|
381 | afterwards: |
---|
382 | |
---|
383 | >>> browser.getControl(name='form.title').value = "My renamed course" |
---|
384 | >>> ctrl = browser.getControl("Save and return") |
---|
385 | >>> ctrl.click() |
---|
386 | |
---|
387 | If we go to the settings page and click ``Cancel`` nothing will be |
---|
388 | changed: |
---|
389 | |
---|
390 | >>> browser.getLink('Edit course').click() |
---|
391 | >>> browser.getControl(name='form.title').value = "Blah" |
---|
392 | >>> browser.getControl('Cancel').click() |
---|
393 | |
---|
394 | Our course was indeed renamed to ``My renamed course`` and not to |
---|
395 | ``Blah``: |
---|
396 | |
---|
397 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') |
---|
398 | >>> print browser.contents |
---|
399 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
400 | ...<td>My renamed course</td>... |
---|
401 | ... |
---|
402 | |
---|
403 | |
---|
404 | Deleting courses |
---|
405 | ---------------- |
---|
406 | |
---|
407 | We can delete courses by browsing the manage page of the containing department and |
---|
408 | checking the appropriate select box and clicking the ´´Remove selected´´ button. |
---|
409 | |
---|
410 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2') |
---|
411 | >>> 'My renamed course' in browser.contents |
---|
412 | True |
---|
413 | |
---|
414 | >>> browser.getControl(name='val_id').getControl(value='COURSE1').selected = True |
---|
415 | >>> browser.getControl('Remove selected courses').click() |
---|
416 | |
---|
417 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') |
---|
418 | >>> 'My renamed course' in browser.contents |
---|
419 | False |
---|
420 | |
---|
421 | |
---|
422 | Certificates |
---|
423 | ============ |
---|
424 | |
---|
425 | Once we have a department, we can add also certificats. |
---|
426 | |
---|
427 | Adding certificates |
---|
428 | ------------------- |
---|
429 | |
---|
430 | Certificates are stored in :class:`ICertificateContainer` instances |
---|
431 | with their code as key. CertificateContainers are normally availabe as |
---|
432 | `certificates` attribute of |
---|
433 | :class:`waeup.sirp.university.department.Department` instances. |
---|
434 | |
---|
435 | To ease the life of users we do not require to browse the |
---|
436 | certificatecontainers (which have in fact no user interface), but |
---|
437 | provide adding of certificates in department views. |
---|
438 | |
---|
439 | Each department provides a ``Add certificate`` action button near top. |
---|
440 | |
---|
441 | Departments provide an add-form to add new certificates: |
---|
442 | |
---|
443 | >>> dept_url = 'http://localhost/myuniversity/faculties/TF/TD' |
---|
444 | >>> browser.open(dept_url + '/addcertificate') |
---|
445 | >>> print browser.contents |
---|
446 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
447 | ...<span class="required">*</span><span>Title</span>: |
---|
448 | ... |
---|
449 | |
---|
450 | We fill in a name for our new cert: |
---|
451 | |
---|
452 | >>> ctrl = browser.getControl(name='form.title') |
---|
453 | >>> ctrl.value = 'My Certificate 1' |
---|
454 | |
---|
455 | Furthermore we add a code (kind of abbreviation): |
---|
456 | |
---|
457 | >>> browser.getControl(name='form.code').value = 'CERT1' |
---|
458 | |
---|
459 | Set the remaining required fields: |
---|
460 | |
---|
461 | >>> browser.getControl(name='form.study_mode').value = ['ume_ft'] |
---|
462 | >>> browser.getControl(name='form.start_level').value = ['100'] |
---|
463 | >>> browser.getControl(name='form.end_level').value = ['400'] |
---|
464 | >>> browser.getControl(name='form.application_category').value = ['basic'] |
---|
465 | |
---|
466 | Finally, we create the certificate: |
---|
467 | |
---|
468 | >>> browser.getControl('Add certificate').click() |
---|
469 | |
---|
470 | If we try to register a certificate under the same code twice we will |
---|
471 | get an error: |
---|
472 | |
---|
473 | >>> browser.open(dept_url + '/addcertificate') |
---|
474 | >>> ctrl = browser.getControl(name='form.title') |
---|
475 | >>> ctrl.value = 'Another cert with same code' |
---|
476 | >>> browser.getControl(name='form.code').value = 'CERT1' |
---|
477 | >>> browser.getControl(name='form.study_mode').value = ['ume_ft'] |
---|
478 | >>> browser.getControl(name='form.start_level').value = ['100'] |
---|
479 | >>> browser.getControl(name='form.end_level').value = ['400'] |
---|
480 | >>> browser.getControl(name='form.application_category').value = ['basic'] |
---|
481 | |
---|
482 | >>> browser.getControl('Add certificate').click() |
---|
483 | >>> print browser.contents |
---|
484 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
485 | ...<li class="message">A certificate with same code already exists:...</li> |
---|
486 | ... |
---|
487 | |
---|
488 | Our certificate will be linked under the code on the department page: |
---|
489 | |
---|
490 | >>> browser.open(dept_url) |
---|
491 | >>> browser.getLink('CERT1').click() |
---|
492 | >>> browser.url |
---|
493 | 'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1' |
---|
494 | |
---|
495 | Before we really add a certificate we can cancel the action and will be |
---|
496 | redirected to the department page: |
---|
497 | |
---|
498 | >>> browser.open(dept_url + '/addcertificate') |
---|
499 | >>> browser.getControl('Cancel').click() |
---|
500 | >>> browser.url |
---|
501 | 'http://localhost/myuniversity/faculties/TF/TD' |
---|
502 | |
---|
503 | |
---|
504 | Modifying certificates |
---|
505 | ---------------------- |
---|
506 | |
---|
507 | We can change the settings for a cert by clicking on the provided |
---|
508 | 'Edit certificate' link: |
---|
509 | |
---|
510 | >>> browser.open(dept_url + '/certificates/CERT1') |
---|
511 | >>> browser.getLink('Manage certificate').click() |
---|
512 | |
---|
513 | When modifying a certificate, we cannot change the code any more: |
---|
514 | |
---|
515 | >>> browser.getControl(name='form.code') |
---|
516 | Traceback (most recent call last): |
---|
517 | ... |
---|
518 | LookupError: name 'form.code' |
---|
519 | |
---|
520 | Let's set a new title and save the form: |
---|
521 | |
---|
522 | >>> browser.getControl(name='form.title').value = "My test cert" |
---|
523 | >>> browser.getControl(name='form.actions.save').click() |
---|
524 | |
---|
525 | Clicking 'Save' we will stay on the settings form. So we can change |
---|
526 | the cert again. |
---|
527 | |
---|
528 | >>> browser.getControl(name='form.title').value = "My renamed cert" |
---|
529 | >>> ctrl = browser.getControl("Save",index=0) |
---|
530 | >>> ctrl.click() |
---|
531 | |
---|
532 | If we go to the settings page and click ``Cancel`` nothing will be |
---|
533 | changed: |
---|
534 | |
---|
535 | >>> browser.getControl(name='form.title').value = "Blah" |
---|
536 | >>> browser.getControl('Cancel',index=0).click() |
---|
537 | |
---|
538 | Our certificate was indeed renamed to ``My renamed cert`` and not to |
---|
539 | ``Blah``: |
---|
540 | |
---|
541 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') |
---|
542 | >>> print browser.contents |
---|
543 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
544 | ...<td>My renamed cert</td>... |
---|
545 | ... |
---|
546 | |
---|
547 | |
---|
548 | Deleting certificates |
---|
549 | --------------------- |
---|
550 | |
---|
551 | We can delete certificates by browsing the manage page of the containing department and |
---|
552 | checking the appropriate select box and clicking the ´´Remove selected´´ button. |
---|
553 | |
---|
554 | >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3') |
---|
555 | >>> 'My renamed cert' in browser.contents |
---|
556 | True |
---|
557 | |
---|
558 | >>> browser.getControl(name='val_id').getControl(value='CERT1').selected = True |
---|
559 | >>> browser.getControl('Remove selected certificates').click() |
---|
560 | >>> 'My renamed cert' in browser.contents |
---|
561 | False |
---|
562 | |
---|
563 | |
---|
564 | CertificateCourses |
---|
565 | ================== |
---|
566 | |
---|
567 | Once we have a certificate, we can add also certificate courses. These |
---|
568 | are referrers of courses with some extra data. |
---|
569 | |
---|
570 | Before we can work with certificate courses, we need some certificates |
---|
571 | and courses to be available. |
---|
572 | |
---|
573 | >>> browser.open(dept_url + '/addcourse') |
---|
574 | >>> ctrl = browser.getControl(name='form.title') |
---|
575 | >>> ctrl.value = 'Another course with same code' |
---|
576 | >>> browser.getControl(name='form.code').value = 'COURSE1' |
---|
577 | >>> browser.getControl(name='form.title').value = 'Course 1' |
---|
578 | >>> browser.getControl('Add course').click() |
---|
579 | |
---|
580 | >>> browser.open(dept_url + '/addcourse') |
---|
581 | >>> ctrl = browser.getControl(name='form.title') |
---|
582 | >>> ctrl.value = 'Another course with same code' |
---|
583 | >>> browser.getControl(name='form.code').value = 'COURSE2' |
---|
584 | >>> browser.getControl(name='form.title').value = 'Course 2' |
---|
585 | >>> browser.getControl('Add course').click() |
---|
586 | |
---|
587 | >>> browser.open(dept_url + '/addcertificate') |
---|
588 | >>> ctrl = browser.getControl(name='form.title') |
---|
589 | >>> ctrl.value = 'Another cert with same code' |
---|
590 | >>> browser.getControl(name='form.code').value = 'CERT1' |
---|
591 | >>> browser.getControl(name='form.title').value = 'Certificate 1' |
---|
592 | >>> browser.getControl(name='form.study_mode').value = ['ume_ft'] |
---|
593 | >>> browser.getControl(name='form.start_level').value = ['100'] |
---|
594 | >>> browser.getControl(name='form.end_level').value = ['400'] |
---|
595 | >>> browser.getControl(name='form.application_category').value = ['basic'] |
---|
596 | >>> browser.getControl('Add certificate').click() |
---|
597 | |
---|
598 | >>> browser.open(dept_url + '/addcertificate') |
---|
599 | >>> ctrl = browser.getControl(name='form.title') |
---|
600 | >>> ctrl.value = 'Another cert with same code' |
---|
601 | >>> browser.getControl(name='form.code').value = 'CERT2' |
---|
602 | >>> browser.getControl(name='form.title').value = 'Certificate 2' |
---|
603 | >>> browser.getControl(name='form.study_mode').value = ['ume_ft'] |
---|
604 | >>> browser.getControl(name='form.start_level').value = ['100'] |
---|
605 | >>> browser.getControl(name='form.end_level').value = ['400'] |
---|
606 | >>> browser.getControl(name='form.application_category').value = ['basic'] |
---|
607 | >>> browser.getControl('Add certificate').click() |
---|
608 | |
---|
609 | |
---|
610 | Adding certificatecourses |
---|
611 | ------------------------- |
---|
612 | |
---|
613 | Certcourses are stored in :class:`ICertificate` instances |
---|
614 | with their code as key. |
---|
615 | |
---|
616 | Each certificate provides a ``Add course referrer`` action button near top. |
---|
617 | |
---|
618 | Certificates provide an add-form to add new certcourses: |
---|
619 | |
---|
620 | >>> cert_url = dept_url + '/certificates/CERT1' |
---|
621 | >>> browser.open(cert_url + '/addcertificatecourse') |
---|
622 | >>> print browser.contents |
---|
623 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... |
---|
624 | ...<span class="required">*</span><span>Level</span>: |
---|
625 | ... |
---|
626 | |
---|
627 | In the add-form we will get a list of available courses to select |
---|
628 | from. This list will contain all courses stored in the site, not only |
---|
629 | the ones from local department: |
---|
630 | |
---|
631 | >>> ctrl = browser.getControl(name='form.course') |
---|
632 | >>> ctrl.displayOptions |
---|
633 | ['(no value)', 'COURSE1 - Course 1', 'COURSE2 - Course 2'] |
---|
634 | |
---|
635 | We select the first course and create our certificatecourse: |
---|
636 | |
---|
637 | >>> ctrl.getControl('COURSE1').selected = True |
---|
638 | >>> browser.getControl(name='form.level').value = ['100'] |
---|
639 | >>> browser.getControl('Add course referrer').click() |
---|
640 | |
---|
641 | Our certificatecourse will be linked on the parent certificate page: |
---|
642 | |
---|
643 | >>> browser.open(cert_url) |
---|
644 | >>> browser.getLink('COURSE1_100').click() |
---|
645 | >>> browser.url |
---|
646 | 'http://localhost/my...sity/faculties/TF/TD/certificates/CERT1/COURSE1_100' |
---|
647 | |
---|
648 | When we started to add a new certificatecourse, we can also cancel the |
---|
649 | process before submitting. This will bring us back to the certificate |
---|
650 | page: |
---|
651 | |
---|
652 | >>> browser.open(cert_url + '/addcertificatecourse') |
---|
653 | >>> browser.getControl('Cancel').click() |
---|
654 | >>> browser.url |
---|
655 | 'http://localhost/myuniversity/faculties/TF/TD/certificates/CERT1' |
---|
656 | |
---|
657 | |
---|
658 | Modifying certificatecourses |
---|
659 | ---------------------------- |
---|
660 | |
---|
661 | We can change the settings for a certcourse by clicking on the |
---|
662 | provided 'Edit certificate course' link: |
---|
663 | |
---|
664 | >>> browser.open(cert_url + '/COURSE1_100') |
---|
665 | >>> browser.getLink('Edit course referrer').click() |
---|
666 | |
---|
667 | Let's set a new level (it was 100 before) and save the form. This will |
---|
668 | bring us to the certificate index page afterwards: |
---|
669 | |
---|
670 | >>> browser.getControl(name='form.level').value = ['200'] |
---|
671 | >>> ctrl = browser.getControl("Save and return") |
---|
672 | >>> ctrl.click() |
---|
673 | |
---|
674 | As we changed the level, also the URL will change: |
---|
675 | |
---|
676 | >>> browser.getLink('COURSE1_200').click() |
---|
677 | >>> browser.url |
---|
678 | 'http://localhost/myun.../TF/TD/certificates/CERT1/COURSE1_200' |
---|
679 | |
---|
680 | If we go to the settings page and click ``Cancel`` nothing will be |
---|
681 | changed: |
---|
682 | |
---|
683 | >>> browser.getLink('Edit course referrer').click() |
---|
684 | >>> browser.getControl(name='form.level').value = ['400'] |
---|
685 | >>> browser.getControl('Cancel').click() |
---|
686 | |
---|
687 | Our certcourse provides a new level of 200 and not 400: |
---|
688 | |
---|
689 | >>> browser.open(cert_url + '/COURSE1_200') |
---|
690 | >>> print browser.contents |
---|
691 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
692 | ...<td>Level:</td> |
---|
693 | ...<td>200 (Year 2)</td> |
---|
694 | ... |
---|
695 | |
---|
696 | |
---|
697 | Deleting certificatecourses |
---|
698 | --------------------------- |
---|
699 | |
---|
700 | We can delete certcourses by browsing the containing certificate manage page: |
---|
701 | |
---|
702 | >>> browser.open(cert_url + '/manage#tab-2') |
---|
703 | >>> 'COURSE1_200</a>' in browser.contents |
---|
704 | True |
---|
705 | |
---|
706 | >>> browser.getControl(name='val_id').getControl(value='COURSE1_200').selected = True |
---|
707 | >>> browser.getControl('Remove selected course referrers').click() |
---|
708 | >>> 'Successfully removed: COURSE1_200' in browser.contents |
---|
709 | True |
---|
710 | |
---|
711 | >>> 'COURSE1_200</a>' in browser.contents |
---|
712 | False |
---|
713 | |
---|
714 | |
---|
715 | |
---|
716 | Data Center |
---|
717 | =========== |
---|
718 | |
---|
719 | The data center helps us uploading files for later import or similar. |
---|
720 | |
---|
721 | >>> browser.open('http://localhost/myuniversity') |
---|
722 | >>> browser.getLink('Data Center').click() |
---|
723 | |
---|
724 | Setting the file path |
---|
725 | --------------------- |
---|
726 | |
---|
727 | A datacenter stores files in a path in filesystem. By default this is |
---|
728 | a directory in the sources: |
---|
729 | |
---|
730 | >>> print browser.contents |
---|
731 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
732 | ... |
---|
733 | <b>Storage path:</b> <span>/.../waeup/sirp/files</span> |
---|
734 | ... |
---|
735 | |
---|
736 | Going to 'Settings` we can change the path: |
---|
737 | |
---|
738 | >>> browser.getLink('Edit settings').click() |
---|
739 | >>> pathsetting = browser.getControl(name='newpath') |
---|
740 | |
---|
741 | We create a directory and set it as our upload path: |
---|
742 | |
---|
743 | >>> import os |
---|
744 | >>> cwd = os.getcwd() |
---|
745 | >>> uploadpath = os.path.join(cwd, 'testfiles') |
---|
746 | >>> os.mkdir(uploadpath) |
---|
747 | >>> pathsetting.value = uploadpath |
---|
748 | |
---|
749 | And submit the form: |
---|
750 | |
---|
751 | >>> browser.getControl(name='save').click() |
---|
752 | |
---|
753 | We clean up the set directory path, as there might be some files be |
---|
754 | copied some files from installation: |
---|
755 | |
---|
756 | >>> files = os.listdir(uploadpath) |
---|
757 | >>> for filename in files: |
---|
758 | ... if os.path.isdir(os.path.join(uploadpath, filename)): |
---|
759 | ... continue |
---|
760 | ... os.unlink(os.path.join(uploadpath, filename)) |
---|
761 | |
---|
762 | We also remove any existing 'accesscodes' subdir: |
---|
763 | |
---|
764 | >>> import shutil |
---|
765 | >>> for filename in files: |
---|
766 | ... if not os.path.isdir(os.path.join(uploadpath, filename)): |
---|
767 | ... continue |
---|
768 | ... if filename != 'accesscodes': |
---|
769 | ... continue |
---|
770 | ... shutil.rmtree(os.path.join(uploadpath, filename)) |
---|
771 | |
---|
772 | The new upload directory is now empty, except from the logs and other |
---|
773 | standard dirs, which are created automatically: |
---|
774 | |
---|
775 | >>> sorted(os.listdir(uploadpath)) |
---|
776 | ['finished', 'jambdata', 'logs', 'unfinished'] |
---|
777 | |
---|
778 | |
---|
779 | Uploading files |
---|
780 | --------------- |
---|
781 | |
---|
782 | Now we can upload files. Most interesting files might be CSV files, |
---|
783 | that can be imported lateron. We create a CSV file containing faculty |
---|
784 | descriptions: |
---|
785 | |
---|
786 | >>> open('faculties.csv', 'wb').write( |
---|
787 | ... """code,title,title_prefix |
---|
788 | ... FA,Arts,faculty |
---|
789 | ... FS,Sciences,faculty |
---|
790 | ... """) |
---|
791 | |
---|
792 | Now we can upload this file. To do this, we first go to the upload |
---|
793 | page: |
---|
794 | |
---|
795 | >>> browser.getLink('Upload CSV file').click() |
---|
796 | |
---|
797 | and enter the appropriate data in the form: |
---|
798 | |
---|
799 | >>> filewidget = browser.getControl(name='uploadfile:file') |
---|
800 | >>> filewidget |
---|
801 | <Control name='uploadfile:file' type='file'> |
---|
802 | |
---|
803 | A sidenote for developers: by marking the filewidget with the |
---|
804 | ``:file`` extension, we tell Zope to handle this field as a file |
---|
805 | widget. |
---|
806 | |
---|
807 | >>> import cStringIO |
---|
808 | >>> filecontents = cStringIO.StringIO( |
---|
809 | ... open('faculties.csv', 'rb').read()) |
---|
810 | >>> filewidget.add_file(filecontents, 'text/plain', 'myfaculties.csv') |
---|
811 | |
---|
812 | >>> browser.getControl(name='SUBMIT').click() |
---|
813 | |
---|
814 | The file was indeed uploaded, with the current userid inserted: |
---|
815 | |
---|
816 | >>> sorted(os.listdir(uploadpath)) |
---|
817 | ['finished', 'jambdata', 'logs', 'myfaculties_zope.mgr.csv', 'unfinished'] |
---|
818 | |
---|
819 | We create and upload also a CSV file containing departments: |
---|
820 | |
---|
821 | >>> open('departments.csv', 'wb').write( |
---|
822 | ... """code,title,title_prefix,faculty_code |
---|
823 | ... LIT,Literature,department,FA |
---|
824 | ... SOC,Sociology,department,FA |
---|
825 | ... PHY,Physics,department,FS |
---|
826 | ... INF,Informatics,department,FS |
---|
827 | ... MAT,Math,department,FS |
---|
828 | ... """) |
---|
829 | |
---|
830 | >>> browser.open('http://localhost/myuniversity/datacenter/upload') |
---|
831 | >>> browser.getControl(name='uploadfile:file').add_file( |
---|
832 | ... cStringIO.StringIO(open('departments.csv', 'rb').read()), |
---|
833 | ... 'text/plain', 'mydepartments.csv') |
---|
834 | >>> browser.getControl(name='SUBMIT').click() |
---|
835 | |
---|
836 | We create and upload also a CSV file containing courses: |
---|
837 | |
---|
838 | >>> open('courses.csv', 'wb').write( |
---|
839 | ... """code,level,title,passmark,credits,semester,faculty,department |
---|
840 | ... LI1,,Introduction to Literature I,40,2,1,FA,LIT |
---|
841 | ... LI2,,Introduction to Literature II,40,2,2,FA,LIT |
---|
842 | ... AN1,000,Analysis I,40,2,1,FS,MAT |
---|
843 | ... AN2,000,Analysis II,40,2,2,FS,MAT |
---|
844 | ... """) |
---|
845 | |
---|
846 | >>> browser.open('http://localhost/myuniversity/datacenter/upload') |
---|
847 | >>> browser.getControl(name='uploadfile:file').add_file( |
---|
848 | ... cStringIO.StringIO(open('courses.csv', 'rb').read()), |
---|
849 | ... 'text/plain', 'mycourses.csv') |
---|
850 | >>> browser.getControl(name='SUBMIT').click() |
---|
851 | |
---|
852 | We create and upload also a CSV file containing certificates: |
---|
853 | |
---|
854 | >>> open('certificates.csv', 'wb').write( |
---|
855 | ... """code,title,faculty_code,department_code,study_mode,end_level,m_prefix,start_level,application_category |
---|
856 | ... LBA,BACHELOR OF LITERATURE,FA,LIT,UG,ug_ft,500,LIT,100,basic |
---|
857 | ... LMA,MASTER OF LITERATURE,FA,LIT,UG,ug_pt,500,LIT,100,cest |
---|
858 | ... DME,DIPLOMA OF MATH,FS,MAT,DP,dp_ft,200,DME,100,cest |
---|
859 | ... """) |
---|
860 | |
---|
861 | >>> browser.open('http://localhost/myuniversity/datacenter/upload') |
---|
862 | >>> browser.getControl(name='uploadfile:file').add_file( |
---|
863 | ... cStringIO.StringIO(open('certificates.csv', 'rb').read()), |
---|
864 | ... 'text/plain', 'mycertificates.csv') |
---|
865 | >>> browser.getControl(name='SUBMIT').click() |
---|
866 | |
---|
867 | We create and upload also a CSV file containing certificate courses: |
---|
868 | |
---|
869 | >>> open('certcourses.csv', 'wb').write( |
---|
870 | ... """code,faculty_code,department_code,certificate_code,level,core_or_elective |
---|
871 | ... LI1,FA,LIT,LBA,100,True |
---|
872 | ... LI2,FA,LIT,LBA,200,True |
---|
873 | ... """) |
---|
874 | |
---|
875 | >>> browser.open('http://localhost/myuniversity/datacenter/upload') |
---|
876 | >>> browser.getControl(name='uploadfile:file').add_file( |
---|
877 | ... cStringIO.StringIO(open('certcourses.csv', 'rb').read()), |
---|
878 | ... 'text/plain', 'mycertcourses.csv') |
---|
879 | >>> browser.getControl(name='SUBMIT').click() |
---|
880 | |
---|
881 | |
---|
882 | Importing a CSV file |
---|
883 | -------------------- |
---|
884 | |
---|
885 | The import of CSV files is described in batchprocessing.txt. |
---|
886 | |
---|
887 | |
---|
888 | Clean up: |
---|
889 | |
---|
890 | >>> import os |
---|
891 | >>> import shutil |
---|
892 | >>> shutil.rmtree(uploadpath) |
---|