def _group_action(self, id=None): if id is None: redirect(url(controller='search', obj_type='group')) group = Group.get(id) if group is None: abort(404) check_forum_setting(group) c.security_context = group c.object_location = group.location c.group = group c.group_menu_items = group_menu_items() c.breadcrumbs = [{'title': group.title, 'link': group.url()}] c.theme = group.location.get_theme() return method(self, group)
def set_up_context(self, id=None, category_id=None, thread_id=None): if id is not None: c.group = Group.get(id) if c.group is None: abort(404) c.group_id = c.group.group_id c.group_menu_items = group_menu_items() c.object_location = c.group.location c.security_context = c.group c.theme = c.group.location.get_theme() c.breadcrumbs.append({'title': c.group.title, 'link': c.group.url()}) else: c.group = None c.group_id = None if category_id is not None: try: category_id = int(category_id) except ValueError: abort(404) c.category = ForumCategory.get(category_id) if c.category is None: abort(404) c.breadcrumbs.append({'title': c.category.title, 'link': url(controller=c.controller, action='index', id=id, category_id=category_id)}) else: c.category = None if thread_id is not None: try: thread_id = int(thread_id) except ValueError: abort(404) c.thread = ForumPost.get(thread_id) if c.thread is None: abort(404) assert c.thread.category_id == int(c.category.id), repr(c.thread.category_id) else: c.thread = None
def _group_action(self, id, message_id, file_id): group = Group.get(id) if group is None: abort(404) message = meta.Session.query(GroupMailingListMessage).filter_by(id=message_id).first() if message is None: abort(404) if isinstance(file_id, basestring): file_id = re.search(r"\d*", file_id).group() file = File.get(file_id) if file is None: #not in group.files: ??? are mailing list files added as the group's files? abort(404) c.security_context = group c.object_location = group.location c.group = group c.group_menu_items = group_menu_items() c.breadcrumbs = [{'title': group.title, 'link': group.url()}] c.theme = group.location.get_theme() return method(self, group, message, file)
def _group_action(self, id, thread_id): group = Group.get(id) if group is None: abort(404) check_forum_setting(group) thread = meta.Session.query(GroupMailingListMessage).filter_by( id=thread_id).first() if (thread is None or thread.group != group): abort(404) if (thread.thread != thread and not thread.in_moderation_queue): abort(404) c.security_context = group c.group = group c.object_location = group.location c.group_menu_items = group_menu_items() c.breadcrumbs = [{'title': group.title, 'link': group.url()}] c.theme = group.location.get_theme() return method(self, group, thread)