Changeset 6005 for main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
- Timestamp:
- 1 May 2011, 20:28:08 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6004 r6005 858 858 # except: 859 859 # self.flash('Could not delete %s.' % code) 860 861 862 class FacultyContainerManageFormPage(WAeUPEditFormPage): 863 """Manage the basic properties of a `Faculty` instance. 864 """ 865 grok.context(IFacultyContainer) 866 grok.name('manage') 867 grok.require('waeup.manageUniversity') 868 grok.template('facultycontainermanagepage') 869 pnav = 1 870 taboneactions = ['Add faculty', 'Remove selected','Cancel'] 871 subunits = 'Faculties' 872 title = 'Academics' 873 874 @property 875 def label(self): 876 return 'Manage academic section' 877 878 def update(self): 879 tabs.need() 880 #warning.need() 881 return super(FacultyContainerManageFormPage, self).update() 882 883 # ToDo: Show warning message before deletion 884 @grok.action('Remove selected') 885 def delFaculties(self, **data): 886 form = self.request.form 887 child_id = form['val_id'] 888 if not isinstance(child_id, list): 889 child_id = [child_id] 890 deleted = [] 891 for id in child_id: 892 try: 893 del self.context[id] 894 deleted.append(id) 895 except: 896 self.flash('Could not delete %s: %s: %s' % ( 897 id, sys.exc_info()[0], sys.exc_info()[1])) 898 if len(deleted): 899 self.flash('Successfully removed: %s' % ', '.join(deleted)) 900 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 901 return 902 903 @grok.action('Add faculty', validator=NullValidator) 904 def addFaculty(self, **data): 905 self.redirect(self.url(self.context, '@@add')) 906 return 907 908 @grok.action('Cancel', validator=NullValidator) 909 def cancel(self, **data): 910 self.redirect(self.url(self.context)) 911 return 912 860 913 861 914 class FacultyAddFormPage(WAeUPAddFormPage): … … 924 977 # except: 925 978 # self.flash('Could not delete %s.' % code) 926 927 class DepartmentAddFormPage(WAeUPAddFormPage):928 """Add a department to a faculty.929 """930 grok.context(IFaculty)931 grok.name('add')932 grok.require('waeup.manageUniversity')933 label = 'Add department'934 form_fields = grok.AutoFields(IDepartmentAdd)935 pnav = 1936 937 @property938 def title(self):939 return self.context.longtitle()940 941 @grok.action('Add department')942 def addDepartment(self, **data):943 department = createObject(u'waeup.Department')944 self.applyData(department, **data)945 try:946 self.context.addDepartment(department)947 except KeyError:948 self.status = Invalid('The code chosen already exists '949 'in the database')950 return951 except DuplicationError:952 self.status = Invalid('The code chosen already exists '953 'in the database')954 return955 self.redirect(self.url(self.context, u'@@manage')+'#tab-2')956 957 @grok.action('Cancel')958 def cancel(self, **data):959 self.redirect(self.url(self.context))960 979 961 980 class FacultyManageFormPage(WAeUPEditFormPage): … … 1021 1040 return 1022 1041 1023 class FacultyContainerManageFormPage(WAeUPEditFormPage): 1024 """Manage the basic properties of a `Faculty` instance. 1025 """ 1026 grok.context(IFacultyContainer) 1027 grok.name('manage') 1028 grok.require('waeup.manageUniversity') 1029 grok.template('facultycontainermanagepage') 1030 pnav = 1 1031 taboneactions = ['Add faculty', 'Remove selected','Cancel'] 1032 subunits = 'Faculties' 1033 title = 'Academics' 1034 1035 @property 1036 def label(self): 1037 return 'Manage academic section' 1038 1039 def update(self): 1040 tabs.need() 1041 #warning.need() 1042 return super(FacultyContainerManageFormPage, self).update() 1043 1044 # ToDo: Show warning message before deletion 1045 @grok.action('Remove selected') 1046 def delFaculties(self, **data): 1047 form = self.request.form 1048 child_id = form['val_id'] 1049 if not isinstance(child_id, list): 1050 child_id = [child_id] 1051 deleted = [] 1052 for id in child_id: 1053 try: 1054 del self.context[id] 1055 deleted.append(id) 1056 except: 1057 self.flash('Could not delete %s: %s: %s' % ( 1058 id, sys.exc_info()[0], sys.exc_info()[1])) 1059 if len(deleted): 1060 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1061 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 1062 return 1063 1064 @grok.action('Add faculty', validator=NullValidator) 1065 def addFaculty(self, **data): 1066 self.redirect(self.url(self.context, '@@add')) 1067 return 1068 1069 @grok.action('Cancel', validator=NullValidator) 1042 1043 class DepartmentAddFormPage(WAeUPAddFormPage): 1044 """Add a department to a faculty. 1045 """ 1046 grok.context(IFaculty) 1047 grok.name('add') 1048 grok.require('waeup.manageUniversity') 1049 label = 'Add department' 1050 form_fields = grok.AutoFields(IDepartmentAdd) 1051 pnav = 1 1052 1053 @property 1054 def title(self): 1055 return self.context.longtitle() 1056 1057 @grok.action('Add department') 1058 def addDepartment(self, **data): 1059 department = createObject(u'waeup.Department') 1060 self.applyData(department, **data) 1061 try: 1062 self.context.addDepartment(department) 1063 except KeyError: 1064 self.status = Invalid('The code chosen already exists ' 1065 'in the database') 1066 return 1067 except DuplicationError: 1068 self.status = Invalid('The code chosen already exists ' 1069 'in the database') 1070 return 1071 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1072 1073 @grok.action('Cancel') 1070 1074 def cancel(self, **data): 1071 1075 self.redirect(self.url(self.context)) 1072 return 1076 1073 1077 1074 1078 … … 1432 1436 return 1433 1437 1438 class CertificateCourseAddFormPage(WAeUPAddFormPage): 1439 """Add-page to add a course ref to a certificate 1440 """ 1441 grok.context(ICertificate) 1442 grok.name('addcertificatecourse') 1443 grok.require('waeup.manageUniversity') 1444 form_fields = grok.AutoFields(ICertificateCourseAdd) 1445 pnav = 1 1446 title = 'Add course referrer' 1447 1448 @grok.action('Add course referrer') 1449 def addCertcourse(self, **data): 1450 try: 1451 self.context.addCourseRef(**data) 1452 except KeyError: 1453 self.status = Invalid('The chosen course referrer is already part of' 1454 'this certificate') 1455 return 1456 except DuplicationError: 1457 self.status = Invalid('The chosen course referrer is already part of' 1458 'this certificate') 1459 return 1460 self.redirect(self.url(self.context)) 1461 1462 @grok.action('Cancel', validator=NullValidator) 1463 def cancel(self, **data): 1464 self.redirect(self.url(self.context)) 1465 return 1466 1467 1434 1468 # 1435 1469 # Certificate course pages... … … 1448 1482 return 'Course Referrer: %s' % (self.context.__name__) 1449 1483 1450 class CertificateCourse FormPage(WAeUPEditFormPage):1484 class CertificateCourseManageFormPage(WAeUPEditFormPage): 1451 1485 """Manage the basic properties of a `CertificateCourse` instance. 1452 1486 """ … … 1481 1515 return 1482 1516 1483 class CertificateCourseAddFormPage(WAeUPAddFormPage):1484 """Add-page to add a course ref to a certificate1485 """1486 grok.context(ICertificate)1487 grok.name('addcertificatecourse')1488 grok.require('waeup.manageUniversity')1489 form_fields = grok.AutoFields(ICertificateCourseAdd)1490 pnav = 11491 title = 'Add course referrer'1492 1493 @grok.action('Add course referrer')1494 def addCertcourse(self, **data):1495 try:1496 self.context.addCourseRef(**data)1497 except KeyError:1498 self.status = Invalid('The chosen course referrer is already part of'1499 'this certificate')1500 return1501 except DuplicationError:1502 self.status = Invalid('The chosen course referrer is already part of'1503 'this certificate')1504 return1505 self.redirect(self.url(self.context))1506 1507 @grok.action('Cancel', validator=NullValidator)1508 def cancel(self, **data):1509 self.redirect(self.url(self.context))1510 return
Note: See TracChangeset for help on using the changeset viewer.