Changeset 7334 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 12 Dec 2011, 14:11:21 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7333 r7334 1407 1407 yield(dict(url=url, name=key, container=val)) 1408 1408 1409 class ShowStudents Page(SIRPPage):1409 class ShowStudentsInDepartmentPage(SIRPPage): 1410 1410 """Page that lists all students in the department. 1411 1411 """ 1412 1412 grok.context(IDepartment) 1413 1413 grok.require('waeup.showStudents') 1414 grok.name('showstudents') 1414 grok.name('showdepstudents') 1415 grok.template('showstudentspage') 1415 1416 pnav = 1 1416 1417 label = 'Students' … … 1429 1430 datatable.need() 1430 1431 return 1432 1433 class ShowStudentsInCertificatePage(ShowStudentsInDepartmentPage): 1434 """Page that lists all students studying a certificate. 1435 """ 1436 grok.context(ICertificate) 1437 grok.require('waeup.showStudents') 1438 grok.name('showcertstudents') 1439 pnav = 1 1440 label = 'Students' 1441 1442 @property 1443 def getStudents(self): 1444 hitlist = searchstudents(query=self.context.code, 1445 searchtype='certcode', view=self) 1446 return hitlist 1431 1447 1432 1448 class DepartmentManageFormPage(SIRPEditFormPage): -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r7333 r7334 434 434 icon = 'actionicon_student.png' 435 435 text = 'Show students' 436 target = 'show students'436 target = 'showdepstudents' 437 437 438 438 class ManageCourseActionButton(ManageActionButton): … … 449 449 grok.view(CertificatePage) 450 450 text = 'Manage certificate' 451 452 class ShowCertificateStudentsActionButton(ManageActionButton): 453 """ 'Show students' button for certificates. 454 """ 455 grok.context(ICertificate) 456 grok.view(CertificatePage) 457 grok.require('waeup.showStudents') 458 icon = 'actionicon_student.png' 459 text = 'Show students' 460 target = 'showcertstudents' 451 461 452 462 class ManageCertificateCourseActionButton(ManageActionButton): -
main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
r7321 r7334 82 82 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 83 83 84 class CourseAdviser(grok.Role): 85 """The course adviser role is meant for the 86 assignment of dynamic roles only. 87 """ 88 grok.name('waeup.local.CourseAdviser') 89 grok.title(u'Course Adviser') 90 grok.permissions('waeup.showStudents') 84 class CourseAdviser100(grok.Role): 85 """The course adviser role is meant for the 86 assignment of dynamic roles only. 87 """ 88 grok.name('waeup.local.CourseAdviser100') 89 grok.title(u'Course Adviser 100L') 90 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 91 92 class CourseAdviser200(grok.Role): 93 """The course adviser role is meant for the 94 assignment of dynamic roles only. 95 """ 96 grok.name('waeup.local.CourseAdviser200') 97 grok.title(u'Course Adviser 200L') 98 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 99 100 class CourseAdviser300(grok.Role): 101 """The course adviser role is meant for the 102 assignment of dynamic roles only. 103 """ 104 grok.name('waeup.local.CourseAdviser300') 105 grok.title(u'Course Adviser 300L') 106 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 107 108 class CourseAdviser400(grok.Role): 109 """The course adviser role is meant for the 110 assignment of dynamic roles only. 111 """ 112 grok.name('waeup.local.CourseAdviser400') 113 grok.title(u'Course Adviser 400L') 114 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 115 116 class CourseAdviser500(grok.Role): 117 """The course adviser role is meant for the 118 assignment of dynamic roles only. 119 """ 120 grok.name('waeup.local.CourseAdviser500') 121 grok.title(u'Course Adviser 500L') 122 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 123 124 class CourseAdviser600(grok.Role): 125 """The course adviser role is meant for the 126 assignment of dynamic roles only. 127 """ 128 grok.name('waeup.local.CourseAdviser600') 129 grok.title(u'Course Adviser 600L') 130 grok.permissions('waeup.showStudents', 'waeup.viewAcademics') 91 131 92 132 class Owner(grok.Role): … … 194 234 to assign each role to). 195 235 """ 196 return [ 197 dict( 236 list_of_dict = [dict( 198 237 name=name, 199 238 title=role.title, 200 239 description=role.description) 201 for name, role in self._roles] 240 for name, role in self._roles] 241 return sorted(list_of_dict, key=lambda x: x['name']) 202 242 203 243 def get_users_with_local_roles(context): -
main/waeup.sirp/trunk/src/waeup/sirp/permissions.txt
r7321 r7334 39 39 >>> from waeup.sirp.permissions import get_waeup_roles 40 40 >>> len(list(get_waeup_roles())) 41 1 041 11 42 42 43 43 >>> len(list(get_waeup_roles(also_local=True))) 44 1644 22 45 45 46 46 … … 53 53 >>> from waeup.sirp.permissions import get_waeup_role_names 54 54 >>> list(get_waeup_role_names()) 55 [u'waeup.ACManager', u'waeup.AcademicsOfficer', 56 u'waeup.AccommodationOfficer', u'waeup.Applicant', 55 [u'waeup.ACManager', 56 u'waeup.AcademicsOfficer', 57 u'waeup.AccommodationOfficer', 58 u'waeup.Applicant', 57 59 u'waeup.ApplicationsOfficer', 58 u'waeup.PortalManager', u'waeup.Student', 59 u'waeup.StudentsClearanceOfficer', u'waeup.StudentsManager', 60 u'waeup.PortalManager', 61 u'waeup.Student', 62 u'waeup.StudentsClearanceOfficer', 63 u'waeup.StudentsCourseAdviser', 64 u'waeup.StudentsManager', 60 65 u'waeup.StudentsOfficer'] 61 66 -
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') -
main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py
r7321 r7334 32 32 """ 33 33 grok.implements(ICertificate, ICertificateAdd) 34 35 @property # Make this method read_only and looking like an attr. 36 def local_roles(cls): 37 return ['waeup.local.CourseAdviser100', 38 'waeup.local.CourseAdviser200', 39 'waeup.local.CourseAdviser300', 40 'waeup.local.CourseAdviser400', 41 'waeup.local.CourseAdviser500', 42 'waeup.local.CourseAdviser600', 43 ] 34 44 35 45 def __init__(self, code=u'NA', title=u'Unnamed Certificate', -
main/waeup.sirp/trunk/src/waeup/sirp/university/department.py
r7333 r7334 33 33 def local_roles(cls): 34 34 return ['waeup.local.DepartmentManager', 35 'waeup.local.ClearanceOfficer',] 35 'waeup.local.ClearanceOfficer', 36 'waeup.local.CourseAdviser100', 37 'waeup.local.CourseAdviser200', 38 'waeup.local.CourseAdviser300', 39 'waeup.local.CourseAdviser400', 40 'waeup.local.CourseAdviser500', 41 'waeup.local.CourseAdviser600', 42 ] 36 43 37 44 # A simple counter for ids. -
main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py
r7195 r7334 34 34 def local_roles(cls): 35 35 return ['waeup.local.DepartmentManager', 36 'waeup.local.ClearanceOfficer',] 36 'waeup.local.ClearanceOfficer', 37 'waeup.local.CourseAdviser100', 38 'waeup.local.CourseAdviser200', 39 'waeup.local.CourseAdviser300', 40 'waeup.local.CourseAdviser400', 41 'waeup.local.CourseAdviser500', 42 'waeup.local.CourseAdviser600', 43 ] 37 44 38 45 def __init__(self,
Note: See TracChangeset for help on using the changeset viewer.