Changeset 4787 for waeup/branches/ulif-layout/src
- Timestamp:
- 11 Jan 2010, 16:26:30 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/viewlets.py
r4778 r4787 30 30 31 31 # 32 # Baseclasses that give some defaults for really used viewlets. 33 # 34 class ActionButton(grok.Viewlet): 35 """A base for action buttons. 36 37 An action button provides an icon, some text and links to a 38 target. If you want to set a different text, icon or target name 39 for some active button below, just override the approriate 40 attribute in the concerned viewlet. 41 42 Action buttons provide by default dynamic attributes 43 44 * ``alt`` 45 An alternative text for the icon. By default the same as 46 the text. 47 48 * ``icon_url`` 49 The URL of the icon. 50 51 * ``target_url`` 52 The URL of the link target. 53 54 """ 55 grok.baseclass() 56 grok.context(IWAeUPObject) 57 grok.template('actionbutton') 58 grok.viewletmanager(ActionBar) 59 icon = 'actionicon_modify.png' # File must exist in static/ 60 target = '@@manage' # link to this viewname. 61 text = 'Edit settings' # Text to display on the button 62 63 @property 64 def alt(self): 65 """Alternative text for icon. 66 """ 67 return self.text 68 69 @property 70 def icon_url(self): 71 """Get the icon URL. 72 """ 73 return self.view.static[self.icon]() 74 75 @property 76 def target_url(self): 77 """Get a URL to the target... 78 """ 79 return self.view.url(self.view.context, self.target) 80 81 82 class ManageActionButton(ActionButton): 83 """A base for 'edit' buttons 84 """ 85 grok.baseclass() 86 grok.order(2) 87 grok.require('waeup.manageUniversity') 88 icon = 'actionicon_modify.png' 89 target = '@@manage' 90 text = 'Edit settings' 91 92 class AddActionButton(ActionButton): 93 """A base for 'add' buttons. 94 """ 95 grok.baseclass() 96 grok.order(4) 97 grok.require('waeup.manageUniversity') 98 icon = 'actionicon_addfavorite.png' 99 target = 'add' 100 text = 'Add' 101 102 103 # 32 104 # General viewlets (for more than one page/context) 33 105 # … … 153 225 # 154 226 # Manage ("Edit settings") actions... 155 # 156 class ManageUniversityAction(grok.Viewlet): 157 grok.viewletmanager(ActionBar) 158 grok.context(IUniversity) 159 grok.view(UniversityPage) 160 grok.require('waeup.manageUniversity') 161 grok.order(2) 162 grok.template('manageaction') 163 164 class GoToFacultiesAction(grok.Viewlet): 165 grok.viewletmanager(ActionBar) 166 grok.context(IUniversity) 167 grok.view(UniversityPage) 168 grok.require('waeup.manageUniversity') 169 grok.order(3) 170 grok.template('gotofacultiesaction') 171 172 class ManageFacultiesAction(ManageUniversityAction): 227 # 228 class ManageUniversityActionButton(ManageActionButton): 229 """ 'Edit settings' button for University instances. 230 """ 231 grok.context(IUniversity) 232 grok.view(UniversityPage) 233 234 class ManageFacultiesActionButton(ManageActionButton): 235 """ 'Edit settings' button for faculty container. 236 """ 173 237 grok.context(IFacultyContainer) 174 238 grok.view(FacultyContainerPage) 175 grok.template('manageaction') 176 177 class ManageDataCenterAction(ManageUniversityAction): 239 240 class ManageDataCenterActionButton(ManageActionButton): 241 """ 'Edit settings' button for datacenter. 242 """ 178 243 grok.context(IDataCenter) 179 244 grok.view(DatacenterPage) 180 grok.template('manageaction') 181 grok.require('waeup.manageUniversity') 182 183 class ManageFacultyAction(ManageUniversityAction): 245 246 class ManageFacultyActionButton(ManageActionButton): 184 247 """ 'Edit settings' button for faculties. 185 248 """ 186 249 grok.context(IFaculty) 187 250 grok.view(FacultyPage) 188 grok.template('manageaction') 189 grok.require('waeup.manageUniversity') 190 191 class ManageDepartmentAction(ManageUniversityAction): 251 252 class ManageDepartmentActionButton(ManageActionButton): 192 253 """ 'Edit settings' button for departments. 193 254 """ 194 255 grok.context(IDepartment) 195 256 grok.view(DepartmentPage) 196 grok.template('manageaction') 197 grok.require('waeup.manageUniversity') 198 199 class ManageCourseAction(ManageUniversityAction): 257 258 class ManageCourseActionButton(ManageActionButton): 200 259 """ 'Edit settings' button for courses. 201 260 """ 202 261 grok.context(ICourse) 203 262 grok.view(CoursePage) 204 grok.template('manageaction') 205 grok.require('waeup.manageUniversity') 206 207 class ManageCertificateAction(ManageUniversityAction): 263 264 class ManageCertificateActionButton(ManageActionButton): 208 265 """ 'Edit settings' button for certificates. 209 266 """ 210 267 grok.context(ICertificate) 211 268 grok.view(CertificatePage) 212 grok.template('manageaction') 213 grok.require('waeup.manageUniversity') 214 215 class ManageCertificateCourseAction(ManageUniversityAction): 216 """ 'Edit settings' button for certificatecourses. 269 270 class ManageCertificateCourseActionButton(ManageActionButton): 271 """ 'Edit settings' button for certificate courses. 217 272 """ 218 273 grok.context(ICertificateCourse) 219 274 grok.view(CertificateCoursePage) 220 grok.template('manageaction')221 grok.require('waeup.manageUniversity')222 275 223 276 # … … 285 338 return '%s/@@%s' % (self.view.url(self.view.context), self.addview_name) 286 339 287 class AddFacult iesAction(AddAction):340 class AddFacultyActionButton(AddActionButton): 288 341 grok.context(IFacultyContainer) 289 342 grok.view(FacultyContainerPage) 290 grok.order(4) 291 grok.template('addaction') 292 grok.require('waeup.manageUniversity') 293 294 addview_name = 'add' 295 addlink_text = 'Add faculty' 296 297 class AddDepartmentsAction(AddAction): 343 text = 'Add faculty' 344 345 class AddDepartmentActionButton(AddActionButton): 298 346 grok.context(IFaculty) 299 347 grok.view(FacultyPage) 300 grok.order(4) 301 grok.template('addaction') 302 grok.require('waeup.manageUniversity') 303 304 addview_name = 'add' 305 addlink_text = 'Add department' 306 307 class AddCertificateAction(AddAction): 308 """Add-certificate button for department index page. 309 """ 348 text = 'Add department' 349 350 class AddCertificateActionButton(AddActionButton): 310 351 grok.context(IDepartment) 311 352 grok.view(DepartmentPage) 312 353 grok.order(3) 313 grok.template('addaction') 314 grok.require('waeup.manageUniversity') 315 316 addview_name = 'addcertificate' 317 addlink_text = 'Add certificate' 318 319 class AddCourseAction(AddAction): 320 """Add-course button for department index page. 321 """ 354 text = 'Add certificate' 355 target = 'addcertificate' 356 357 class AddCourseActionButton(AddActionButton): 322 358 grok.context(IDepartment) 323 359 grok.view(DepartmentPage) 324 360 grok.order(4) 325 grok.template('addaction') 326 grok.require('waeup.manageUniversity') 327 328 addview_name = 'addcourse' 329 addlink_text = 'Add course' 330 331 class AddCertificateCourseAction(AddAction): 332 """Add-course button for certificate index page. 333 """ 361 text = 'Add course' 362 target = 'addcourse' 363 364 class AddCertificateActionButton(AddActionButton): 334 365 grok.context(ICertificate) 335 366 grok.view(CertificatePage) 336 367 grok.order(4) 337 grok.template('addaction') 338 grok.require('waeup.manageUniversity') 339 340 addview_name = 'addcertificatecourse' 341 addlink_text = 'Add course' 368 text = 'Add course reference' 369 target = 'addcertificatecourse' 342 370 343 371
Note: See TracChangeset for help on using the changeset viewer.