def news_and_events(context, display="news-and-events", heading=3, format="details", current_or_archive="current", max_items=None, order_by="importance/date", entity=None): """ Depends on Cardiff's row/column CSS Publishes a date-ordered list of news and events """ instance = NewsAndEventsPlugin() if not entity: entity = work_out_entity(context, entity) instance.order_by = order_by instance.entity = entity instance.heading_level = heading instance.display = display instance.limit_to = max_items instance.format = format instance.layout = "sidebyside" instance.current_or_archive = current_or_archive instance.show_more_items = False # because we know that these hardcoded lists don't require it CMSNewsAndEventsPlugin().render(context, instance, None) return context
def events(self): instance = CMSNewsAndEventsPlugin() instance.display = "events" instance.order_by = "date" instance.format = "details" instance.type = "for_place" instance.place = self instance.show_venue = False events = get_news_and_events(instance) return events
def events(self): from news_and_events.models import NewsAndEventsPlugin # invoke the plugin to find out more instance = NewsAndEventsPlugin() instance.display = "events" instance.type = "for_place" instance.place = self instance.view = "current" instance.format = "details image" # create an instance of the plugin to see if the menu should have items plugin = CMSNewsAndEventsPlugin() plugin.get_items(instance) plugin.add_links_to_other_items(instance) plugin.set_image_format(instance) plugin.set_limits_and_indexes(instance) instance.lists = plugin.lists return instance
def person_events(context): """ Depends on Cardiff's row/column CSS Publishes a date-ordered list of news and events """ instance = NewsAndEventsPlugin() instance.type = "for_person" instance.heading_level = 3 instance.display = "events" instance.view = "all_forthcoming" instance.order_by = "date" instance.format = "details" instance.show_images = False instance.person = context["person"] # get_news_and_events(instance) CMSNewsAndEventsPlugin().render(context, instance, None) return context
def place_events(context): """ Depends on Cardiff's row/column CSS Publishes a date-ordered list of news and events """ instance = NewsAndEventsPlugin() instance.type = "for_place" instance.display = "events" instance.view = "current" instance.order_by = "date" instance.format = "details" instance.show_images = False instance.limit_to = None instance.show_venue = False instance.place = context["place"] # get_news_and_events(instance) CMSNewsAndEventsPlugin().render(context, instance, None) return context
def recursive(self, request, nodes): for child in nodes: try: ancestor = child.ancestor except AttributeError: ancestor = False try: selected = child.selected except AttributeError: selected = False # expand branches selectvely, or expand all if selected or ancestor or EXPAND_ALL_MENU_BRANCHES: # does the entity have an entity? try: page = Page.objects.get(id=child.id, entity__isnull=False) entity = page.entity.all()[0] # does this entity have a news page? if entity.auto_news_page and "news" in menu_tests: # invoke the plugin to find out more instance = NewsAndEventsPlugin() instance.entity = entity instance.type = "menu" instance.limit_to = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH instance.view = "current" context = RequestContext(request) # create an instance of the plugin to see if the menu should have items plugin = CMSNewsAndEventsPlugin() plugin.get_items(instance) plugin.add_links_to_other_items(instance) # assume there's no menu item required show_menu_item = False menutitle = entity.news_page_menu_title # create a new node new_node = NavigationNode( mark_safe(menutitle), entity.get_related_info_page_url('news-and-events'), None ) # go through the lists of items for item in plugin.lists: if item["items"]: show_menu_item = True # and go through the other_items lists for each for other_item in item["other_items"]: new_sub_node = NavigationNode( mark_safe(other_item["title"]), other_item["link"], None ) if request.page_path == new_sub_node.get_absolute_url(): new_sub_node.selected = True new_node.selected = False show_menu_item = True new_node.children.append(new_sub_node) if show_menu_item: # is this node the one we are currently looking at? if new_node.get_absolute_url() == request.page_path: new_node.selected = True child.selected = False child.children.append(new_node) if entity.auto_contacts_page and "contacts" in menu_tests: menutitle = entity.contacts_page_menu_title new_node = NavigationNode(mark_safe(menutitle), entity.get_related_info_page_url('contact'), None) if new_node.get_absolute_url() in request.page_path: new_node.selected = True child.selected=False child.children.append(new_node) if getattr(entity, "auto_vacancies_page", None) and "vacancies" in menu_tests: instance = VacanciesPlugin() instance.entity = entity instance.type = "menu" instance.limit_to = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH instance.view = "current" context = RequestContext(request) # create an instance of the plugin to see if the menu should have items plugin = CMSVacanciesPlugin() plugin.get_items(instance) plugin.add_links_to_other_items(instance) # assume there's no menu item required show_menu_item = False # are there actually any vacancies/studentships items to show? if not, no menu for item in plugin.lists: if item["items"]: show_menu_item = True if show_menu_item: print "menu" print plugin.lists menutitle = entity.vacancies_page_menu_title new_node = NavigationNode(mark_safe(menutitle), entity.get_related_info_page_url('vacancies-and-studentships'), None) if request.page_path == new_node.get_absolute_url(): new_node.selected = True child.selected=False child.children.append(new_node) if getattr(entity, "auto_publications_page", None) and entity.auto_publications_page and "publications" in menu_tests: menutitle = entity.publications_page_menu_title new_node = NavigationNode(mark_safe(menutitle), entity.get_related_info_page_url('publications'), None) if request.page_path == new_node.get_absolute_url(): new_node.selected = True child.selected=False child.children.append(new_node) except Page.DoesNotExist: pass self.recursive(request, child.children)