From 2a67e9d8b25674e8fa04ffeb4aecb7776d1962d3 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 14:35:05 +0100 Subject: [PATCH 1/8] Stripped out all timezone references. Also reduced query to past 3 months --- RIGS/ical.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 944d03a9..15dc73af 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -16,8 +16,8 @@ class CalendarICS(ICalFeed): file_name = "rigs.ics" def items(self): - #include events from up to 1 year ago - start = datetime.datetime.now() - datetime.timedelta(days=365) + #include events from up to 3 months ago + start = datetime.datetime.now() - datetime.timedelta(days=31*3) filter = Q(start_date__gte=start) return models.Event.objects.filter(filter).order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic') @@ -46,11 +46,11 @@ class CalendarICS(ICalFeed): def item_start_datetime(self, item): #set start date to the earliest defined time for the event if item.meet_at: - startDateTime = item.meet_at + startDateTime = item.meet_at.replace(tzinfo=None) elif item.access_at: - startDateTime = item.access_at + startDateTime = item.access_at.replace(tzinfo=None) elif item.start_time: - startDateTime = datetime.datetime.combine(item.start_date,item.start_time) + startDateTime = datetime.datetime.combine(item.start_date,item.start_time).replace(tzinfo=None) else: startDateTime = item.start_date @@ -65,9 +65,9 @@ class CalendarICS(ICalFeed): endDateTime = item.end_date if item.start_time and item.end_time: # don't allow an event with specific end but no specific start - endDateTime = datetime.datetime.combine(endDateTime,item.end_time) + endDateTime = datetime.datetime.combine(endDateTime,item.end_time).replace(tzinfo=None) elif item.start_time: # if there's a start time specified then an end time should also be specified - endDateTime = datetime.datetime.combine(endDateTime+datetime.timedelta(days=1),datetime.time(00, 00)) + endDateTime = datetime.datetime.combine(endDateTime+datetime.timedelta(days=1),datetime.time(00, 00)).replace(tzinfo=None) #elif item.end_time: # end time but no start time - this is weird - don't think ICS will like it so ignoring # do nothing @@ -106,7 +106,7 @@ class CalendarICS(ICalFeed): desc += 'Notes:\n'+item.notes+'\n\n' base_url = "https://pyrigs.nottinghamtec.co.uk" - desc += 'URL = '+base_url+str(reverse_lazy('event_detail',kwargs={'pk':item.pk})) + desc += 'URL = '+base_url+str(item.get_absolute_url()) return desc @@ -119,7 +119,7 @@ class CalendarICS(ICalFeed): # return '' def item_updated(self, item): # some ical clients will display this - return item.last_edited_at + return item.last_edited_at.replace(tzinfo=None) def item_guid(self, item): # use the rig-id as the ical unique event identifier return item.pk \ No newline at end of file From 551e1117eb05bd82776e9f967a76a71ff58a074d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 14:41:06 +0100 Subject: [PATCH 2/8] Added google calendar instructions --- RIGS/templates/RIGS/profile_detail.html | 1 + 1 file changed, 1 insertion(+) diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 9e236ccc..197f86b4 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -73,6 +73,7 @@ {% else %}
No API Key Generated
{% endif %} + To add to google calendar follow instructions here From 70d887f91b99624fbc8ac8f7d95f06c106926805 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 14:54:42 +0100 Subject: [PATCH 3/8] Added more help --- RIGS/templates/RIGS/profile_detail.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 197f86b4..65a6aca3 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -73,7 +73,8 @@ {% else %}
No API Key Generated
{% endif %} - To add to google calendar follow instructions here + To add to google calendar follow instructions here. + To make it sync from google to your mobile device, visit this page on your device and tick "PyRIGS Calendar". From 53c804cfc66b04b71a9cc1384619855e28f2c215 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 15:29:17 +0100 Subject: [PATCH 4/8] Apparently google doesn't work without www. --- RIGS/templates/RIGS/profile_detail.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 65a6aca3..511267a7 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -74,7 +74,7 @@
No API Key Generated
{% endif %} To add to google calendar follow instructions here. - To make it sync from google to your mobile device, visit this page on your device and tick "PyRIGS Calendar". + To make it sync from google to your mobile device, visit this page on your device and tick "PyRIGS Calendar". From 88c67054b61ef60b6316d4f4e302fad27b07c83d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 15:31:50 +0100 Subject: [PATCH 5/8] Back to 12 month query --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 15dc73af..02862dfb 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -17,7 +17,7 @@ class CalendarICS(ICalFeed): def items(self): #include events from up to 3 months ago - start = datetime.datetime.now() - datetime.timedelta(days=31*3) + start = datetime.datetime.now() - datetime.timedelta(days=365) filter = Q(start_date__gte=start) return models.Event.objects.filter(filter).order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic') From a464c210ddabe1c2ede980183d0bb0bcf53fe557 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 15:57:00 +0100 Subject: [PATCH 6/8] Better help info --- RIGS/templates/RIGS/profile_detail.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 511267a7..4e9a58a1 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -48,7 +48,7 @@ {% if object.pk == user.pk %}
- + {% if user.api_key %}Reset API Key{% else %}Generate API Key{% endif %} @@ -70,11 +70,12 @@
{% if user.api_key %}
http{{ request.is_secure|yesno:"s,"}}://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}
+ Click here to add to google calendar.
+ To sync from google calendar to mobile device, visit this page on your device and tick "PyRIGS Calendar".
{% else %}
No API Key Generated
{% endif %} - To add to google calendar follow instructions here. - To make it sync from google to your mobile device, visit this page on your device and tick "PyRIGS Calendar". +
From 3397bb772de9477bf9f6cfcd71b1f4687a1ea468 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 22 Apr 2015 16:11:11 +0100 Subject: [PATCH 7/8] Don't serve cancelled rigs --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 02862dfb..ef351ecf 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -18,7 +18,7 @@ class CalendarICS(ICalFeed): def items(self): #include events from up to 3 months ago start = datetime.datetime.now() - datetime.timedelta(days=365) - filter = Q(start_date__gte=start) + filter = Q(start_date__gte=start) & ~Q(status=models.Event.CANCELLED) return models.Event.objects.filter(filter).order_by('-start_date').select_related('person', 'organisation', 'venue', 'mic') From 0e7232a16cde1390a5a5492ced668e8844212be9 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 24 Apr 2015 00:10:14 +0100 Subject: [PATCH 8/8] Corrected comment --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index ef351ecf..c276e512 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -16,7 +16,7 @@ class CalendarICS(ICalFeed): file_name = "rigs.ics" def items(self): - #include events from up to 3 months ago + #include events from up to 1 year ago start = datetime.datetime.now() - datetime.timedelta(days=365) filter = Q(start_date__gte=start) & ~Q(status=models.Event.CANCELLED)