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