def render(self, date, template=None): #need('yui-editor') need('yui-rte') need('yui-resize') need('yui-button') if template is None: template = self.template container = self.context.__parent__ #schedule_url = self.request.getURL() container_url = url.absoluteURL(container, self.request) # determine position in container key = stringKey(self.context) keys = list(container.keys()) pos = keys.index(key) links = {} if pos > 0: links['previous'] = "%s/%s/%s" % (container_url, keys[pos - 1], self.__name__) if pos < len(keys) - 1: links['next'] = "%s/%s/%s" % (container_url, keys[pos + 1], self.__name__) #start_date = utils.datetimedict.fromdatetime(self.context.start_date) #end_date = utils.datetimedict.fromdatetime(self.context.end_date) site_url = url.absoluteURL(getSite(), self.request) return template( display="sitting", #title=_(u"$A $e, $B $Y", mapping=start_date), title="%s: %s - %s" % (self.context.group.short_name, self.context.start_date.strftime('%Y-%m-%d %H:%M'), self.context.end_date.strftime('%H:%M')), description=_( u"$type — ${start}-${end}", mapping={ 'start': self.context.start_date.strftime('%Y-%m-%d %H:%M'), 'end': self.context.end_date.strftime('%H:%M') }), # title = u"", # description = u"", # links=links, actions=get_sitting_actions(self.context, self.request), items=get_sitting_items(self.context, self.request, include_actions=True), #categories=vocabulary.ItemScheduleCategories(self.context), new_category_url="%s/admin/content/categories/add?next_url=..." % site_url, status=self.context.status, )
def render(self, date, template=None): #need('yui-editor') need('yui-rte') need('yui-resize') need('yui-button') if template is None: template = self.template container = self.context.__parent__ #schedule_url = self.request.getURL() container_url = url.absoluteURL(container, self.request) # determine position in container key = stringKey(self.context) keys = list(container.keys()) pos = keys.index(key) links = {} if pos > 0: links['previous'] = "%s/%s/%s" % ( container_url, keys[pos-1], self.__name__) if pos < len(keys) - 1: links['next'] = "%s/%s/%s" % ( container_url, keys[pos+1], self.__name__) #start_date = utils.datetimedict.fromdatetime(self.context.start_date) #end_date = utils.datetimedict.fromdatetime(self.context.end_date) site_url = url.absoluteURL(getSite(), self.request) return template( display="sitting", #title=_(u"$A $e, $B $Y", mapping=start_date), title = "%s: %s - %s" % (self.context.group.short_name, self.context.start_date.strftime('%Y-%m-%d %H:%M'), self.context.end_date.strftime('%H:%M')), description=_(u"$type — ${start}-${end}", mapping={ 'start': self.context.start_date.strftime('%Y-%m-%d %H:%M'), 'end': self.context.end_date.strftime('%H:%M') }), # title = u"", # description = u"", # links=links, actions=get_sitting_actions(self.context, self.request), items=get_sitting_items( self.context, self.request, include_actions=True), #categories=vocabulary.ItemScheduleCategories(self.context), new_category_url="%s/admin/content/categories/add?next_url=..." % site_url, status=self.context.status, )
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in get_states("groupsitting", keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map( removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) site_url = url.absoluteURL(getSite(), request) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or \ IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None info = IWorkflowInfo(item, None) state_title = info.workflow().workflow.states[item.status].title record = { 'title': props.title, 'description': props.description, 'name': stringKey(scheduling), 'status': item.status, 'type': item.type.capitalize, 't':item.type, 'state_title': state_title, #'category_id': scheduling.category_id, #'category': scheduling.category, 'discussion': discussion, 'delete_url': "%s/delete" % url.absoluteURL(scheduling, request), 'url': url.set_url_context(site_url+('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id)))} if include_actions: record['actions'] = get_scheduling_actions(scheduling, request) record['workflow'] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record['discussion_action'] = discussion_actions[0] else: record['discussion_action'] = None items.append(record) return items
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in get_states("groupsitting", keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map(removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) site_url = url.absoluteURL(getSite(), request) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or \ IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None info = IWorkflowInfo(item, None) state_title = info.workflow().workflow.states[item.status].title record = { 'title': props.title, 'description': props.description, 'name': stringKey(scheduling), 'status': item.status, 'type': item.type.capitalize, 't': item.type, 'state_title': state_title, #'category_id': scheduling.category_id, #'category': scheduling.category, 'discussion': discussion, 'delete_url': "%s/delete" % url.absoluteURL(scheduling, request), 'url': url.set_url_context(site_url + ('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id))) } if include_actions: record['actions'] = get_scheduling_actions(scheduling, request) record['workflow'] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record['discussion_action'] = discussion_actions[0] else: record['discussion_action'] = None items.append(record) return items