From a0467300e36d88ad0c5c0893d3a8694a3483e7e8 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 20:46:15 +0100 Subject: [PATCH 1/8] Fixed ordering of event archive --- RIGS/rigboard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 050e0eda..790a46f4 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -171,9 +171,9 @@ class EventArchive(generic.ArchiveIndexView): filter = Q(start_date__gte=start) if filter: - qs = self.model.objects.filter(filter) + qs = self.model.objects.filter(filter).order_by('-start_date') else: - qs = self.model.objects.all() + qs = self.model.objects.all().order_by('-start_date') # Preselect related for efficiency qs.select_related('person', 'organisation', 'venue', 'mic') From 0a55d373f2de9444b9f124d4918fae4b79c770f1 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 22:35:52 +0100 Subject: [PATCH 2/8] Fix logout/login infinite loop (Since there are now no pages accessible without login, there is no need for the login link to have the "next" parameter) --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index 184346ef..9b6eaa10 100644 --- a/templates/base.html +++ b/templates/base.html @@ -112,7 +112,7 @@ {% else %} - + Login From 73ba535efb038048e74c801365aecc9e3d527c3f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 22:54:58 +0100 Subject: [PATCH 3/8] Fixed API permissions, and removed unnecessary data from the events api (it now only gives information available to non-keyholders - the rest wasn't used anyway). This now means the web-calendar view works for non-keyholders --- RIGS/urls.py | 4 ++-- RIGS/views.py | 25 ++----------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/RIGS/urls.py b/RIGS/urls.py index c39a571c..93028bb2 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -145,8 +145,8 @@ urlpatterns = patterns('', url(r'^ical/(?P\d+)/(?P\w+)/rigs.ics$', api_key_required(ical.CalendarICS()), name="ics_calendar"), # API - url(r'^api/(?P\w+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"), - url(r'^api/(?P\w+)/(?P\d+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"), + url(r'^api/(?P\w+)/$', login_required(views.SecureAPIRequest.as_view()), name="api_secure"), + url(r'^api/(?P\w+)/(?P\d+)/$', login_required(views.SecureAPIRequest.as_view()), name="api_secure"), # Legacy URL's url(r'^rig/show/(?P\d+)/$', RedirectView.as_view(permanent=True,pattern_name='event_detail')), diff --git a/RIGS/views.py b/RIGS/views.py index 0894d800..ea7d2bc9 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -221,8 +221,8 @@ class SecureAPIRequest(generic.View): 'venue': 'RIGS.view_venue', 'person': 'RIGS.view_person', 'organisation': 'RIGS.view_organisation', - 'profile': None, - 'event': 'RIGS.view_event', + 'profile': 'RIGS.view_profile', + 'event': None, } ''' @@ -331,27 +331,6 @@ class SecureAPIRequest(generic.View): if item.access_at: data['access_at'] = item.access_at.strftime('%Y-%m-%dT%H:%M:%SZ') - if item.venue: - data['venue'] = item.venue.name - - if item.person: - data['person'] = item.person.name - - if item.organisation: - data['organisation'] = item.organisation.name - - if item.mic: - data['mic'] = { - 'name':item.mic.get_full_name(), - 'initials':item.mic.initials - } - - if item.description: - data['description'] = item.description - - if item.notes: - data['notes'] = item.notes - data['url'] = str(reverse_lazy('event_detail',kwargs={'pk':item.pk})) results.append(data) From 1fdeed7da3f1e5fd1aeadb18efdc5808101b7719 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 23:26:02 +0100 Subject: [PATCH 4/8] Added dry hire indicator to event_detail - issue #144 --- RIGS/templates/RIGS/event_detail.html | 4 +--- RIGS/templates/RIGS/event_table.html | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/RIGS/templates/RIGS/event_detail.html b/RIGS/templates/RIGS/event_detail.html index c1e21c25..358eaf10 100644 --- a/RIGS/templates/RIGS/event_detail.html +++ b/RIGS/templates/RIGS/event_detail.html @@ -5,12 +5,10 @@
{% if not request.is_ajax %}
-

{% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %} - | {{ object.name }} + | {{ object.name }} {% if event.dry_hire %}Dry Hire{% endif %}

