Commit 085ec42b authored by Robert's avatar Robert

Export site calendar, refs #602

parent 78670e99
......@@ -115,7 +115,7 @@ def event_time(context, event):
@register.inclusion_tag('events/_sidebar_calendar.html', takes_context=True)
def sidebar_calendar(
context, associations, group=None, preview_length=5, show_group=True,
hide_buttons=False, component_id=None):
hide_buttons=False, component_id=None, site_calendar=False):
user = context['user']
group = context.get('group')
upcoming = associations\
......@@ -139,6 +139,9 @@ def sidebar_calendar(
if group:
url = reverse('group-events-export', args=(group.slug,))
actions.append(('Kalender exportieren', url))
if site_calendar:
url = reverse('export-site-events')
actions.append(('Kalender exportieren', url))
context.update({
'actions': actions,
......
......@@ -13,6 +13,16 @@ urlpatterns = [
views.Create.as_view(),
name='create-event'),
url(
r'^stadt/events/export$',
views.SiteCalendarExport.as_view(),
name='export-site-events'),
url(
r'^stadt/events/public.ics$',
views.SiteCalendarFeed(),
name='site-events-feed'),
url(
r'^stadt/events/(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/$',
views.Day.as_view(),
......
......@@ -88,16 +88,16 @@ class BaseCalendarFeed(ICalFeed):
self.assemble_content_filter_dict(filter_dict)
if user is None:
if filter_dict['public']:
return associations.Association.objects.filter_events().filter(**filter_dict)
return associations.Association.objects.filter_upcoming().filter(**filter_dict)
else:
# non-public items cannot be accessed without being authorized
raise PermissionDenied
else:
return associations.Association.objects.filter_events().can_view(user).filter(
return associations.Association.objects.filter_upcoming().can_view(user).filter(
**filter_dict)
def assemble_content_filter_dict(self, filter_dict):
filter_dict['public'] = (self.kwargs['domain'] == 'public')
filter_dict['public'] = (self.kwargs.get('domain', 'public') == 'public')
def get_authorized_user(self):
authenticated_gestalt = self.user_resolver.resolve_user(self.request,
......@@ -177,6 +177,14 @@ class GroupCalendarFeed(BaseCalendarFeed, features.groups.views.Mixin):
and is_member_of(authenticated_gestalt.user, self.get_group()))
class SiteCalendarFeed(BaseCalendarFeed):
def get_calendar_owner(self):
return None
def title(self):
return sites_models.Site.objects.get_current().name
class CalendarExport(utils_views.PageMixin, generic.DetailView):
sidebar = tuple()
template_name = 'events/export.html'
......@@ -218,6 +226,19 @@ class GroupCalendarExport(CalendarExport):
return False
class SiteCalendarExport(utils_views.PageMixin, generic.TemplateView):
permission_required = 'stadt.view_index'
title = 'Exportmöglichkeiten für Kalender'
feed_route = 'site-events-feed'
template_name = 'events/export.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['public_export_url'] = self.request.build_absolute_uri(
reverse(self.feed_route))
return context
class GestaltCalendarFeed(BaseCalendarFeed):
def get_calendar_owner(self):
......
......@@ -2,3 +2,4 @@ from rules import add_perm, always_allow
add_perm('stadt.search', always_allow)
add_perm('stadt.view_privacy', always_allow)
add_perm('stadt.view_index', always_allow)
......@@ -4,6 +4,13 @@
<link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ feed_url }}">
{% endblock %}
{% block sidebar %}
{% load events %}
{% sidebar_calendar paginator.object_list component_id='content-calendar' site_calendar=True %}
{% load groups %}
{% sidebar_groups user %}
{% endblock %}
{% block content_header %}
{% if STADTGESTALTEN_SHOW_HEADER %}
{% load dismissible %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment