From a9a030a5fd150e6adc69c255d08a50600b6331eb Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 28 Apr 2015 01:05:40 +0100 Subject: [PATCH 1/8] Change timezone and turn off timezone support --- PyRIGS/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 9f78c9cf..d7a4dcc2 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -174,13 +174,13 @@ else: LANGUAGE_CODE = 'en-gb' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/London' USE_I18N = True USE_L10N = True -USE_TZ = True +USE_TZ = False DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M','%Y-%m-%dT%H:%M:%S') From 16a026bca5f159289dd57f586c55e6ed3663c9da Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 28 Apr 2015 01:06:08 +0100 Subject: [PATCH 2/8] Add explicit timezone declaration to ical interface --- RIGS/ical.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RIGS/ical.py b/RIGS/ical.py index b7ecbee4..ba411ef5 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -12,6 +12,7 @@ class CalendarICS(ICalFeed): #Metadata which is passed on to clients product_id = 'PyRIGS' title = 'PyRIGS Calendar' + timezone = 'Europe/London' file_name = "rigs.ics" def items(self): From 61b2a9e7add705ae2988ad60d64c9180289cc8c3 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 28 Apr 2015 01:06:47 +0100 Subject: [PATCH 3/8] Stop stripping timezone info (no longer necessary) --- RIGS/ical.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index ba411ef5..1eb4ebe3 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -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.replace(tzinfo=None) + startDateTime = item.meet_at elif item.access_at: - startDateTime = item.access_at.replace(tzinfo=None) + startDateTime = item.access_at elif item.has_start_time: - startDateTime = datetime.datetime.combine(item.start_date,item.start_time).replace(tzinfo=None) + startDateTime = datetime.datetime.combine(item.start_date,item.start_time) else: startDateTime = item.start_date @@ -65,9 +65,9 @@ class CalendarICS(ICalFeed): endDateTime = item.end_date if item.has_start_time and item.has_end_time: # don't allow an event with specific end but no specific start - endDateTime = datetime.datetime.combine(endDateTime,item.end_time).replace(tzinfo=None) + endDateTime = datetime.datetime.combine(endDateTime,item.end_time) elif item.has_end_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)).replace(tzinfo=None) + endDateTime = datetime.datetime.combine(endDateTime+datetime.timedelta(days=1),datetime.time(00, 00)) #elif item.end_time: # end time but no start time - this is weird - don't think ICS will like it so ignoring # do nothing @@ -119,7 +119,7 @@ class CalendarICS(ICalFeed): # return '' def item_updated(self, item): # some ical clients will display this - return item.last_edited_at.replace(tzinfo=None) + return item.last_edited_at 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 ff4dd46c8790dbe3c867f06089e170bc3024ddac Mon Sep 17 00:00:00 2001 From: Tom Price Date: Mon, 18 May 2015 23:41:17 +0100 Subject: [PATCH 4/8] Re-enable timezones and add iCal converstion to UTC. This should work on Google Cal but won't be able to test till in production. --- PyRIGS/settings.py | 2 +- RIGS/ical.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 90b88c16..297ef8d8 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -180,7 +180,7 @@ USE_I18N = True USE_L10N = True -USE_TZ = False +USE_TZ = True DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M','%Y-%m-%dT%H:%M:%S') diff --git a/RIGS/ical.py b/RIGS/ical.py index 1eb4ebe3..ecabce62 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -2,19 +2,26 @@ from RIGS import models, forms from django_ical.views import ICalFeed from django.db.models import Q from django.core.urlresolvers import reverse_lazy, reverse, NoReverseMatch +from django.utils import timezone +from django.conf import settings -import datetime +import datetime, pytz class CalendarICS(ICalFeed): """ A simple event calender """ #Metadata which is passed on to clients - product_id = 'PyRIGS' - title = 'PyRIGS Calendar' - timezone = 'Europe/London' + product_id = 'RIGS' + title = 'RIGS Calendar' + timezone = 'UTC' file_name = "rigs.ics" + def get(self, *args, **kwargs): + timezone.activate(timezone.UTC) + return super(CalendarICS, self).get(*args, **kwargs) + + def items(self): #include events from up to 1 year ago start = datetime.datetime.now() - datetime.timedelta(days=365) @@ -51,6 +58,8 @@ class CalendarICS(ICalFeed): startDateTime = item.access_at elif item.has_start_time: startDateTime = datetime.datetime.combine(item.start_date,item.start_time) + tz = pytz.timezone(settings.TIME_ZONE) + startDateTime = tz.normalize(tz.localize(startDateTime)).astimezone(pytz.timezone(self.timezone)) else: startDateTime = item.start_date @@ -66,6 +75,8 @@ class CalendarICS(ICalFeed): if item.has_start_time and item.has_end_time: # don't allow an event with specific end but no specific start endDateTime = datetime.datetime.combine(endDateTime,item.end_time) + tz = pytz.timezone(settings.TIME_ZONE) + endDateTime = tz.normalize(tz.localize(endDateTime)).astimezone(pytz.timezone(self.timezone)) elif item.has_end_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)) #elif item.end_time: # end time but no start time - this is weird - don't think ICS will like it so ignoring From d2458fbf22cddcc5cdfa8bbe2a99601e7b193c20 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 21 May 2015 16:32:52 +0100 Subject: [PATCH 5/8] Changed file timezone to match django settings --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index ecabce62..53e178d5 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -14,7 +14,7 @@ class CalendarICS(ICalFeed): #Metadata which is passed on to clients product_id = 'RIGS' title = 'RIGS Calendar' - timezone = 'UTC' + timezone = settings.TIME_ZONE file_name = "rigs.ics" def get(self, *args, **kwargs): From 8c9977e46412b322130b8fafb631ea9b4b2f043b Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 21 May 2015 16:38:21 +0100 Subject: [PATCH 6/8] Removed meet-info from event description --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 53e178d5..2e0a8fda 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -102,7 +102,7 @@ class CalendarICS(ICalFeed): desc += '\n' if item.meet_at: - desc += 'Crew Meet = ' + item.meet_at.strftime('%Y-%m-%d %H:%M') + (('('+item.meet_info+')') if item.meet_info else '---') + '\n' + desc += 'Crew Meet = ' + (item.meet_at.strftime('%Y-%m-%d %H:%M') if item.meet_at else '---') + '\n' if item.access_at: desc += 'Access At = ' + item.access_at.strftime('%Y-%m-%d %H:%M') + '\n' if item.start_date: From e05185181fb8359a5a2c2b6e518c2350debe5d35 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 21 May 2015 16:40:02 +0100 Subject: [PATCH 7/8] Corrected pyrigs.nottinghamtec to rigs.nottinghamtec --- RIGS/ical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 2e0a8fda..20434c12 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -116,7 +116,7 @@ class CalendarICS(ICalFeed): if item.notes: desc += 'Notes:\n'+item.notes+'\n\n' - base_url = "https://pyrigs.nottinghamtec.co.uk" + base_url = "http://rigs.nottinghamtec.co.uk" desc += 'URL = '+base_url+str(item.get_absolute_url()) return desc From fb0fc3506b9f9e4929ef82b8f9ffdd20153113b0 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 24 May 2015 14:21:24 +0100 Subject: [PATCH 8/8] Fixed MIC photo logic --- RIGS/templates/RIGS/event_table.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RIGS/templates/RIGS/event_table.html b/RIGS/templates/RIGS/event_table.html index 3cd5144f..49e4ec6f 100644 --- a/RIGS/templates/RIGS/event_table.html +++ b/RIGS/templates/RIGS/event_table.html @@ -80,12 +80,12 @@ {% endif %} - {% if event.mic or not event.is_rig %} + {% if event.mic %} {{ event.mic.initials }}
- {% else %} + {% elif event.is_rig %} {% endif %}