コード例 #1
0
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
コード例 #2
0
ファイル: views.py プロジェクト: ojii/Arkestra
def common_settings(request, slug):
    # general values - entity, request, template
    entity = Entity.objects.get(slug=slug) or default_entity
    request.current_page = entity.get_website() # for the menu, so it knows where we are
    context = RequestContext(request)
    instance = NewsAndEventsPlugin()
    instance.limit_to = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
    instance.default_limit = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
    instance.order_by = "importance/date"
    instance.entity = entity
    instance.heading_level = IN_BODY_HEADING_LEVEL
    instance.display = "news-and-events"
    instance.format = "details image"
    instance.layout = layout
    instance.view = "current"
    return instance, context, entity
コード例 #3
0
ファイル: views.py プロジェクト: stefanfoulis/Arkestra
def common_settings(request, slug = default_entity.slug):
    # general values - entity, request, template
    entity = Entity.objects.get(slug=slug)
    # request.current_page = entity.get_website() # for the menu, so it knows where we are
    request.current_page = default_entity.get_website()
    context = RequestContext(request)
    instance = NewsAndEventsPlugin()
    instance.limit_to = news_and_events_list_default_limit
    instance.default_limit = news_and_events_list_default_limit
    instance.order_by = "importance/date"
    instance.entity = entity
    instance.heading_level = h_main_body
    instance.display = "news-and-events"
    instance.format = "details"
    instance.layout = "sidebyside"
    instance.view = "current"
    return instance, context, entity
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
ファイル: menu.py プロジェクト: ojii/Arkestra
    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
    
            if selected or ancestor:
                # 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 = "main_page"
                        instance.limit_to = news_and_events_list_default_limit
                        instance.view = "current"
                        get_news_and_events(instance)
                        
                        # are there actually any new/events items to show? if not, no menu
                        if instance.news or instance.other_news or instance.events or instance.other_events:
                        
                            menutitle = entity.news_page_menu_title
                            new_node = NavigationNode(mark_safe(menutitle), entity.get_related_info_page_url('news-and-events'), None)
                            if new_node.get_absolute_url() in request.page_path:

                                new_node.selected = True
                                child.selected=False

                                if instance.other_news  and "news_archive" in menu_tests:
                                    new_sub_node = NavigationNode(mark_safe("News archive"), entity.get_related_info_page_url('news-archive'), None )
                                    if request.page_path == new_sub_node.get_absolute_url():
                                        new_sub_node.selected = True
                                        new_node.selected=False
                                    new_node.children.append(new_sub_node)

                                if any("all-forthcoming" in d.itervalues() for d in instance.other_events) and "forthcoming_events" in menu_tests:
                                    new_sub_node = NavigationNode(mark_safe("All forthcoming events"), entity.get_related_info_page_url('forthcoming-events'), None )
                                    if request.page_path == new_sub_node.get_absolute_url():
                                        new_sub_node.selected = True
                                        new_node.selected=False
                                    new_node.children.append(new_sub_node)
                
                                if any("previous-events" in d.itervalues() for d in instance.other_events) and "previous_events" in menu_tests:
                                    new_sub_node = NavigationNode(mark_safe("Previous events"), entity.get_related_info_page_url('previous-events'), None )
                                    if request.page_path == new_sub_node.get_absolute_url():
                                        new_sub_node.selected = True
                                        new_node.selected=False
                                    new_node.children.append(new_sub_node)

                            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:
                        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)
コード例 #8
0
ファイル: menu.py プロジェクト: airtonix/Arkestra
    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)