- Timestamp:
- 29 Dec 2009, 16:48:24 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/app.py
r4579 r4585 1 1 import grok 2 import re3 2 from zope.app.authentication.authentication import PluggableAuthentication 4 3 from zope.app.security.interfaces import IAuthentication 5 from zope.component import getUtility, getMultiAdapter, createObject 6 from zope.interface import Interface 4 from zope.component import createObject 7 5 8 from waeup.interfaces import (IUniversity, IStudentContainer, IHostelContainer, 9 IFacultyContainer, ICSVDataReceivers) 10 from waeup.viewlets import (MainArea, LeftSidebar, Index, Manage, 11 FormWrapMixin, master_template_path) 6 from waeup.interfaces import IUniversity, ICSVDataReceivers 12 7 from waeup.authentication import setup_authentication 13 8 from waeup.datacenter import DataCenter 14 9 from waeup.users import UserContainer 15 from waeup.widgets.interfaces import ITableProvider16 17 master_template = grok.PageTemplateFile(master_template_path)18 10 19 11 class University(grok.Application, grok.Container): … … 56 48 return self.datacenter 57 49 return None 58 59 60 class ManageForm(grok.EditForm):61 """Manage the basic properties of a `University` instance.62 """63 64 form_fields = grok.AutoFields(IUniversity)65 grok.require('waeup.manageUniversity')66 67 @grok.action('Save')68 def save(self, **data):69 self.applyData(self.context, **data)70 return71 72 @grok.action('Save and return')73 def saveAndReturn(self, **data):74 self.applyData(self.context, **data)75 self.redirect(self.url(self.context))76 return77 78 @grok.action('Cancel')79 def cancel(self, **data):80 self.redirect(self.url(self.context))81 return82 83 class ManageUniversity(Manage):84 grok.name('manage')85 grok.context(IUniversity)86 grok.require('waeup.manageUniversity')87 grok.template('master_template')88 89 90 class ManageUniversityMain(FormWrapMixin, grok.Viewlet):91 """A viewlet that renders the `ManageForm`.92 """93 grok.viewletmanager(MainArea)94 grok.context(IUniversity)95 grok.view(Manage)96 grok.require('waeup.manageUniversity')97 98 formview_name = 'manageform' # The name of the formview we want to99 # be rendered in this viewlet.100 101 class Content(grok.Viewlet):102 grok.viewletmanager(MainArea)103 grok.context(IUniversity)104 grok.view(Index)105 106 def update(self):107 self.table = ITableProvider(self.context).getTables(self.view)[0]108 self.table.need()109 110 class ManageLink(grok.Viewlet):111 grok.viewletmanager(LeftSidebar)112 grok.context(IUniversity)113 grok.view(Index)114 grok.order(5)115 # This link is only displayed, if the user is116 # allowed to use it!117 grok.require('waeup.manageUniversity')118 119 def render(self):120 return u'<div class="portlet"><a href="manage">Settings</a></div>'121 122 class ManageFacultiesLink(grok.Viewlet):123 grok.viewletmanager(LeftSidebar)124 grok.context(IUniversity)125 grok.view(Index)126 grok.order(6)127 # This is so cool! This link is only displayed, when the user is128 # allowed to use it!129 grok.require('waeup.manageUniversity')130 131 def render(self):132 return u'<div class="portlet"><a href="faculties">Manage faculties</a></div>'133 134 class ManageUsersLink(grok.Viewlet):135 grok.viewletmanager(LeftSidebar)136 grok.context(IUniversity)137 grok.view(Index)138 grok.order(6)139 grok.require('waeup.manageUsers')140 141 def render(self):142 return u'<div class="portlet"><a href="users">Manage users</a></div>'143 144 class ManageDataCenter(grok.Viewlet):145 grok.viewletmanager(LeftSidebar)146 grok.context(IUniversity)147 grok.view(Index)148 grok.order(6)149 grok.require('waeup.manageUniversity')150 151 def render(self):152 return u'<div class="portlet"><a href="datacenter">Data Center</a></div>'
Note: See TracChangeset for help on using the changeset viewer.