Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 81 lines (74 sloc) 2.814 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
from django import template
from news_and_events.models import NewsAndEventsPlugin
# from entity_tags import work_out_entity
from news_and_events.cms_plugins import CMSNewsAndEventsPlugin

#from django.template.defaultfilters import date

register = template.Library()
    
@register.inclusion_tag('arkestra/universal_plugin_lister.html', takes_context=True)
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
    
@register.inclusion_tag('arkestra/universal_plugin_lister.html', takes_context=True)
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
    

@register.inclusion_tag('arkestra/universal_plugin_lister.html', takes_context=True)
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
    
@register.inclusion_tag('event_index.html', takes_context=True)
def event_index(context):
    """
"""
    index_items = context["news_and_events"].events_index_items
    return {
        "index_items": index_items,
        "indexer": "start_date.year",
        }
Something went wrong with that request. Please try again.