class EmailViewActionsLinks(flourish.page.RefineLinksViewlet): """Email view actions links viewlet.""" body_template = InlineViewPageTemplate(""" <ul tal:attributes="class view/list_class"> <li tal:repeat="item view/renderable_items" tal:attributes="class item/class" tal:content="structure item/viewlet"> </li> </ul> """) # We don't want this manager rendered at all # if there are no renderable viewlets @property def renderable_items(self): result = [] for item in self.items: render_result = item['viewlet']() if render_result and render_result.strip(): result.append({ 'class': item['class'], 'viewlet': render_result, }) return result def render(self): if self.renderable_items: return super(EmailViewActionsLinks, self).render()
class ManageSchoolTertiaryNavigation(flourish.page.Content, flourish.page.TertiaryNavigationManager, ActiveSchoolYearContentMixin): template = InlineViewPageTemplate(""" <ul tal:attributes="class view/list_class" tal:condition="view/items"> <li tal:repeat="item view/items" tal:attributes="class item/class"> <a tal:attributes="href item/url" tal:content="item/schoolyear/@@title" /> </li> </ul> """) @property def items(self): result = [] active = self.schoolyear schoolyears = active.__parent__ if active is not None else {} for schoolyear in schoolyears.values(): url = '%s/%s?schoolyear_id=%s' % (absoluteURL( self.context, self.request), 'manage', schoolyear.__name__) css_class = schoolyear.first == active.first and 'active' or None result.append({ 'class': css_class, 'url': url, 'schoolyear': schoolyear, }) return result
class TermsTertiaryNavigationManager( flourish.page.TertiaryNavigationManager, ActiveSchoolYearContentMixin): template = InlineViewPageTemplate(""" <ul tal:attributes="class view/list_class"> <li tal:repeat="item view/items" tal:attributes="class item/class" tal:content="structure item/viewlet"> </li> </ul> """) @property def items(self): result = [] active = self.schoolyear schoolyears = active.__parent__ if active is not None else {} for schoolyear in schoolyears.values(): url = '%s/terms?schoolyear_id=%s' % ( absoluteURL(self.context, self.request), schoolyear.__name__) result.append({ 'class': schoolyear.first == active.first and 'active' or None, 'viewlet': u'<a href="%s">%s</a>' % (url, schoolyear.title), }) return result
class GroupManageActionsLinks(flourish.page.RefineLinksViewlet): """Manager for Action links in GroupView""" body_template = InlineViewPageTemplate(""" <ul tal:attributes="class view/list_class"> <li tal:repeat="item view/renderable_items" tal:attributes="class item/class" tal:content="structure item/viewlet"> </li> </ul> """) # We don't want this manager rendered at all # if there are no renderable viewlets @property def renderable_items(self): result = [] for item in self.items: render_result = item['viewlet']() if render_result and render_result.strip(): result.append({ 'class': item['class'], 'viewlet': render_result, }) return result def render(self): # This check is necessary because the user can be a leader # of the context group, which gives him schooltool.edit on it if canAccess(self.context.__parent__, '__delitem__'): if self.renderable_items: return super(GroupManageActionsLinks, self).render()
class CourseTableSchoolYear(flourish.viewlet.Viewlet): template = InlineViewPageTemplate(''' <input type="hidden" name="schoolyear_id" tal:define="schoolyear_id view/view/schoolyear/__name__|nothing" tal:condition="schoolyear_id" tal:attributes="value schoolyear_id" /> ''')
class FlourishCourseViewDoneLink(flourish.viewlet.Viewlet): template = InlineViewPageTemplate(''' <h3 class="done-link" i18n:domain="schooltool"> <a tal:attributes="href view/view/done_link" i18n:translate="">Done</a> </h3> ''')
class FlourishContactContainerView(flourish.page.Page): """A flourish Contact Container view.""" content_template = InlineViewPageTemplate(''' <div tal:content="structure context/schooltool:content/ajax/table" /> ''') @property def done_link(self): app = ISchoolToolApplication(None) return absoluteURL(app, self.request) + '/manage'
class ViewletManager(ViewletManagerBase): template = InlineViewPageTemplate(""" <tal:block repeat="viewlet view/viewlets"> <tal:block define="rendered viewlet; stripped rendered/strip|nothing" condition="stripped" content="structure stripped"> </tal:block> </tal:block> """) render = lambda self, *args, **kw: self.template(*args, **kw)
class CourseTableDoneLink(flourish.viewlet.Viewlet): template = InlineViewPageTemplate(''' <h3 tal:define="can_manage context/schooltool:app/schooltool:can_edit" class="done-link" i18n:domain="schooltool"> <tal:block condition="can_manage"> <a tal:attributes="href string:${context/schooltool:app/@@absolute_url}/manage" i18n:translate="">Done</a> </tal:block> <tal:block condition="not:can_manage"> <a tal:attributes="href request/principal/schooltool:person/@@absolute_url" i18n:translate="">Done</a> </tal:block> </h3> ''')
class TimetableDoneLink(ActiveSchoolYearContentMixin): template = InlineViewPageTemplate(''' <h3 class="done-link"> <a tal:attributes="href view/url" tal:content="view/title" /> </h3> ''') title = _('Done') @property def schoolyear(self): container = ITimetableContainer(self.context) return ISchoolYear(IHaveTimetables(container)) @property def url(self): app = ISchoolToolApplication(None) return self.url_with_schoolyear_id(app, view_name='timetables')
class FlourishCoursesView(table.table.TableContainerView, ActiveSchoolYearContentMixin): content_template = InlineViewPageTemplate(''' <div> <tal:block content="structure view/container/schooltool:content/ajax/table" /> </div> ''') @property def title(self): schoolyear = self.schoolyear return _('Courses for ${schoolyear}', mapping={'schoolyear': schoolyear.title}) @property def container(self): schoolyear = self.schoolyear return ICourseContainer(schoolyear)
class FlourishGroupsView(flourish.page.Page, ActiveSchoolYearContentMixin): content_template = InlineViewPageTemplate(''' <div tal:content="structure context/schooltool:content/ajax/view/container/table" /> ''') @property def title(self): schoolyear = self.schoolyear return _('Groups for ${schoolyear}', mapping={'schoolyear': schoolyear.title}) @Lazy def container(self): schoolyear = self.schoolyear return IGroupContainer(schoolyear) def __call__(self, *args, **kw): if not flourish.canView(self.container): raise Unauthorized("No permission to view groups.") return flourish.page.Page.__call__(self, *args, **kw)
class Table(flourish.ajax.CompositeAJAXPart, TableContent): no_default_url_cell_formatter = False container_wrapper = ViewPageTemplateFile('templates/f_ajax_table.pt') form_wrapper = InlineViewPageTemplate(""" <form method="post" tal:attributes="action view/@@absolute_url; class view/form_class; id view/form_id"> <tal:block replace="structure view/template" /> </form> """) empty_message = u"" form_class = None form_id = None table_formatter = AJAXFormSortFormatter inside_form = False # don't surround with <form> tag if inside_form @Lazy def html_id(self): return flourish.page.generic_viewlet_html_id(self, self.prefix) @Lazy def filter_widget(self): return self.get('filter') @Lazy def batch(self): return self.get('batch') def updateFormatter(self): if self._table_formatter is not None: return if self.no_default_url_cell_formatter: formatters = [] else: formatters = [url_cell_formatter] self.setUp(formatters=formatters, table_formatter=self.table_formatter, batch_size=self.batch_size, prefix=self.__name__, css_classes={'table': 'data'}) def update(self): self.updateFormatter() TableContent.update(self) flourish.ajax.CompositeAJAXPart.update(self) def makeFormatter(self): if self._table_formatter is None: return None formatter = self._table_formatter( self.source, self.request, self._items, visible_column_names=self.visible_column_names, columns=self._columns, batch_start=self.batch.start, batch_size=self.batch.size, sort_on=self._sort_on, prefix=self.prefix, ignore_request=self.ignoreRequest, group_by_column=self.group_by_column, ) formatter.html_id = self.html_id formatter.view = self formatter.cssClasses.update(dict(self.css_classes)) return formatter def renderTable(self): formatter = self.makeFormatter() return formatter() if formatter is not None else '' def render(self, *args, **kw): content = '' if self.inside_form: content = self.template(*args, **kw) else: content = self.form_wrapper(*args, **kw) if self.fromPublication: return content zc.resourcelibrary.need('schooltool.table') return self.container_wrapper(content=content)
class FlourishResourcesView(flourish.page.Page): content_template = InlineViewPageTemplate(''' <div tal:content="structure context/schooltool:content/ajax/table" /> ''')
class CourseActivityAddTertiaryNavigationManager( flourish.page.TertiaryNavigationManager): template = InlineViewPageTemplate("")