Changeset 5006 for main/waeup.sirp/trunk
- Timestamp:
- 4 Feb 2010, 12:10:22 (15 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/tables.py
r5005 r5006 3 3 import grok 4 4 from waeup.sirp.interfaces import IUniversity 5 from waeup.sirp.university.interfaces import (6 IFacultyContainer, IFaculty, IDepartment, ICourseContainer)7 5 from waeup.sirp.widgets.interfaces import ITableProvider 8 6 from waeup.sirp.widgets.table import YUITable as Table 9 7 from waeup.sirp.widgets.table import Col 10 from zope.security.management import checkPermission11 8 12 9 class CodeAndTitleTableProvider(grok.Adapter): … … 49 46 return (self.table,) 50 47 51 class DepartmentTableProvider(CodeAndTitleTableProvider):52 grok.context(IFaculty)53 grok.provides(ITableProvider)54 title = 'Departments'55 56 class FacultyTableProvider(CodeAndTitleTableProvider):57 grok.context(IFacultyContainer)58 grok.provides(ITableProvider)59 title = 'Faculties'60 61 48 class UniversityTableProvider(CodeAndTitleTableProvider): 62 49 grok.context(IUniversity) … … 67 54 self.data_source = self.context.faculties 68 55 69 class CourseTableProvider(CodeAndTitleTableProvider):70 grok.context(IDepartment)71 grok.provides(ITableProvider)72 title = 'Courses'73 74 def prepare(self):75 self.data_source = self.context.courses76 77 def getTables(self, view=None):78 data = self.data_source79 context_url = ''80 if view:81 context_url = view.url(self.context) + '/'82 83 # Create a courses table...84 cols = (85 Col(86 header='Code', sortable=True,87 data = tuple([self.getItemURL(view, data[x].code)88 for x in data])),89 Col(90 header='Title', sortable=True,91 data = tuple([data[x].title for x in data])),92 )93 delcol = Col(header='', sortable=False,94 data = [95 '<form method="post">'96 '<input type="submit" name="delcourse" value="Delete" />'97 '<input type="hidden" name="code" value="%s" />'98 '</form>' % (data[x].code)99 for x in data])100 101 if checkPermission('waeup.manageUniversity', self.context.courses):102 cols = list(cols)103 cols.append(delcol)104 cols = tuple(cols)105 self.coursetable = Table('Courses', cols=cols)106 107 # Create a certificates table...108 self.data_source = self.context.certificates109 data = self.data_source110 certcols =(111 Col(112 header='Code', sortable=True,113 data = tuple([self.getItemURL(view, data[x].code)114 for x in data])),115 Col(116 header='Title', sortable=True,117 data = tuple([data[x].title for x in data])),118 )119 120 delcol = Col(header='', sortable=False,121 data = [122 '<form method="post">'123 '<input type="submit" name="delcert" value="Delete" />'124 '<input type="hidden" name="code" value="%s" />'125 '</form>' % (data[x].code)126 for x in data])127 128 if checkPermission('waeup.manageUniversity', self.context.certificates):129 certcols = list(certcols)130 certcols.append(delcol)131 certcols = tuple(certcols)132 133 self.certtable = Table('Certificates', cols=certcols)134 return (self.coursetable, self.certtable)135 136 class CourseContainerCourseTableProvider(CodeAndTitleTableProvider):137 grok.context(ICourseContainer)138 grok.provides(ITableProvider)139 title = 'Courses'140 141 def getTables(self, view=None):142 data = self.data_source143 context_url = ''144 if view:145 context_url = view.url(self.context) + '/'146 cols = (147 Col(148 header='Code', sortable=True,149 data = tuple([self.getItemURL(view, data[x].code)150 for x in data])),151 Col(152 header='Title', sortable=True,153 data = tuple([data[x].title for x in data])),154 )155 self.table = Table(self.title, cols=cols)156 return (self.table,)
Note: See TracChangeset for help on using the changeset viewer.