Changeset 6161 for main/waeup.sirp/trunk
- Timestamp:
- 20 May 2011, 09:39:59 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6154 r6161 48 48 user = form['user'] 49 49 role_manager = IPrincipalRoleManager(view.context) 50 role_manager.assignRoleToPrincipal(localrole, user) 51 view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab) 52 return 53 54 def get_users_with_local_roles(view): 55 role_manager = IPrincipalRoleManager(view.context) 50 56 role_map = IPrincipalRoleMap(view.context) 51 role_manager.assignRoleToPrincipal(localrole, user) 57 for item in role_map.getPrincipalsAndRoles(): 58 local_role = item[0] 59 user_name = item[1] 60 setting = item[2] 61 user = grok.getSite()['users'].get(user_name,None) 62 roles_dict = view.context.local_roles 63 local_role_title = roles_dict[local_role] 64 if user: 65 yield(dict(user_name=user_name, user_title=user.description, 66 local_role=local_role, local_role_title=local_role_title, 67 setting=setting)) 68 else: 69 yield(dict(user_name=user_name, user_title=user_name, 70 local_role=local_role, local_role_title=local_role_title, 71 setting=setting)) 72 73 def del_local_roles(view, tab, **data): 74 form = view.request.form 75 if form.has_key('role_id'): 76 child_id = form['role_id'] 77 else: 78 view.flash('No local role selected!') 79 view.redirect(view.url(view.context, '@@manage')+'#tab-%s' % tab) 80 return 81 if not isinstance(child_id, list): 82 child_id = [child_id] 83 #import pdb; pdb.set_trace() 84 deleted = [] 85 role_manager = IPrincipalRoleManager(view.context) 86 for id in child_id: 87 localrole = id.split('|')[1] 88 user_name = id.split('|')[0] 89 try: 90 role_manager.unsetRoleForPrincipal(localrole, user_name) 91 deleted.append(id) 92 except: 93 view.flash('Could not remove %s: %s: %s' % ( 94 id, sys.exc_info()[0], sys.exc_info()[1])) 95 if len(deleted): 96 view.flash('Successfully removed: %s' % ', '.join(deleted)) 52 97 view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab) 53 98 return … … 859 904 def delFaculties(self, **data): 860 905 form = self.request.form 861 child_id = form['val_id'] 906 if form.has_key('val_id'): 907 child_id = form['val_id'] 908 else: 909 self.flash('No faculty selected!') 910 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 911 return 862 912 if not isinstance(child_id, list): 863 913 child_id = [child_id] … … 947 997 taboneactions = ['Save','Cancel'] 948 998 tabtwoactions = ['Add department', 'Remove selected','Cancel'] 949 tabthreeactions = ['Add local role', 'Remove local roles selected'] 999 tabthreeactions1 = ['Remove selected local roles'] 1000 tabthreeactions2 = ['Add local role'] 950 1001 951 1002 form_fields = grok.AutoFields(IFaculty) … … 961 1012 def update(self): 962 1013 tabs.need() 963 #warning.need()1014 datatable.need() 964 1015 return super(FacultyManageFormPage, self).update() 965 1016 … … 974 1025 url = self.url(val) 975 1026 yield(dict(url=url, name=key, val=val)) 1027 1028 def getUsersWithLocalRoles(self): 1029 return get_users_with_local_roles(self) 976 1030 977 1031 # ToDo: Show warning message before deletion … … 982 1036 child_id = form['val_id'] 983 1037 else: 984 self.flash('No subunit selected!')985 self.redirect(self.url(self.context, '@@manage')+'#tab- %s' % tab)1038 self.flash('No department selected!') 1039 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 986 1040 return 987 1041 if not isinstance(child_id, list): … … 1019 1073 return add_local_role(self, '3', **data) 1020 1074 1075 @grok.action('Remove selected local roles') 1076 def delLocalRoles(self, **data): 1077 return del_local_roles(self,3,**data) 1078 1021 1079 class DepartmentAddFormPage(WAeUPAddFormPage): 1022 1080 """Add a department to a faculty. … … 1100 1158 tabtwoactions = ['Add course', 'Remove selected courses','Cancel'] 1101 1159 tabthreeactions = ['Add certificate', 'Remove selected certificates', 'Cancel'] 1102 tabfouractions = ['Add local role', 'Remove local roles selected'] 1160 tabfouractions1 = ['Remove selected local roles'] 1161 tabfouractions2 = ['Add local role'] 1103 1162 1104 1163 form_fields = grok.AutoFields(IDepartment) … … 1142 1201 url = self.url(val) 1143 1202 yield(dict(url=url, name=key, val=val)) 1203 1204 def getUsersWithLocalRoles(self): 1205 return get_users_with_local_roles(self) 1144 1206 1145 1207 @grok.action('Save') … … 1152 1214 def delCourses(self, **data): 1153 1215 form = self.request.form 1154 child_id = form['val_id'] 1216 if form.has_key('val_id'): 1217 child_id = form['val_id'] 1218 else: 1219 self.flash('No course selected!') 1220 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1221 return 1155 1222 if not isinstance(child_id, list): 1156 1223 child_id = [child_id] … … 1171 1238 def delCertificates(self, **data): 1172 1239 form = self.request.form 1173 child_id = form['val_id'] 1240 if form.has_key('val_id'): 1241 child_id = form['val_id'] 1242 else: 1243 self.flash('No certificate selected!') 1244 self.redirect(self.url(self.context, '@@manage')+'#tab-3') 1245 return 1174 1246 if not isinstance(child_id, list): 1175 1247 child_id = [child_id] … … 1206 1278 return add_local_role(self, 4, **data) 1207 1279 1280 @grok.action('Remove selected local roles') 1281 def delLocalRoles(self, **data): 1282 return del_local_roles(self,4,**data) 1283 1208 1284 class CourseAddFormPage(WAeUPAddFormPage): 1209 1285 """Add-form to add course to a department. … … 1396 1472 def delCertificateCourses(self, **data): 1397 1473 form = self.request.form 1398 child_id = form['val_id'] 1474 if form.has_key('val_id'): 1475 child_id = form['val_id'] 1476 else: 1477 self.flash('No course referrer selected!') 1478 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1479 return 1399 1480 if not isinstance(child_id, list): 1400 1481 child_id = [child_id] -
main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css
r6133 r6161 66 66 .ui-tabs .ui-tabs-nav li a:hover { 67 67 text-decoration: underline; 68 } 69 70 .dataTables_wrapper { 71 min-height: 100px; 68 72 } 69 73 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentmanagepage.pt
r6152 r6161 31 31 32 32 <div id="tab-1"> 33 <table class="zebra"> 34 <tbody> 35 <tal:block repeat="widget view/widgets"> 36 <tr> 37 <td class="label" tal:define="hint widget/hint"> 38 <label tal:condition="python:hint" 39 tal:attributes="for widget/name"> 40 <span class="required" tal:condition="widget/required" 41 >*</span><span i18n:translate="" 42 tal:content="widget/label">label</span> 43 </label> 44 <label tal:condition="python:not hint" 45 tal:attributes="for widget/name"> 46 <span class="required" tal:condition="widget/required" 47 >*</span><span i18n:translate="" 48 tal:content="widget/label">label</span> 49 </label>: 50 </td> 51 <td class="field"> 52 <div class="widget" tal:content="structure widget"> 53 <input type="text" /> 54 </div> 55 <div class="error" tal:condition="widget/error"> 56 <span tal:replace="structure widget/error">error</span> 57 </div> 58 </td> 59 </tr> 60 </tal:block> 61 </tbody> 62 </table> 63 64 <div id="actionsView"> 65 <span class="actionButtons" tal:condition="view/availableActions"> 66 <span tal:repeat="action view/actions" 67 tal:omit-tag=""> 68 <input tal:condition="python:action.label in view.taboneactions" 69 tal:replace="structure action/render"/> 70 </span> 71 </span> 72 </div> 33 <table class="zebra"> 34 <tbody> 35 <tal:block repeat="widget view/widgets"> 36 <tr> 37 <td class="label" tal:define="hint widget/hint"> 38 <label tal:condition="python:hint" 39 tal:attributes="for widget/name"> 40 <span class="required" tal:condition="widget/required" 41 >*</span><span i18n:translate="" 42 tal:content="widget/label">label</span> 43 </label> 44 <label tal:condition="python:not hint" 45 tal:attributes="for widget/name"> 46 <span class="required" tal:condition="widget/required" 47 >*</span><span i18n:translate="" 48 tal:content="widget/label">label</span> 49 </label>: 50 </td> 51 <td class="field"> 52 <div class="widget" tal:content="structure widget"> 53 <input type="text" /> 54 </div> 55 <div class="error" tal:condition="widget/error"> 56 <span tal:replace="structure widget/error">error</span> 57 </div> 58 </td> 59 </tr> 60 </tal:block> 61 </tbody> 62 </table> 63 64 <div class="actionButtons" tal:condition="view/availableActions"> 65 <span tal:repeat="action view/actions" 66 tal:omit-tag=""> 67 <input tal:condition="python:action.label in view.taboneactions" 68 tal:replace="structure action/render"/> 69 </span> 70 </div> 73 71 74 72 </div> … … 100 98 </table> 101 99 <br /><br /> 102 <div id="actionsView"> 103 <span class="actionButtons" tal:condition="view/availableActions"> 104 <span tal:repeat="action view/actions" 105 tal:omit-tag=""> 106 <input tal:condition="python:action.label in view.tabtwoactions" 107 tal:replace="structure action/render"/> 108 </span> 109 </span> 110 </div> 100 <div class="actionButtons" tal:condition="view/availableActions"> 101 <span tal:repeat="action view/actions" 102 tal:omit-tag=""> 103 <input tal:condition="python:action.label in view.tabtwoactions" 104 tal:replace="structure action/render"/> 105 </span> 106 </div> 111 107 </div> 112 108 … … 137 133 </table> 138 134 <br /><br /> 139 <div id="actionsView"> 140 <span class="actionButtons" tal:condition="view/availableActions"> 141 <span tal:repeat="action view/actions" 142 tal:omit-tag=""> 143 <input tal:condition="python:action.label in view.tabthreeactions" 144 tal:replace="structure action/render"/> 145 </span> 146 </span> 147 </div> 135 <div class="actionButtons" tal:condition="view/availableActions"> 136 <span tal:repeat="action view/actions" 137 tal:omit-tag=""> 138 <input tal:condition="python:action.label in view.tabthreeactions" 139 tal:replace="structure action/render"/> 140 </span> 141 </div> 148 142 </div> 149 143 150 144 <div id="tab-4"> 151 <h3>Manage local roles</h3> 145 <br /> 146 <table class="display dataTableManage"> 147 <thead> 148 <tr> 149 <th> </th><th>User</th><th>Local Role</th> 150 </tr> 151 </thead> 152 <tbody> 153 <tr tal:repeat="entry view/getUsersWithLocalRoles" 154 class="gradeB"> 155 <td> 156 <input type="checkbox" name="role_id" 157 tal:attributes="value python: entry['user_name']+'|'+entry['local_role']" /> 158 </td> 159 <td tal:content="entry/user_title">User 160 </td> 161 <td tal:content="entry/local_role_title"> 162 Local Role 163 </td> 164 </tr> 165 </tbody> 166 </table> 167 <div class="actionButtons" tal:condition="view/availableActions"> 168 <span tal:repeat="action view/actions" 169 tal:omit-tag=""> 170 <input tal:condition="python:action.label in view.tabfouractions1" 171 tal:replace="structure action/render"/> 172 </span> 173 </div> 174 <br /><br /> 152 175 <table class="zebra"> 153 176 <tr> 154 <td>155 <label>User:</label>156 </td>157 177 <td> 158 178 <select id="user" name="user" tal:repeat="user view/getUsers"> … … 161 181 </option> 162 182 </select> 163 </td>164 </tr>165 <tr>166 <td>167 <label>Local Role:</label>168 183 </td> 169 184 <td> … … 174 189 </select> 175 190 </td> 191 <td> 192 <div class="actionButtons" tal:condition="view/availableActions"> 193 <span tal:repeat="action view/actions" 194 tal:omit-tag=""> 195 <input tal:condition="python:action.label in view.tabfouractions2" 196 tal:replace="structure action/render"/> 197 </span> 198 </div> 199 </td> 200 176 201 </tr> 177 202 </table> 178 179 <div id="actionsView"> 180 <span class="actionButtons" tal:condition="view/availableActions"> 181 <span tal:repeat="action view/actions" 182 tal:omit-tag=""> 183 <input tal:condition="python:action.label in view.tabfouractions" 184 tal:replace="structure action/render"/> 185 </span> 186 </span> 187 </div> 188 </div> 189 203 </div> 190 204 </div> 191 205 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt
r6130 r6161 30 30 31 31 <div id="tab-1"> 32 33 <tbody>34 <tal:block repeat="widget view/widgets">35 <tr>36 <td class="label" tal:define="hint widget/hint">37 38 39 40 41 42 43 44 45 46 47 48 49 </td>50 <td class="field">51 52 53 54 55 56 57 </td>58 </tr>59 </tal:block>60 </tbody>61 32 <table class="zebra"> 33 <tbody> 34 <tal:block repeat="widget view/widgets"> 35 <tr> 36 <td class="label" tal:define="hint widget/hint"> 37 <label tal:condition="python:hint" 38 tal:attributes="for widget/name"> 39 <span class="required" tal:condition="widget/required" 40 >*</span><span i18n:translate="" 41 tal:content="widget/label">label</span> 42 </label> 43 <label tal:condition="python:not hint" 44 tal:attributes="for widget/name"> 45 <span class="required" tal:condition="widget/required" 46 >*</span><span i18n:translate="" 47 tal:content="widget/label">label</span> 48 </label>: 49 </td> 50 <td class="field"> 51 <div class="widget" tal:content="structure widget"> 52 <input type="text" /> 53 </div> 54 <div class="error" tal:condition="widget/error"> 55 <span tal:replace="structure widget/error">error</span> 56 </div> 57 </td> 58 </tr> 59 </tal:block> 60 </tbody> 61 </table> 62 62 63 <div id="actionsView"> 64 <span class="actionButtons" tal:condition="view/availableActions"> 65 <span tal:repeat="action view/actions" 66 tal:omit-tag=""> 67 <input tal:condition="python:action.label in view.taboneactions" 68 tal:replace="structure action/render"/> 69 </span> 63 <div class="actionButtons" tal:condition="view/availableActions"> 64 <span tal:repeat="action view/actions" 65 tal:omit-tag=""> 66 <input tal:condition="python:action.label in view.taboneactions" 67 tal:replace="structure action/render"/> 70 68 </span> 71 </div> 69 </div> 72 70 73 71 </div> … … 75 73 <div id="tab-2"> 76 74 <h3 tal:content="view/subunits">Departments</h3> 77 <table class="zebra">75 <table class="zebra"> 78 76 <thead> 79 77 <tr> … … 101 99 </tr> 102 100 </tbody> 103 </table>101 </table> 104 102 105 <div id="actionsView"> 106 <span class="actionButtons" tal:condition="view/availableActions"> 107 <span tal:repeat="action view/actions" 108 tal:omit-tag=""> 109 <input tal:condition="python:action.label in view.tabtwoactions" 110 tal:replace="structure action/render"/> 111 </span> 103 <div class="actionButtons" tal:condition="view/availableActions"> 104 <span tal:repeat="action view/actions" 105 tal:omit-tag=""> 106 <input tal:condition="python:action.label in view.tabtwoactions" 107 tal:replace="structure action/render"/> 112 108 </span> 113 </div> 109 </div> 114 110 </div> 115 111 116 112 <div id="tab-3"> 117 <h3>Manage local roles</h3> 113 <br /> 114 <table class="display dataTableManage"> 115 <thead> 116 <tr> 117 <th> </th><th>User</th><th>Local Role</th> 118 </tr> 119 </thead> 120 <tbody> 121 <tr tal:repeat="entry view/getUsersWithLocalRoles" 122 class="gradeB"> 123 <td> 124 <input type="checkbox" name="role_id" 125 tal:attributes="value python: entry['user_name']+'|'+entry['local_role']" /> 126 </td> 127 <td tal:content="entry/user_title">User 128 </td> 129 <td tal:content="entry/local_role_title"> 130 Local Role 131 </td> 132 </tr> 133 </tbody> 134 </table> 135 <div class="actionButtons" tal:condition="view/availableActions"> 136 <span tal:repeat="action view/actions" 137 tal:omit-tag=""> 138 <input tal:condition="python:action.label in view.tabthreeactions1" 139 tal:replace="structure action/render"/> 140 </span> 141 </div> 142 <br /><br /> 118 143 <table class="zebra"> 119 144 <tr> 120 <td>121 <label>User:</label>122 </td>123 145 <td> 124 146 <select id="user" name="user" tal:repeat="user view/getUsers"> … … 127 149 </option> 128 150 </select> 129 </td>130 </tr>131 <tr>132 <td>133 <label>Local Role:</label>134 151 </td> 135 152 <td> … … 140 157 </select> 141 158 </td> 159 <td> 160 <div class="actionButtons" tal:condition="view/availableActions"> 161 <span tal:repeat="action view/actions" 162 tal:omit-tag=""> 163 <input tal:condition="python:action.label in view.tabthreeactions2" 164 tal:replace="structure action/render"/> 165 </span> 166 </div> 167 </td> 142 168 </tr> 143 169 </table> 144 145 <div id="actionsView">146 <span class="actionButtons" tal:condition="view/availableActions">147 <span tal:repeat="action view/actions"148 tal:omit-tag="">149 <input tal:condition="python:action.label in view.tabthreeactions"150 tal:replace="structure action/render"/>151 </span>152 </span>153 </div>154 170 </div> 155 171
Note: See TracChangeset for help on using the changeset viewer.