From c7b0ca4334a6b22b981e9884467983361aad9625 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 21 Apr 2015 19:25:46 +0100 Subject: [PATCH] Change ical to use dynamically generated URL's instead of a static base URL. --- RIGS/ical.py | 4 ++-- RIGS/models.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 55362d75..944d03a9 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -112,8 +112,8 @@ class CalendarICS(ICalFeed): def item_link(self, item): # Make a link to the event in the web interface - base_url = "https://pyrigs.nottinghamtec.co.uk" - return base_url+str(reverse_lazy('event_detail',kwargs={'pk':item.pk})) + # base_url = "https://pyrigs.nottinghamtec.co.uk" + return item.get_absolute_url() # def item_created(self, item): #TODO - Implement created date-time (using django-reversion?) - not really necessary though # return '' diff --git a/RIGS/models.py b/RIGS/models.py index d7305530..641aeab9 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -9,6 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible import reversion import string import random +from django.core.urlresolvers import reverse_lazy from decimal import Decimal @@ -304,6 +305,9 @@ class Event(models.Model, RevisionMixin): objects = EventManager() + def get_absolute_url(self): + return reverse_lazy('event_detail', kwargs={'pk': self.pk}) + def __str__(self): return str(self.pk) + ": " + self.name