Permalink
Browse files

rationalising plugin lists

  • Loading branch information...
1 parent 452bae5 commit e4eb9f9901a115da6024bf7ae8f2a76279405f11 @evildmp committed Jul 13, 2011
View
6 arkestra_utilities/templates/arkestra/universal_plugin_lister.html
@@ -2,7 +2,7 @@
{% for list in everything.lists %}
{% if list.items or list.other_items %}
- {% include list.index_file %}
+ {% include "arkestra/universal_date_index.html" %}
<div class = "{{ list.div_class }}">
{% if everything.heading_level %}
@@ -16,14 +16,14 @@
<li class="grouper {{get_when.grouper|slugify}}" id ="{{get_when.grouper|slugify}}">{{ get_when.grouper }}
<ul>
{% for item in get_when.list %}
- {% include list.item_file %}
+ {% include "arkestra/universal_plugin_list_item.html" %}
{% endfor %}
</ul>
</li>
{% endfor %}
{% else %}
{% for item in list.items %}
- {% include list.item_file %}
+ {% include "arkestra/universal_plugin_list_item.html" %}
{% endfor %}
{% endif %}
</ul>
View
129 arkestra_utilities/universal_plugin_lists.py
@@ -0,0 +1,129 @@
+class UniversalPlugin(object):
+ def __init__(self, model = None, admin_site = None):
+ self.lists = []
+ super(UniversalPlugin, self).__init__(model, admin_site)
+
+ def set_defaults(self, instance):
+ # set defaults
+ instance.view = getattr(instance, "view", "current")
+ return
+
+ def add_link_to_main_page(self, instance):
+ if instance.type == "plugin" or instance.type == "sub_page":
+ if (any(d['items'] for d in self.lists)) and getattr(instance.entity, self.auto_page_attribute, False):
+ instance.link_to_main_page = instance.entity.get_related_info_page_url(self.auto_page_slug)
+ instance.main_page_name = getattr(instance.entity, self.auto_page_menu_title, "")
+
+ def print_settings(self):
+ print "---- plugin settings ----"
+ print "self.display", self.display
+ print "self.view", self.view
+ print "self.order_by", self.order_by
+ print "self.group_dates", self.group_dates
+ print "self.format", self.format
+ print "self.list_format", self.list_format
+ print "self.limit_to", self.limit_to
+ print "self.layout", self.layout
+
+ def add_links_to_other_items(self, instance):
+ if instance.type == "main_page" or instance.type == "sub_page":
+ for this_list in self.lists:
+ this_list["links_to_other_items"](instance, this_list)
+
+ def news_style_other_links(self, instance, this_list):
+ if this_list["items"] and instance.view == "current":
+ all_items_count = len(this_list["items"])
+ if instance.limit_to and all_items_count > instance.limit_to:
+ this_list["other_items"] = [{
+ "link":instance.entity.get_related_info_page_url("news-archive"),
+ "title":"news archive",
+ "count": all_items_count,}]
+ return this_list
+
+ def events_style_other_links(self, instance, this_list):
+ this_list["other_items"] = []
+ if instance.view == "current":
+
+ if instance.previous_events or instance.forthcoming_events:
+ if instance.limit_to and len(instance.events) > instance.limit_to:
+ if instance.forthcoming_events.count() > instance.limit_to:
+ this_list["other_items"].append({
+ "link":instance.entity.get_related_info_page_url("forthcoming-events"),
+ "title":"all forthcoming events",
+ "count": instance.forthcoming_events.count(),}
+ )
+ if instance.previous_events:
+ this_list["other_items"].append({
+ "link":instance.entity.get_related_info_page_url("previous-events"),
+ "title":"previous events",
+ "count": instance.previous_events.count(),}
+ )
+
+ elif instance.view == "archive":
+
+ if instance.forthcoming_events:
+ this_list["other_items"] = [{
+ "link":instance.entity.get_related_info_page_url("forthcoming-events"),
+ "title":"all forthcoming events",
+ "count": instance.forthcoming_events.count(),}]
+ return this_list
+
+ def set_limits_and_indexes(self, instance):
+ for this_list in self.lists:
+
+ if this_list["items"] and len(this_list["items"]) > instance.limit_to:
+ this_list["items"] = this_list["items"][:instance.limit_to]
+
+ this_list["index_items"] = [item for item in this_list["items"] if not getattr(item, 'sticky', False)] # put non-top items in it
+ this_list["no_of_get_whens"] = len(set(item.get_when() for item in this_list["index_items"]))
+ if instance.type == "sub_page" and this_list["no_of_get_whens"] > 1: # more than 1 get_when()?
+ this_list["index"] = True # show an index
+ this_list["show_when"] = instance.group_dates and not ("horizontal" in instance.list_format or this_list["no_of_get_whens"] < 2)
+
+ def determine_layout_settings(self, instance):
+ """
+ Sets:
+ image_size
+ list_format
+
+
+ """
+ if "image" in instance.format:
+ instance.image_size = (75,75)
+
+ # set columns for horizontal lists
+ if "horizontal" in instance.list_format:
+ instance.list_format = "row columns" + str(instance.limit_to) + " " + instance.list_format
+
+ for this_list in self.lists:
+ if this_list["items"]:
+ for item in this_list["items"]:
+ item.column_class = "column"
+ this_list["items"][0].column_class = this_list["items"][0].column_class + " firstcolumn"
+ this_list["items"][-1].column_class = this_list["items"][-1].column_class + " lastcolumn"
+
+ elif "vertical" in instance.format:
+ instance.list_format = "row columns1"
+
+ def set_layout_classes(self, instance):
+ """
+ Lays out the plugin's news and events divs
+ """
+ instance.row_class="row"
+ # if news and events will be side-by-side
+ if instance.layout == "sidebyside":
+ if len(self.lists) > 1:
+ instance.row_class=instance.row_class+" columns" + str(len(self.lists))
+ self.lists[0]["div_class"] = "column firstcolumn"
+ self.lists[-1]["div_class"] = "column lastcolumn"
+ # if just news or events, and it needs an index
+ else:
+ for this_list in self.lists:
+ if this_list.get("index"):
+ instance.row_class=instance.row_class+" columns3"
+ instance.index_div_class = "column lastcolumn"
+ this_list["div_class"] = "column firstcolumn doublecolumn"
+ # and if it doesn't need an index
+ else:
+ instance.row_class=instance.row_class+" columns1"
+
View
39 arkestra_utilities/universal_plugin_models.py
@@ -0,0 +1,39 @@
+# from django.db import models
+# from django.conf import settings
+#
+# PLUGIN_HEADING_LEVELS = settings.PLUGIN_HEADING_LEVELS
+# PLUGIN_HEADING_LEVEL_DEFAULT = settings.PLUGIN_HEADING_LEVEL_DEFAULT
+#
+# class UniversalPluginOptions(models.Model):
+# class Meta:
+# abstract = True
+# LAYOUTS = (
+# ("sidebyside", u"Side-by-side"),
+# ("stacked", u"Stacked"),
+# )
+# layout = models.CharField("Plugin layout", max_length=25, choices = LAYOUTS, default = "sidebyside")
+# FORMATS = (
+# ("title", u"Title only"),
+# ("details image", u"Details"),
+# )
+# format = models.CharField("Item format", max_length=25,choices = FORMATS, default = "details image")
+# heading_level = models.PositiveSmallIntegerField(choices = PLUGIN_HEADING_LEVELS, default = PLUGIN_HEADING_LEVEL_DEFAULT)
+# ORDERING = (
+# ("date", u"Date alone"),
+# ("importance/date", u"Importance & date"),
+# )
+# order_by = models.CharField(max_length = 25, choices=ORDERING, default="importance/date")
+# LIST_FORMATS = (
+# ("vertical", u"Vertical"),
+# ("horizontal", u"Horizontal"),
+# )
+# list_format = models.CharField("List format", max_length = 25, choices=LIST_FORMATS, default="vertical")
+# group_dates = models.BooleanField("Show date groups", default = True)
+# limit_to = models.PositiveSmallIntegerField("Maximum number of items", default = 5, null = True, blank = True,
+# help_text = u"Leave blank for no limit")
+#
+# def sub_heading_level(self): # requires that we change 0 to None in the database
+# if self.heading_level == None: # this means the user has chosen "No heading"
+# return 6 # we need to give sub_heading_level a value
+# else:
+# return self.heading_level + 1 # so if headings are h3, sub-headings are h4
View
41 news_and_events/cms_plugins.py
@@ -1,8 +1,9 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
-from models import NewsAndEventsPlugin
+from models import NewsAndEventsPlugin, NewsArticle, Event
from django.utils.translation import ugettext as _
from django import forms
+from arkestra_utilities.universal_plugin_lists import UniversalPlugin
from contacts_and_people.templatetags.entity_tags import work_out_entity
from functions import get_news_and_events
@@ -30,14 +31,16 @@ def clean(self):
return self.cleaned_data
-class CMSNewsAndEventsPlugin(AutocompleteMixin, CMSPluginBase):
+class CMSNewsAndEventsPlugin(UniversalPlugin, AutocompleteMixin, CMSPluginBase):
model = NewsAndEventsPlugin
name = _("News & events")
text_enabled = True
form = NewsAndEventsPluginForm
render_template = "arkestra/universal_plugin_lister.html"
admin_preview = False
-
+ auto_page_attribute = "auto_news_page"
+ auto_page_slug = "news-and-events"
+ auto_page_menu_title = "news_page_menu_title"
fieldsets = (
(None, {
'fields': (('display', 'layout', 'list_format',), ( 'format', 'order_by', 'group_dates',), 'limit_to')
@@ -48,19 +51,37 @@ class CMSNewsAndEventsPlugin(AutocompleteMixin, CMSPluginBase):
}),
)
-
# autocomplete fields
related_search_fields = ['entity',]
def render(self, context, instance, placeholder):
- #print self.render_template
+ self.set_defaults(instance)
+
instance.entity = getattr(instance, "entity", None) or work_out_entity(context, None)
instance.type = getattr(instance, "type", "plugin")
- try:
- render_template = instance.render_template
- except AttributeError:
- pass
- get_news_and_events(instance)
+ render_template = getattr(instance, "render_template", "")
+
+ if "news" in instance.display:
+ this_list = {"model": NewsArticle,}
+ this_list["items"] = NewsArticle.objects.get_items(instance)
+ this_list["links_to_other_items"] = self.news_style_other_links
+ this_list["heading_text"] = instance.news_heading_text
+ self.lists.append(this_list)
+
+ if "events" in instance.display:
+ this_list = {"model": Event,}
+ this_list["items"] = Event.objects.get_items(instance)
+ this_list["links_to_other_items"] = self.events_style_other_links
+ this_list["heading_text"] = instance.events_heading_text
+ self.lists.append(this_list)
+
+ self.add_link_to_main_page(instance)
+ self.add_links_to_other_items(instance)
+ self.set_limits_and_indexes(instance)
+ self.determine_layout_settings(instance)
+ self.set_layout_classes(instance)
+ instance.lists = self.lists
+
context.update({
'everything': instance,
'placeholder': placeholder,
View
2 news_and_events/functions.py
@@ -49,7 +49,7 @@ def get_news_and_events(instance):
events_index_items
"""
print
- print "___________________________ Getting news and events _______________________"
+ print "___________________________ Getting news and events from functions.get_news_and_events() _______________________"
print
set_defaults(instance) # initialise some variables
print_settings(instance)
View
210 news_and_events/managers.py
@@ -0,0 +1,210 @@
+from django.db import models
+from django.db.models import Q
+from django.conf import settings
+from datetime import datetime
+import operator
+
+MULTIPLE_ENTITY_MODE = settings.MULTIPLE_ENTITY_MODE
+COLLECT_TOP_ALL_FORTHCOMING_EVENTS = settings.COLLECT_TOP_ALL_FORTHCOMING_EVENTS
+
+class NewsArticleManager(models.Manager):
+ def get_news_ordered_by_importance_and_date(self, instance):
+ ordinary_news = []
+
+ # split the within-date items for this entity into two sets
+ publishable_news = self.get_publishable_news(instance)
+ sticky_news = publishable_news.order_by('-importance').filter(
+ Q(hosted_by=instance.entity) | Q(is_sticky_everywhere = True),
+ sticky_until__gte=datetime.today(),
+ )
+ non_sticky_news = publishable_news.exclude(
+ Q(hosted_by=instance.entity) | Q(is_sticky_everywhere = True),
+ sticky_until__gte=datetime.today(),
+ )
+ print "Sticky news", sticky_news.count()
+ print "Non-sticky news", non_sticky_news.count()
+ top_news = list(sticky_news)
+
+ # now we have to go through the non-top items, and find any that can be promoted
+ # get the set of dates where possible promotable items can be found
+ dates = non_sticky_news.dates('date', 'day').reverse()
+ print "Going through the date set"
+ for date in dates:
+ print " examining possibles from", date
+ # get all non-top items from this date
+ possible_top_news = non_sticky_news.filter(date__year=date.year, date__month= date.month, date__day= date.day)
+ # promotable items have importance > 0
+ print " found", possible_top_news.count(), "of which I will promote", possible_top_news.filter(Q(hosted_by=instance.entity) | Q(is_sticky_everywhere = True),importance__gte = 1).count()
+ # add the good ones to the top news list
+ top_news.extend(possible_top_news.filter(
+ Q(hosted_by=instance.entity) | Q(is_sticky_everywhere = True),
+ importance__gte = 1)
+ )
+ # if this date set contains any unimportant items, then there are no more to promote
+ demotable_items = possible_top_news.exclude(
+ Q(hosted_by=instance.entity) | Q(is_sticky_everywhere = True),
+ importance__gte = 1
+ )
+ if demotable_items.count() > 0:
+ # put those unimportant items into ordinary news
+ ordinary_news.extend(demotable_items)
+ print " demoting", demotable_items.count()
+ # and stop looking for any more
+ break
+ # and add everything left in non-sticky news before this date
+ if dates:
+ remaining_items = non_sticky_news.filter(date__lte=date)
+ print " demoting the remaining", remaining_items.count()
+ ordinary_news.extend(remaining_items)
+ for item in top_news:
+ item.sticky = True
+ print "Top news", len(top_news)
+ print "Ordinary news", len(ordinary_news)
+ ordinary_news.sort(key=operator.attrgetter('date'), reverse = True)
+ return top_news, ordinary_news
+
+ def get_publishable_news(self, instance):
+ # returns news items that can be published, latest news first
+ publishable_news = self.get_all_news(instance) \
+ .filter(date__lte = datetime.today()) \
+ .order_by('-date')
+ return publishable_news
+
+
+ def get_all_news(self, instance):
+ # returns every news item associated with this entity,
+ # or all news items if MULTIPLE_ENTITY_MODE is False, or instance.entity is unspecified
+ if MULTIPLE_ENTITY_MODE and instance.entity:
+ all_news = self.model.objects.filter(
+ Q(hosted_by=instance.entity) | Q(publish_to=instance.entity)
+ ).distinct()
+ else:
+ all_news = NewsArticle.objects.all()
+ print "All news", all_news.count()
+ return all_news
+
+ def get_items(self, instance):
+ if instance.order_by == "importance/date":
+ top_news, ordinary_news = self.get_news_ordered_by_importance_and_date(instance)
+ instance.news = top_news + ordinary_news
+ else:
+ instance.news = self.get_publishable_news(instance)
+ return instance.news
+
+
+class EventManager(models.Manager):
+ def get_events_ordered_by_importance_and_date(self, instance):
+ """
+ When we need more than just a simple list-by-date, this keeps the top items separate
+ """
+ print "____ get_events_ordered_by_importance_and_date() ____"
+ ordinary_events = []
+ # split the within-date items for this entity into two sets
+ actual_events = instance.forthcoming_events
+ # top_events jump the queue
+ top_events = actual_events.filter(
+ Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),
+ jumps_queue_on__lte=datetime.today(), jumps_queue_on__isnull=False,
+ ).order_by('importance').reverse()
+ # non_top events are the rest
+ non_top_events = actual_events.exclude(
+ Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),
+ jumps_queue_on__lte=datetime.today(), jumps_queue_on__isnull=False,
+ )
+ print "Queue-jumping top events", top_events
+ print "Non top events", non_top_events.count()
+
+ # now we have to go through the non-top items, and find any that can be promoted to top_events
+ # get the set of dates where possible promotable items can be found
+ dates = non_top_events.dates('start_date', 'day')
+ print "Going through the date set"
+ for date in dates:
+ print " examining possibles from", date
+ # get all non-top items from this date
+ possible_top_events = non_top_events.filter(
+ start_date = date)
+ # promotable items have importance > 0
+ print " found", possible_top_events.count(), "of which I will promote", possible_top_events.filter(Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),importance__gte = 1).count()
+ # promote the promotable items
+ list(top_events).extend(possible_top_events.filter(Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),importance__gte = 1))
+ top_events = top_events | possible_top_events.filter(Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),importance__gte = 1)
+ # print top_events | possible_top_events.filter(Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),importance__gte = 1))
+ # if this date set contains any unimportant items, then there are no more to promote
+ demotable_items = possible_top_events.exclude(Q(hosted_by=instance.entity) | Q(jumps_queue_everywhere = True),importance__gte = 1)
+ if demotable_items.count() > 0:
+ # put those unimportant items into ordinary news
+ ordinary_events = demotable_items
+ print " demoting", demotable_items.count()
+ # and stop looking for any more
+ break
+ # and everything left in non-top items after this date
+ if dates:
+ remaining_items = non_top_events.filter(start_date__gt=date)
+ print " demoting the remaining", remaining_items.count()
+ ordinary_events = ordinary_events | remaining_items
+ top_events = top_events
+ ordinary_events = list(ordinary_events)
+ for item in top_events:
+ item.sticky = True
+
+ print "Top events after processing", len(top_events), top_events
+ print "Ordinary events", len(ordinary_events)
+ # ordinary_events.sort(key=operator.attrgetter('start_date'))
+ instance.top_events, instance.ordinary_events = list(top_events), ordinary_events
+ return
+
+ def get_events(self, instance):
+ """
+ returns forthcoming_events, previous_events, series_events
+ """
+ print "____ get_events() ____"
+ if instance.type == "for_person":
+ all_events = instance.person.event_featuring.all()
+ elif instance.type == "for_place":
+ all_events = instance.place.event_set.all()
+ # most likely, we're getting events related to an entity
+ elif MULTIPLE_ENTITY_MODE and instance.entity:
+ all_events = self.model.objects.filter(Q(hosted_by=instance.entity) | Q(publish_to=instance.entity)).distinct().order_by('start_date', 'start_time')
+ else:
+ all_events = self.model.objects.all()
+
+ # if an entity should automatically publish its descendants' items
+ # all_events = Event.objects.filter(Q(hosted_by__in=instance.entity.get_descendants(include_self=True)) | Q(publish_to=instance.entity)).distinct().order_by('start_date')
+ print "All events", instance.type, all_events.count()
+
+ actual_events = all_events.filter(
+ # if it's (not a series and not a child) - series events are excluded, children too unless:
+ # the child's parent is a series and its children can be advertised
+ # tough luck if it's the child of a series and can't be advertised
+ Q(series = False, parent = None) | Q(parent__series = True, parent__do_not_advertise_children = False),
+ )
+ print "Actual events", actual_events.count()
+
+ instance.forthcoming_events = actual_events.filter(
+ # ... and it's (a single-day event starting after today) or (not a single-day event and ends after today)
+ Q(single_day_event = True, start_date__gte = datetime.now()) | Q(single_day_event = False, end_date__gte = datetime.now())
+ )
+
+ instance.previous_events = actual_events.exclude(
+ # ... and it's (a single-day event starting after today) or (not a single-day event and ends after today)
+ Q(single_day_event = True, start_date__gte = datetime.now()) | Q(single_day_event = False, end_date__gte = datetime.now())
+ ).order_by('-start_date', '-start_time')
+
+ print "Previous events", instance.previous_events.count()
+
+ instance.series_events = all_events.filter(series = True)
+ print "Series events", instance.series_events.count()
+
+ return
+
+ def get_items(self, instance):
+ self.get_events(instance) # go and get events
+ if instance.view == "archive":
+ instance.events = list(instance.previous_events)
+ # keep top events together where appropriate - not in long lists if COLLECT_TOP_ALL_FORTHCOMING_EVENTS is False
+ elif instance.order_by == "importance/date" and (instance.view == "current" or COLLECT_TOP_ALL_FORTHCOMING_EVENTS):
+ self.get_events_ordered_by_importance_and_date(instance)
+ instance.events = instance.top_events + instance.ordinary_events
+ else:
+ instance.events = list(instance.forthcoming_events)
+ return instance.events
View
3 news_and_events/models.py
@@ -12,6 +12,7 @@
import mptt
from cms.models import CMSPlugin
from django.conf import settings
+from news_and_events.managers import NewsArticleManager, EventManager
PLUGIN_HEADING_LEVELS = settings.PLUGIN_HEADING_LEVELS
PLUGIN_HEADING_LEVEL_DEFAULT = settings.PLUGIN_HEADING_LEVEL_DEFAULT
@@ -103,6 +104,7 @@ class NewsArticle(NewsAndEvents):
enquiries = models.ManyToManyField(Person, related_name='%(class)s_person',
help_text=u'The person to whom enquiries about this should be directed ',
null=True, blank=True)
+ objects = NewsArticleManager()
class Meta:
ordering = ['-date']
@@ -168,6 +170,7 @@ class Event(NewsAndEvents):
jumps_queue_on = models.DateField(null=True, blank=True,
help_text=u"Will become a featured item on this date")
jumps_queue_everywhere = models.BooleanField(default=False)
+ objects = EventManager()
class Meta:
ordering = ['type', 'start_date', 'start_time']
View
2 news_and_events/urls.py
@@ -1,4 +1,5 @@
from django.conf.urls.defaults import *
+# from news_and_events.views import NewsAndEventsViews
urlpatterns = patterns('',
@@ -17,6 +18,7 @@
(r'^previous-events/$', "news_and_events.views.previous_events"),
(r'^forthcoming-events/$', "news_and_events.views.all_forthcoming_events"),
(r'^news-and-events/$', "news_and_events.views.news_and_events"),
+ # (r'^news-and-events/$', NewsAndEventsViews.test),
)
#(r"^entity/(?P<slug>[-\w]+)/news/$", "news_and_events.views.news"), # in development
View
87 news_and_events/views.py
@@ -1,5 +1,6 @@
from django.shortcuts import render_to_response, get_object_or_404
from news_and_events.models import NewsAndEventsPlugin, Event, NewsArticle
+from cms_plugins import CMSNewsAndEventsPlugin
from contacts_and_people.models import Entity, default_entity
from django.conf import settings
from links.link_functions import object_links
@@ -12,8 +13,12 @@
MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH = settings.MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
IN_BODY_HEADING_LEVEL = settings.IN_BODY_HEADING_LEVEL
+class NewsAndEventsViews(object):
+ def test(self):
+ pass
+
+
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)
@@ -27,103 +32,121 @@ def common_settings(request, slug):
instance.format = "details image"
instance.layout = layout
instance.view = "current"
+ instance.main_page_body_file = "arkestra/universal_plugin_lister.html"
return instance, context, entity
+
def news_and_events(request, slug=getattr(default_entity, "slug", None)):
instance, context, entity = common_settings(request, slug)
- main_page_body_file = "arkestra/universal_plugin_lister.html"
instance.type = "main_page"
get_news_and_events(instance)
meta = {"description": "Recent news and forthcoming events",}
title = str(entity) + " news & events"
pagetitle = str(entity) + " news & events"
- return render_to_response(
- "contacts_and_people/entity_information.html",
- {"entity":entity,
+
+ CMSNewsAndEventsPlugin().render(context, instance, None)
+ # get_news_and_events(instance)
+
+ context.update({
+ "entity":entity,
"title": title,
"meta": meta,
"pagetitle": pagetitle,
- "main_page_body_file": main_page_body_file,
- 'everything': instance,
- },
+ "main_page_body_file": instance.main_page_body_file,
+ 'everything': instance,}
+ )
+
+ return render_to_response(
+ "contacts_and_people/entity_information.html",
context,
)
def previous_events(request, slug=getattr(default_entity, "slug", None)):
instance, context, entity = common_settings(request, slug)
+
instance.type = "sub_page"
instance.view = "archive"
instance.display = "events"
instance.limit_to = None
- get_news_and_events(instance)
meta = {"description": "Archive of previous events",}
title = str(entity) + " previous events"
pagetitle = str(entity) + " previous events"
- main_page_body_file = "arkestra/universal_plugin_lister.html"
- return render_to_response(
- "contacts_and_people/entity_information.html",
- {"entity":entity,
+ CMSNewsAndEventsPlugin().render(context, instance, None)
+
+ context.update({
+ "entity":entity,
"title": title,
"meta": meta,
"pagetitle": pagetitle,
- "main_page_body_file": main_page_body_file,
- 'everything': instance,
- },
+ "main_page_body_file": instance.main_page_body_file,
+ 'everything': instance,}
+ )
+
+ return render_to_response(
+ "contacts_and_people/entity_information.html",
context,
)
def all_forthcoming_events(request, slug=getattr(default_entity, "slug", None)):
instance, context, entity = common_settings(request, slug)
+ main_page_body_file = "arkestra/universal_plugin_lister.html"
+
instance.type = "sub_page"
instance.view = "current"
instance.display = "events"
instance.limit_to = None
- get_news_and_events(instance)
+
+ CMSNewsAndEventsPlugin().render(context, instance, None)
meta = {"description": "All forthcoming events",}
title = str(entity) + " forthcoming events"
pagetitle = str(entity) + " forthcoming events"
- main_page_body_file = "arkestra/universal_plugin_lister.html"
- return render_to_response(
- "contacts_and_people/entity_information.html",
- {"entity":entity,
+ context.update({
+ "entity":entity,
"title": title,
"meta": meta,
"pagetitle": pagetitle,
- "main_page_body_file": main_page_body_file,
- 'everything': instance,
- },
+ "main_page_body_file": instance.main_page_body_file,
+ 'everything': instance,}
+ )
+
+ return render_to_response(
+ "contacts_and_people/entity_information.html",
context,
)
def news_archive(request, slug=getattr(default_entity,"slug", None)):
instance, context, entity = common_settings(request, slug)
+ main_page_body_file = "arkestra/universal_plugin_lister.html"
+
instance.type = "sub_page"
instance.view = "archive"
instance.display = "news"
instance.limit_to = None
instance.order_by = "date"
- get_news_and_events(instance)
+
+ CMSNewsAndEventsPlugin().render(context, instance, None)
meta = {"description": "Archive of news items",}
title = str(entity) + " - news archive"
pagetitle = str(entity) + " - news archive"
- main_page_body_file = "arkestra/universal_plugin_lister.html"
- return render_to_response(
- "contacts_and_people/entity_information.html",
- {"entity":entity,
+ context.update({
+ "entity":entity,
"title": title,
"meta": meta,
"pagetitle": pagetitle,
- "main_page_body_file": main_page_body_file,
- 'everything': instance,
- },
+ "main_page_body_file": instance.main_page_body_file,
+ 'everything': instance,}
+ )
+
+ return render_to_response(
+ "contacts_and_people/entity_information.html",
context,
)

0 comments on commit e4eb9f9

Please sign in to comment.