def _get_items(self): formatter = self.get_date_formatter("date", "long") trusted = removeSecurityProxy(self.context) user_id = trusted.user_id office_list = [] if interfaces.IMemberOfParliament.providedBy(self.context): parliament_id = trusted.group_id else: parliament = get_parliament_for_group_id(trusted.group_id) if parliament: parliament_id = parliament.parliament_id else: return office_list for oh in get_groups_held_for_user_in_parliament(user_id, parliament_id): title = {} # !+FULL_NAME(mr, oct-2010) this should probably make use of # the GroupDescriptor (combined) listing Field full_name title["group"] = "%s - %s" % (_(oh[0]), oh[1] and _(oh[1]) or "") title["group_type"] = _(oh[2]) if oh[3]: title["member_title"] = _(oh[3]) else: title["member_title"] = _(u"Member") title["start_date"] = None if oh[4]: title["start_date"] = formatter.format(oh[4]) elif oh[6]: title["start_date"] = formatter.format(oh[6]) title["end_date"] = None if oh[5]: title["end_date"] = formatter.format(oh[5]) elif oh[7]: title["end_date"] = formatter.format(oh[7]) office_list.append(title) return office_list
def update(self): """ refresh the query """ trusted = removeSecurityProxy(self.context) user_id = trusted.user_id if interfaces.IMemberOfParliament.providedBy(self.context): parliament_id = trusted.group_id else: parliament = get_parliament_for_group_id(trusted.group_id) if parliament: parliament_id = parliament.parliament_id self.offices_held = get_offices_held_for_user_in_parliament( user_id, parliament_id)
def get_group_context(context): if interfaces.IOffice.providedBy(context): return get_parliament_for_group_id(context.group_id) else: return context