Changeset 6808
- Timestamp:
- 21 Sep 2011, 08:26:51 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6806 r6808 486 486 target = 'manage' 487 487 488 class AddStudyLevelActionButton(AddActionButton):489 grok.order(1)490 grok.context(IStudentStudyCourse)491 grok.view(StudyCourseDisplayFormPage)492 grok.require('waeup.handleStudent')493 text = 'Add course list'494 target = 'add'495 496 @property497 def target_url(self):498 student = self.view.context.getStudent()499 condition1 = student.state != 'school fee paid'500 condition2 = str(student['studycourse'].current_level) in \501 self.view.context.keys()502 if condition1 or condition2:503 return ''504 return self.view.url(self.view.context, self.target)505 506 488 class StudyCourseManageFormPage(WAeUPEditFormPage): 507 489 """ Page to edit the student study course data … … 668 650 669 651 class CourseTicketAddFormPage(WAeUPAddFormPage): 670 """Add a department to a faculty.652 """Add a course ticket. 671 653 """ 672 654 grok.context(IStudentStudyLevel) … … 674 656 grok.require('waeup.manageStudents') 675 657 label = 'Add course ticket' 676 form_fields = grok.AutoFields(ICourseTicketAdd).omit('grade', 'score') 658 form_fields = grok.AutoFields(ICourseTicketAdd).omit( 659 'grade', 'score', 'automatic') 677 660 pnav = 4 678 661 … … 1021 1004 return 1022 1005 1006 class AddStudyLevelActionButton(AddActionButton): 1007 grok.order(1) 1008 grok.context(IStudentStudyCourse) 1009 grok.view(StudyCourseDisplayFormPage) 1010 grok.require('waeup.handleStudent') 1011 text = 'Add course list' 1012 target = 'add' 1013 1014 @property 1015 def target_url(self): 1016 student = self.view.context.getStudent() 1017 condition1 = student.state != 'school fee paid' 1018 condition2 = str(student['studycourse'].current_level) in \ 1019 self.view.context.keys() 1020 if condition1 or condition2: 1021 return '' 1022 return self.view.url(self.view.context, self.target) 1023 1023 1024 class AddStudyLevelFormPage(WAeUPEditFormPage): 1024 1025 """ Page for students to add current study levels … … 1063 1064 self.redirect(self.url(self.context)) 1064 1065 return 1066 1067 class StudyLevelEditActionButton(ManageActionButton): 1068 grok.order(1) 1069 grok.context(IStudentStudyLevel) 1070 grok.view(StudyLevelDisplayFormPage) 1071 grok.require('waeup.handleStudent') 1072 text = 'Add and remove courses' 1073 target = 'edit' 1074 1075 @property 1076 def target_url(self): 1077 student = self.view.context.getStudent() 1078 condition1 = student.state != 'school fee paid' 1079 condition2 = student[ 1080 'studycourse'].current_level != self.view.context.level 1081 if condition1 or condition2: 1082 return '' 1083 return self.view.url(self.view.context, self.target) 1084 1085 class StudyLevelEditFormPage(WAeUPEditFormPage): 1086 """ Page to edit the student study level data by students 1087 """ 1088 grok.context(IStudentStudyLevel) 1089 grok.name('edit') 1090 grok.require('waeup.handleStudent') 1091 grok.template('studyleveleditpage') 1092 form_fields = grok.AutoFields(IStudentStudyLevel).omit( 1093 'level_session', 'level_verdict') 1094 pnav = 4 1095 1096 def update(self): 1097 super(StudyLevelEditFormPage, self).update() 1098 # tabs.need() 1099 datatable.need() 1100 return 1101 1102 @property 1103 def title(self): 1104 return 'Study Level %s' % self.context.level_title 1105 1106 @property 1107 def label(self): 1108 return 'Add and remove course tickets of study level %s' % self.context.level_title 1109 1110 @property 1111 def total_credits(self): 1112 total_credits = 0 1113 for key, val in self.context.items(): 1114 total_credits += val.credits 1115 return total_credits 1116 1117 @grok.action('Add course ticket') 1118 def addCourseTicket(self, **data): 1119 self.redirect(self.url(self.context, 'ctadd')) 1120 1121 @grok.action('Remove selected tickets') 1122 def delCourseTicket(self, **data): 1123 form = self.request.form 1124 if form.has_key('val_id'): 1125 child_id = form['val_id'] 1126 else: 1127 self.flash('No ticket selected.') 1128 self.redirect(self.url(self.context, '@@edit')) 1129 return 1130 if not isinstance(child_id, list): 1131 child_id = [child_id] 1132 deleted = [] 1133 for id in child_id: 1134 # Student are not allowed to remove core tickets 1135 if not self.context[id].core_or_elective: 1136 try: 1137 del self.context[id] 1138 deleted.append(id) 1139 except: 1140 self.flash('Could not delete %s: %s: %s' % ( 1141 id, sys.exc_info()[0], sys.exc_info()[1])) 1142 if len(deleted): 1143 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1144 self.redirect(self.url(self.context, u'@@edit')) 1145 return 1146 1147 class CourseTicketAddFormPage2(CourseTicketAddFormPage): 1148 """Add a course ticket by student. 1149 """ 1150 grok.name('ctadd') 1151 grok.require('waeup.handleStudent') 1152 form_fields = grok.AutoFields(ICourseTicketAdd).omit( 1153 'grade', 'score', 'core_or_elective', 'automatic') 1154 1155 @grok.action('Add course ticket') 1156 def addCourseTicket(self, **data): 1157 ticket = CourseTicket() 1158 course = data['course'] 1159 ticket.automatic = False 1160 ticket.code = course.code 1161 ticket.title = course.title 1162 ticket.faculty = course.__parent__.__parent__.__parent__.title 1163 ticket.department = course.__parent__.__parent__.title 1164 ticket.credits = course.credits 1165 ticket.passmark = course.passmark 1166 ticket.semester = course.semester 1167 try: 1168 self.context.addCourseTicket(ticket) 1169 except KeyError: 1170 self.flash('The ticket exists.') 1171 return 1172 self.flash('Successfully added %s.' % ticket.code) 1173 self.redirect(self.url(self.context, u'@@edit')) 1174 return
Note: See TracChangeset for help on using the changeset viewer.