parent
388f42b05f
commit
6642f03720
1 changed files with 6 additions and 0 deletions
|
@ -14,6 +14,7 @@ from django.http import Http404, HttpResponse, HttpResponseForbidden
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.views import login as django_login_view
|
from django.contrib.auth.views import login as django_login_view
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
import django.utils.six as six
|
import django.utils.six as six
|
||||||
|
|
||||||
|
@ -710,12 +711,15 @@ def calendar_ics(request, token):
|
||||||
tirage__active=True)
|
tirage__active=True)
|
||||||
shows = shows.distinct()
|
shows = shows.distinct()
|
||||||
vcal = Calendar()
|
vcal = Calendar()
|
||||||
|
site = Site.objects.get_current()
|
||||||
for show in shows:
|
for show in shows:
|
||||||
vevent = Vevent()
|
vevent = Vevent()
|
||||||
vevent.add('dtstart', show.date)
|
vevent.add('dtstart', show.date)
|
||||||
vevent.add('dtend', show.date + timedelta(seconds=7200))
|
vevent.add('dtend', show.date + timedelta(seconds=7200))
|
||||||
vevent.add('summary', show.title)
|
vevent.add('summary', show.title)
|
||||||
vevent.add('location', show.location.name)
|
vevent.add('location', show.location.name)
|
||||||
|
vevent.add('uid', 'show-{:d}-{:d}@{:s}'.format(
|
||||||
|
show.pk, show.tirage_id, site.domain))
|
||||||
vcal.add_component(vevent)
|
vcal.add_component(vevent)
|
||||||
if subscription.subscribe_to_events:
|
if subscription.subscribe_to_events:
|
||||||
for event in Event.objects.filter(old=False).all():
|
for event in Event.objects.filter(old=False).all():
|
||||||
|
@ -725,6 +729,8 @@ def calendar_ics(request, token):
|
||||||
vevent.add('summary', event.title)
|
vevent.add('summary', event.title)
|
||||||
vevent.add('location', event.location)
|
vevent.add('location', event.location)
|
||||||
vevent.add('description', event.description)
|
vevent.add('description', event.description)
|
||||||
|
vevent.add('uid', 'event-{:d}@{:s}'.format(
|
||||||
|
event.pk, site.domain))
|
||||||
vcal.add_component(vevent)
|
vcal.add_component(vevent)
|
||||||
response = HttpResponse(content=vcal.to_ical())
|
response = HttpResponse(content=vcal.to_ical())
|
||||||
response['Content-Type'] = "text/calendar"
|
response['Content-Type'] = "text/calendar"
|
||||||
|
|
Loading…
Reference in a new issue