-
diff --git a/RIGS/templates/RIGS/event_table.html b/RIGS/templates/RIGS/event_table.html index 1868f2dd..186795e0 100644 --- a/RIGS/templates/RIGS/event_table.html +++ b/RIGS/templates/RIGS/event_table.html @@ -38,7 +38,7 @@ at {{ event.venue }} {% endif %} {% if event.dry_hire %} - Dry Hire + Dry Hire {% endif %} {% if event.is_rig and not event.cancelled %} From 44c1704f755ec6667467ac166438e47742dc0707 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 23:29:06 +0100 Subject: [PATCH 5/8] Paperwork emergency contacts "or" to "and" --- RIGS/templates/RIGS/event_print_page.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/templates/RIGS/event_print_page.xml b/RIGS/templates/RIGS/event_print_page.xml index 96087e71..046af269 100644 --- a/RIGS/templates/RIGS/event_print_page.xml +++ b/RIGS/templates/RIGS/event_print_page.xml @@ -241,7 +241,7 @@ - 24 Hour Emergency Contacts: 07825 065681 or 07825 065678 + 24 Hour Emergency Contacts: 07825 065681 and 07825 065678 From c6e442b4224c0e05395d56c83cbdcffcd0d973b7 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 00:44:34 +0100 Subject: [PATCH 6/8] Fixed date formatting issue #141 --- RIGS/templates/RIGS/version_changes.html | 21 +++++++++++++++++++-- RIGS/versioning.py | 10 ++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/RIGS/templates/RIGS/version_changes.html b/RIGS/templates/RIGS/version_changes.html index bbd15695..98abaf15 100644 --- a/RIGS/templates/RIGS/version_changes.html +++ b/RIGS/templates/RIGS/version_changes.html @@ -2,8 +2,25 @@ diff --git a/RIGS/versioning.py b/RIGS/versioning.py index 9fd815b4..fa54e9ff 100644 --- a/RIGS/versioning.py +++ b/RIGS/versioning.py @@ -16,7 +16,7 @@ import simplejson from reversion.models import Version from django.contrib.contenttypes.models import ContentType # Used to lookup the content_type from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger -from django.db.models import ForeignKey, IntegerField, EmailField +from django.db.models import ForeignKey, IntegerField, EmailField, TextField from RIGS import models, forms import datetime @@ -56,7 +56,13 @@ def model_compare(oldObj, newObj, excluded_keys=[]): def long(self): if isinstance(self.field, EmailField): return True - return False + return False + + @property + def linebreaks(self): + if isinstance(self.field, TextField): + return True + return False changes = [] From 0089c7d36fa939538d6f9089b402760e44ed4108 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 12:09:31 +0100 Subject: [PATCH 7/8] Fixed TZ issue #146 (MomentJS wasn't being supplied with timezone info) --- RIGS/templates/RIGS/activity_feed.html | 2 +- RIGS/templates/RIGS/activity_feed_data.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RIGS/templates/RIGS/activity_feed.html b/RIGS/templates/RIGS/activity_feed.html index 5b2c9f0a..78d5f9b0 100644 --- a/RIGS/templates/RIGS/activity_feed.html +++ b/RIGS/templates/RIGS/activity_feed.html @@ -38,7 +38,7 @@ $('.date').each(function (index, dateElem) { var $dateElem = $(dateElem); - var formatted = moment($dateElem.attr('data-date'),"DD/MM/YYYY HH:mm").twitterLong(); + var formatted = moment($dateElem.attr('data-date')).twitterLong(); $dateElem.text(formatted); }); diff --git a/RIGS/templates/RIGS/activity_feed_data.html b/RIGS/templates/RIGS/activity_feed_data.html index e0e454bf..fc9af87e 100644 --- a/RIGS/templates/RIGS/activity_feed_data.html +++ b/RIGS/templates/RIGS/activity_feed_data.html @@ -27,7 +27,7 @@
{{ version.revision.user.name }} - +
{% endif %} From d3c6dab29b037ac7c1a04df95552186d803ed24a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 14:42:53 +0100 Subject: [PATCH 8/8] Improved how events are selected for display on web-calendar --- RIGS/models.py | 9 +++++++++ RIGS/views.py | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/RIGS/models.py b/RIGS/models.py index 6c4c9c9c..34f65724 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -224,6 +224,15 @@ class EventManager(models.Manager): ).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person', 'organisation', 'venue', 'mic') return events + def events_in_bounds(self, start, end): + events = self.filter( + (models.Q(start_date__gte=start.date(), start_date__lte=end.date())) | # Start date in bounds + (models.Q(end_date__gte=start.date(), end_date__lte=end.date())) | # End date in bounds + (models.Q(access_at__gte=start, access_at__lte=end)) | # Access at in bounds + (models.Q(meet_at__gte=start, meet_at__lte=end)) # Meet at in bounds + ).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person', 'organisation', 'venue', 'mic') + return events + def rig_count(self): event_count = self.filter( (models.Q(start_date__gte=datetime.date.today(), end_date__isnull=True, dry_hire=False, diff --git a/RIGS/views.py b/RIGS/views.py index ea7d2bc9..a0ef2785 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -300,10 +300,9 @@ class SecureAPIRequest(generic.View): # Probably a calendar request start_datetime = datetime.datetime.strptime( start, "%Y-%m-%dT%H:%M:%SZ" ) end_datetime = datetime.datetime.strptime( end, "%Y-%m-%dT%H:%M:%SZ" ) - all_objects = self.models[model].objects + objects = self.models[model].objects.events_in_bounds(start_datetime,end_datetime) + results = [] - filter = Q(start_date__lte=end_datetime) & Q(start_date__gte=start_datetime) - objects = all_objects.filter(filter).select_related('person', 'organisation', 'venue', 'mic').order_by('-start_date') for item in objects: data = { 'pk': item.pk,