Changeset 4720
- Timestamp:
- 8 Jan 2010, 01:05:01 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4717 r4720 2 2 """ Viewing components for WAeUP objects. 3 3 """ 4 import copy 4 5 import grok 5 6 import os … … 13 14 from waeup.interfaces import (IUniversity, IWAeUPObject, IUserContainer, 14 15 IUserAccount, IFacultyContainer, IDataCenter, 15 IFaculty, IDepartment )16 IFaculty, IDepartment, ICourse, ICertificate) 16 17 from waeup.widgets.interfaces import ITableProvider 17 18 from waeup.utils.helpers import getName … … 491 492 # 492 493 class DepartmentPage(WAeUPPage): 494 """Department index page. 495 """ 493 496 grok.context(IDepartment) 494 497 grok.require('waeup.View') … … 513 516 self.certificatetable = self.tables[1] 514 517 self.coursetable.need() 518 519 class DepartmentManageFormPage(WAeUPEditFormPage): 520 """Manage the basic properties of a `Department` instance. 521 """ 522 grok.context(IDepartment) 523 grok.name('manage') 524 grok.require('waeup.manageUniversity') 525 title = u'Edit department settings' 526 pnav = 1 527 528 form_fields = grok.AutoFields(IDepartment) 529 530 @grok.action('Save') 531 def save(self, **data): 532 self.applyData(self.context, **data) 533 return 534 535 @grok.action('Save and return') 536 def saveAndReturn(self, **data): 537 self.applyData(self.context, **data) 538 self.redirect(self.url(self.context)) 539 return 540 541 @grok.action('Cancel') 542 def cancel(self, **data): 543 self.redirect(self.url(self.context)) 544 return 545 546 class DepartmentAddCourseFormPage(WAeUPAddFormPage): 547 """Add-form to add course to a department. 548 """ 549 grok.context(IDepartment) 550 grok.name('addcourse') 551 grok.require('waeup.manageUniversity') 552 title = u'Add course' 553 pnav = 1 554 555 # We need a deepcopy here, because otherwise also all other 556 # ICourse forms would be affected. 557 form_fields = copy.deepcopy(grok.AutoFields(ICourse)) 558 form_fields.get('code').field.readonly = False 559 560 @grok.action('Add course') 561 def addCourse(self, **data): 562 course = createObject(u'waeup.Course') 563 self.applyData(course, **data) 564 try: 565 self.context.courses.addCourse(course) 566 except DuplicationError: 567 self.status = Invalid('The code chosen already exists ' 568 'in the database') 569 return 570 self.redirect(self.url(self.context)) 571 572 @grok.action('Cancel') 573 def cancel(self, **data): 574 self.redirect(self.url(self.context)) 575 return 576 577 class DepartmentAddCertificateFormPage(WAeUPAddFormPage): 578 """Add-form to add certificate to a department. 579 """ 580 grok.context(IDepartment) 581 grok.name('addcertificate') 582 grok.require('waeup.manageUniversity') 583 title = u'Add certificate' 584 pnav = 1 585 586 # We need a deepcopy here, because otherwise also all other 587 # ICertificate forms would be affected. 588 form_fields = copy.deepcopy(grok.AutoFields(ICertificate)) 589 form_fields.get('code').field.readonly = False 590 591 @grok.action('Add certificate') 592 def addCertificate(self, **data): 593 certificate = createObject(u'waeup.Certificate') 594 self.applyData(certificate, **data) 595 try: 596 self.context.certificates.addCertificate(certificate) 597 except DuplicationError: 598 self.status = Invalid('The name chosen already exists ' 599 'in the database') 600 return 601 self.redirect(self.url(self.context)) 602 603 @grok.action('Cancel') 604 def cancel(self, **data): 605 self.redirect(self.url(self.context)) 606 return
Note: See TracChangeset for help on using the changeset viewer.