Changeset 7334 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 12 Dec 2011, 14:11:21 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7329 r7334 594 594 595 595 def render(self): 596 self.redirect(self.url(self.context, 'view_clearance'))597 596 return 598 597 … … 615 614 else: 616 615 self.flash('Student is in the wrong state.') 616 self.redirect(self.url(self.context,'view_clearance')) 617 617 return 618 618 args = {'subject':message} … … 857 857 target = 'manage' 858 858 859 class StudentValidateCoursesActionButton(ManageActionButton): 860 grok.order(3) 861 grok.context(IStudentStudyLevel) 862 grok.view(StudyLevelDisplayFormPage) 863 grok.require('waeup.validateStudent') 864 text = 'Validate courses' 865 target = 'validate_courses' 866 icon = 'actionicon_accept.png' 867 868 @property 869 def target_url(self): 870 if self.context.getStudent().state != REGISTERED or \ 871 str(self.context.__parent__.current_level) != self.context.__name__: 872 return '' 873 return self.view.url(self.view.context, self.target) 874 875 class StudentRejectCoursesActionButton(ManageActionButton): 876 grok.order(4) 877 grok.context(IStudentStudyLevel) 878 grok.view(StudyLevelDisplayFormPage) 879 grok.require('waeup.validateStudent') 880 text = 'Reject courses' 881 target = 'reject_courses' 882 icon = 'actionicon_reject.png' 883 884 @property 885 def target_url(self): 886 if self.context.getStudent().state not in (VALIDATED, REGISTERED) or \ 887 str(self.context.__parent__.current_level) != self.context.__name__: 888 return '' 889 return self.view.url(self.view.context, self.target) 890 859 891 class StudyLevelManageFormPage(SIRPEditFormPage): 860 892 """ Page to edit the student study level data … … 915 947 self.flash('Successfully removed: %s' % ', '.join(deleted)) 916 948 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 949 return 950 951 class ValidateCoursesPage(grok.View): 952 """ Validate course list by course adviser 953 """ 954 grok.context(IStudentStudyLevel) 955 grok.name('validate_courses') 956 grok.require('waeup.validateStudent') 957 958 def update(self): 959 if str(self.context.__parent__.current_level) != self.context.__name__: 960 self.flash('This level does not correspond current level.') 961 elif self.context.getStudent().state == REGISTERED: 962 IWorkflowInfo(self.context.getStudent()).fireTransition('validate_courses') 963 self.flash('Course list has been registered.') 964 else: 965 self.flash('Student is in the wrong state.') 966 self.redirect(self.url(self.context)) 967 return 968 969 def render(self): 970 return 971 972 class RejectCoursesPage(grok.View): 973 """ Reject course list by course adviser 974 """ 975 grok.context(IStudentStudyLevel) 976 grok.name('reject_courses') 977 grok.require('waeup.validateStudent') 978 979 def update(self): 980 if str(self.context.__parent__.current_level) != self.context.__name__: 981 self.flash('This level does not correspond current level.') 982 self.redirect(self.url(self.context)) 983 return 984 elif self.context.getStudent().state == VALIDATED: 985 IWorkflowInfo(self.context.getStudent()).fireTransition('reset8') 986 message = 'Course list request has been annulled' 987 self.flash(message) 988 elif self.context.getStudent().state == REGISTERED: 989 IWorkflowInfo(self.context.getStudent()).fireTransition('reset7') 990 message = 'Course list request has been rejected' 991 self.flash(message) 992 else: 993 self.flash('Student is in the wrong state.') 994 self.redirect(self.url(self.context)) 995 return 996 args = {'subject':message} 997 self.redirect(self.url(self.context.getStudent()) + 998 '/contactstudent?%s' % urlencode(args)) 999 return 1000 1001 def render(self): 917 1002 return 918 1003 -
main/waeup.sirp/trunk/src/waeup/sirp/students/dynamicroles.py
r7256 r7334 46 46 rolename_mapping = { 47 47 'waeup.local.ClearanceOfficer':'waeup.StudentsClearanceOfficer', 48 'waeup.local.CourseAdviser100':'waeup.StudentsCourseAdviser 100',49 'waeup.local.CourseAdviser200':'waeup.StudentsCourseAdviser 200',50 'waeup.local.CourseAdviser300':'waeup.StudentsCourseAdviser 300',51 'waeup.local.CourseAdviser400':'waeup.StudentsCourseAdviser 400',52 'waeup.local.CourseAdviser500':'waeup.StudentsCourseAdviser 500',53 'waeup.local.CourseAdviser600':'waeup.StudentsCourseAdviser 600'48 'waeup.local.CourseAdviser100':'waeup.StudentsCourseAdviser', 49 'waeup.local.CourseAdviser200':'waeup.StudentsCourseAdviser', 50 'waeup.local.CourseAdviser300':'waeup.StudentsCourseAdviser', 51 'waeup.local.CourseAdviser400':'waeup.StudentsCourseAdviser', 52 'waeup.local.CourseAdviser500':'waeup.StudentsCourseAdviser', 53 'waeup.local.CourseAdviser600':'waeup.StudentsCourseAdviser' 54 54 } 55 55 … … 100 100 obj = getattr( 101 101 self._context[self.subcontainer], self.extra_attrib, None) 102 current_level = getattr( 103 self._context[self.subcontainer], 'current_level', None) 102 104 else: 103 105 obj = getattr(self._context, self.extra_attrib, None) 106 current_level = None 104 107 # lookup local roles for connected course and all parent 105 108 # objects. This way we fake 'role inheritance'. … … 113 116 # permissions (allow, deny or unset) for the 114 117 # passed in principal id. 115 result.append( 116 (self.rolename_mapping[role_id], setting)) 118 # Make an exception for Course Advisers: 119 # Grant additional role only if external role corresponds 120 # with current_level of student. 121 if not current_level or \ 122 'CourseAdviser' not in role_id or \ 123 str(current_level) in role_id: 124 result.append( 125 (self.rolename_mapping[role_id], setting)) 117 126 return result 118 127 obj = getattr(obj, '__parent__', None) -
main/waeup.sirp/trunk/src/waeup/sirp/students/permissions.py
r7240 r7334 53 53 grok.name('waeup.clearStudent') 54 54 55 class ValidateStudent(grok.Permission): 56 grok.name('waeup.validateStudent') 57 55 58 # Local role 56 59 class StudentRecordOwner(grok.Role): … … 83 86 grok.title(u'Clearance Officer (all students)') 84 87 grok.permissions('waeup.clearStudent','waeup.viewStudent') 88 89 class StudentsCourseAdviser(grok.Role): 90 grok.name('waeup.StudentsCourseAdviser') 91 grok.title(u'Course Adviser (all students)') 92 grok.permissions('waeup.validateStudent','waeup.viewStudent')
Note: See TracChangeset for help on using the changeset viewer.