Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 182 lines (147 sloc) 5.7 kb
ce5ee75 Daniele Procida news and events and contacts and people now use get_object_or_404
authored
1 from django.shortcuts import render_to_response, get_object_or_404
e428a00 Daniele Procida committing all files (I hope)
authored
2 from django.conf import settings
8fa1af8 Jonas Obrist My stab at making the code style more consistent, and more PEP8 complian...
ojii authored
3 from django.template import RequestContext
e428a00 Daniele Procida committing all files (I hope)
authored
4
d14c25b Daniele Procida news and events for universal plugins
authored
5 from contacts_and_people.models import Entity, default_entity
6 from links.link_functions import object_links
d9b1144 Daniele Procida sidestepping a menu.py issue, temporarily
authored
7
8 from models import NewsAndEventsPlugin, Event, NewsArticle
9 from cms_plugins import CMSNewsAndEventsPlugin
d14c25b Daniele Procida news and events for universal plugins
authored
10
9d0cc52 Daniele Procida added a setting to allow stacked layout in news & events pages
authored
11 layout = getattr(settings, "NEWS_AND_EVENTS_LAYOUT", "sidebyside")
21fce21 Daniele Procida lots of tidying-up related to settings
authored
12
8191f57 Daniele Procida bringing news and events up-to-date with new ways
authored
13 MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH = settings.MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
14 IN_BODY_HEADING_LEVEL = settings.IN_BODY_HEADING_LEVEL
6ff6100 Daniele Procida vacancies & studentships now more in line with universal plugin scheme
authored
15
e4eb9f9 Daniele Procida rationalising plugin lists
authored
16
b278f38 Daniele Procida great improvement in the way we access entities' news and other pages, w...
authored
17 def common_settings(request, slug):
5594c11 Daniele Procida temporarily saving state
authored
18 entity = Entity.objects.get(slug=slug) or default_entity
4c52e53 Daniele Procida new menu system
authored
19 request.auto_page_url = request.path
d528c43 Daniele Procida more tidying up
authored
20 # request.path = entity.get_website.get_absolute_url() # for the menu, so it knows where we are
21 request.current_page = entity.get_website
e428a00 Daniele Procida committing all files (I hope)
authored
22 context = RequestContext(request)
23 instance = NewsAndEventsPlugin()
21fce21 Daniele Procida lots of tidying-up related to settings
authored
24 instance.limit_to = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
25 instance.default_limit = MAIN_NEWS_EVENTS_PAGE_LIST_LENGTH
e428a00 Daniele Procida committing all files (I hope)
authored
26 instance.order_by = "importance/date"
27 instance.entity = entity
21fce21 Daniele Procida lots of tidying-up related to settings
authored
28 instance.heading_level = IN_BODY_HEADING_LEVEL
e428a00 Daniele Procida committing all files (I hope)
authored
29 instance.display = "news-and-events"
04a4e9e Daniele Procida big improvements to news functions and templates
authored
30 instance.format = "details image"
9d0cc52 Daniele Procida added a setting to allow stacked layout in news & events pages
authored
31 instance.layout = layout
e428a00 Daniele Procida committing all files (I hope)
authored
32 instance.view = "current"
e4eb9f9 Daniele Procida rationalising plugin lists
authored
33 instance.main_page_body_file = "arkestra/universal_plugin_lister.html"
e428a00 Daniele Procida committing all files (I hope)
authored
34 return instance, context, entity
35
e4eb9f9 Daniele Procida rationalising plugin lists
authored
36
8fa1af8 Jonas Obrist My stab at making the code style more consistent, and more PEP8 complian...
ojii authored
37 def news_and_events(request, slug=getattr(default_entity, "slug", None)):
e428a00 Daniele Procida committing all files (I hope)
authored
38 instance, context, entity = common_settings(request, slug)
39
40 instance.type = "main_page"
41
5ab8673 Daniele Procida improvements to metadata output
authored
42 meta = {"description": "Recent news and forthcoming events",}
a882d04 hejsan Changed all relevant str() calls to unicode() and added a few translatio...
hejsan authored
43 title = unicode(entity) + u" news & events"
8695bb9 Daniele Procida better page titles for auto pages
authored
44 if getattr(settings, "MULTIPLE_ENTITY_MODE"):
a882d04 hejsan Changed all relevant str() calls to unicode() and added a few translatio...
hejsan authored
45 pagetitle = unicode(entity) + u" news & events"
8695bb9 Daniele Procida better page titles for auto pages
authored
46 else:
47 pagetitle = "News & events"
e4eb9f9 Daniele Procida rationalising plugin lists
authored
48 CMSNewsAndEventsPlugin().render(context, instance, None)
49
50 context.update({
51 "entity":entity,
e428a00 Daniele Procida committing all files (I hope)
authored
52 "title": title,
53 "meta": meta,
54 "pagetitle": pagetitle,
e4eb9f9 Daniele Procida rationalising plugin lists
authored
55 "main_page_body_file": instance.main_page_body_file,
a6c2114 Daniele Procida added fields for placeholders on contacts/news/vacancies
authored
56 "intro_page_placeholder": entity.news_page_intro,
57 'everything': instance,
58 }
e4eb9f9 Daniele Procida rationalising plugin lists
authored
59 )
60
61 return render_to_response(
d64e8f9 Daniele Procida arkestra_page.html instead of entity_information.html
authored
62 "contacts_and_people/arkestra_page.html",
e428a00 Daniele Procida committing all files (I hope)
authored
63 context,
64 )
65
8fa1af8 Jonas Obrist My stab at making the code style more consistent, and more PEP8 complian...
ojii authored
66 def previous_events(request, slug=getattr(default_entity, "slug", None)):
e428a00 Daniele Procida committing all files (I hope)
authored
67 instance, context, entity = common_settings(request, slug)
e4eb9f9 Daniele Procida rationalising plugin lists
authored
68
e428a00 Daniele Procida committing all files (I hope)
authored
69 instance.type = "sub_page"
70 instance.view = "archive"
71 instance.display = "events"
72 instance.limit_to = None
73
5ab8673 Daniele Procida improvements to metadata output
authored
74 meta = {"description": "Archive of previous events",}
a882d04 hejsan Changed all relevant str() calls to unicode() and added a few translatio...
hejsan authored
75 title = unicode(entity) + u" previous events"
76 pagetitle = unicode(entity) + u" previous events"
e428a00 Daniele Procida committing all files (I hope)
authored
77
e4eb9f9 Daniele Procida rationalising plugin lists
authored
78 CMSNewsAndEventsPlugin().render(context, instance, None)
79
80 context.update({
81 "entity":entity,
e428a00 Daniele Procida committing all files (I hope)
authored
82 "title": title,
83 "meta": meta,
84 "pagetitle": pagetitle,
e4eb9f9 Daniele Procida rationalising plugin lists
authored
85 "main_page_body_file": instance.main_page_body_file,
86 'everything': instance,}
87 )
88
89 return render_to_response(
d64e8f9 Daniele Procida arkestra_page.html instead of entity_information.html
authored
90 "contacts_and_people/arkestra_page.html",
e428a00 Daniele Procida committing all files (I hope)
authored
91 context,
92 )
93
8fa1af8 Jonas Obrist My stab at making the code style more consistent, and more PEP8 complian...
ojii authored
94 def all_forthcoming_events(request, slug=getattr(default_entity, "slug", None)):
e428a00 Daniele Procida committing all files (I hope)
authored
95 instance, context, entity = common_settings(request, slug)
e4eb9f9 Daniele Procida rationalising plugin lists
authored
96
e428a00 Daniele Procida committing all files (I hope)
authored
97 instance.type = "sub_page"
98 instance.view = "current"
99 instance.display = "events"
100 instance.limit_to = None
e4eb9f9 Daniele Procida rationalising plugin lists
authored
101
102 CMSNewsAndEventsPlugin().render(context, instance, None)
e428a00 Daniele Procida committing all files (I hope)
authored
103
5ab8673 Daniele Procida improvements to metadata output
authored
104 meta = {"description": "All forthcoming events",}
a882d04 hejsan Changed all relevant str() calls to unicode() and added a few translatio...
hejsan authored
105 title = unicode(entity) + u" forthcoming events"
106 pagetitle = unicode(entity) + u" forthcoming events"
e428a00 Daniele Procida committing all files (I hope)
authored
107
e4eb9f9 Daniele Procida rationalising plugin lists
authored
108 context.update({
109 "entity":entity,
e428a00 Daniele Procida committing all files (I hope)
authored
110 "title": title,
111 "meta": meta,
112 "pagetitle": pagetitle,
e4eb9f9 Daniele Procida rationalising plugin lists
authored
113 "main_page_body_file": instance.main_page_body_file,
114 'everything': instance,}
115 )
116
117 return render_to_response(
d64e8f9 Daniele Procida arkestra_page.html instead of entity_information.html
authored
118 "contacts_and_people/arkestra_page.html",
e428a00 Daniele Procida committing all files (I hope)
authored
119 context,
120 )
121
8fa1af8 Jonas Obrist My stab at making the code style more consistent, and more PEP8 complian...
ojii authored
122 def news_archive(request, slug=getattr(default_entity,"slug", None)):
e428a00 Daniele Procida committing all files (I hope)
authored
123 instance, context, entity = common_settings(request, slug)
e4eb9f9 Daniele Procida rationalising plugin lists
authored
124
e428a00 Daniele Procida committing all files (I hope)
authored
125 instance.type = "sub_page"
126 instance.view = "archive"
127 instance.display = "news"
128 instance.limit_to = None
129 instance.order_by = "date"
e4eb9f9 Daniele Procida rationalising plugin lists
authored
130
131 CMSNewsAndEventsPlugin().render(context, instance, None)
e428a00 Daniele Procida committing all files (I hope)
authored
132
5ab8673 Daniele Procida improvements to metadata output
authored
133 meta = {"description": "Archive of news items",}
a882d04 hejsan Changed all relevant str() calls to unicode() and added a few translatio...
hejsan authored
134 title = unicode(entity) + u" - news archive"
135 pagetitle = unicode(entity) + u" - news archive"
e428a00 Daniele Procida committing all files (I hope)
authored
136
e4eb9f9 Daniele Procida rationalising plugin lists
authored
137 context.update({
138 "entity":entity,
e428a00 Daniele Procida committing all files (I hope)
authored
139 "title": title,
140 "meta": meta,
141 "pagetitle": pagetitle,
e4eb9f9 Daniele Procida rationalising plugin lists
authored
142 "main_page_body_file": instance.main_page_body_file,
143 'everything': instance,}
144 )
145
146 return render_to_response(
d64e8f9 Daniele Procida arkestra_page.html instead of entity_information.html
authored
147 "contacts_and_people/arkestra_page.html",
e428a00 Daniele Procida committing all files (I hope)
authored
148 context,
149 )
150
b278f38 Daniele Procida great improvement in the way we access entities' news and other pages, w...
authored
151
e428a00 Daniele Procida committing all files (I hope)
authored
152 def newsarticle(request, slug):
153 """
154 Responsible for publishing news article
155 """
ce5ee75 Daniele Procida news and events and contacts and people now use get_object_or_404
authored
156 newsarticle = get_object_or_404(NewsArticle, slug=slug)
e428a00 Daniele Procida committing all files (I hope)
authored
157
ce5ee75 Daniele Procida news and events and contacts and people now use get_object_or_404
authored
158 return render_to_response(
e428a00 Daniele Procida committing all files (I hope)
authored
159 "news_and_events/newsarticle.html",
5594c11 Daniele Procida temporarily saving state
authored
160 {
161 "newsarticle":newsarticle,
d528c43 Daniele Procida more tidying up
authored
162 "entity": newsarticle.get_hosted_by,
a1b191e Daniele Procida summary, not subtitle, on news and events
authored
163 "meta": {"description": newsarticle.summary,}
e428a00 Daniele Procida committing all files (I hope)
authored
164 },
165 RequestContext(request),
166 )
167
168 def event(request, slug):
169 """
170 Responsible for publishing an event
171 """
54bf4ff Daniele Procida commenting out prints
authored
172 # print " -------- views.event --------"
ce5ee75 Daniele Procida news and events and contacts and people now use get_object_or_404
authored
173 event = get_object_or_404(Event, slug=slug)
b278f38 Daniele Procida great improvement in the way we access entities' news and other pages, w...
authored
174
ce5ee75 Daniele Procida news and events and contacts and people now use get_object_or_404
authored
175 return render_to_response(
e428a00 Daniele Procida committing all files (I hope)
authored
176 "news_and_events/event.html",
177 {"event": event,
5e3c303 Daniele Procida get_hosted_by for Event view
authored
178 "entity": event.get_hosted_by,
a1b191e Daniele Procida summary, not subtitle, on news and events
authored
179 "meta": {"description": event.summary,},
e428a00 Daniele Procida committing all files (I hope)
authored
180 },
181 RequestContext(request),
4c52e53 Daniele Procida new menu system
authored
182 )
Something went wrong with that request. Please try again.