From 452b56c54bed76974453077406f68e3bef25c9b8 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 20:46:15 +0100 Subject: [PATCH 01/11] 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 338694248e8ce22ae948ea3a5f875a961ab3270c Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 22:35:52 +0100 Subject: [PATCH 02/11] 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 d497e6729f613ad8235210963e008fba04af505d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 22:54:58 +0100 Subject: [PATCH 03/11] 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 346f3a91948a758910c536e8eb394188e04b2f34 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 23:26:02 +0100 Subject: [PATCH 04/11] 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 51b28662e54da7df71d621bede4c0035ff0b467a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 28 Jun 2015 23:29:06 +0100 Subject: [PATCH 05/11] 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 d5da0e90d82790b1cf2c071bdaf2a91867f36da9 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 00:44:34 +0100 Subject: [PATCH 06/11] 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 ab516c2f90a8480cae3d1d1d77850d88fe045353 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 12:09:31 +0100 Subject: [PATCH 07/11] 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 0b63bbcc5b2f8859dcaae11c956e7d9a43ab4afd Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 14:42:53 +0100 Subject: [PATCH 08/11] 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, From e7c39c2b8148a8ac300fc7cccf8e58e9b8798ec9 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 23:27:10 +0100 Subject: [PATCH 09/11] Removed special characters from paperwork filenames - issue #103 --- RIGS/finance.py | 5 ++++- RIGS/models.py | 2 +- RIGS/rigboard.py | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RIGS/finance.py b/RIGS/finance.py index e0f7ec7a..2ae0fc47 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -14,6 +14,7 @@ from z3c.rml import rml2pdf from RIGS import models +import re class InvoiceIndex(generic.ListView): model = models.Invoice @@ -63,8 +64,10 @@ class InvoicePrint(generic.View): pdfData = buffer.read() + escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name) + response = HttpResponse(content_type='application/pdf') - response['Content-Disposition'] = "filename=Invoice %05d | %s.pdf" % (invoice.pk, object.name) + response['Content-Disposition'] = "filename=Invoice %05d | %s.pdf" % (invoice.pk, escapedEventName) response.write(pdfData) return response diff --git a/RIGS/models.py b/RIGS/models.py index 34f65724..4a86d9df 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -355,7 +355,7 @@ class Event(models.Model, RevisionMixin): return reverse_lazy('event_detail', kwargs={'pk': self.pk}) def __str__(self): - return str(self.pk) + ": " + self.name + return unicode(self.pk) + ": " + self.name class Meta: permissions = ( diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 790a46f4..9853d9d0 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -124,7 +124,10 @@ class EventPrint(generic.View): merger.write(merged) response = HttpResponse(content_type='application/pdf') - response['Content-Disposition'] = "filename=N%05d | %s.pdf" % (object.pk, object.name) + + escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name) + + response['Content-Disposition'] = "filename=N%05d | %s.pdf" % (object.pk, escapedEventName) response.write(merged.getvalue()) return response From fa63328c4271ed31e5ea28a9627a16bbdb07b764 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 21 Jul 2015 21:24:58 +0100 Subject: [PATCH 10/11] Enable vagrant env for development. --- .gitignore | 3 +- Vagrantfile | 133 +++++++++++++++++++++++ config/vagrant.yml | 11 ++ config/vagrant/build_dependency_setup.sh | 16 +++ config/vagrant/foreman_setup.sh | 36 ++++++ config/vagrant/git_setup.sh | 14 +++ config/vagrant/postgresql_setup.sh | 112 +++++++++++++++++++ config/vagrant/python_setup.sh | 23 ++++ config/vagrant/virtualenv_setup.sh | 66 +++++++++++ 9 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile create mode 100644 config/vagrant.yml create mode 100644 config/vagrant/build_dependency_setup.sh create mode 100644 config/vagrant/foreman_setup.sh create mode 100644 config/vagrant/git_setup.sh create mode 100644 config/vagrant/postgresql_setup.sh create mode 100644 config/vagrant/python_setup.sh create mode 100644 config/vagrant/virtualenv_setup.sh diff --git a/.gitignore b/.gitignore index 064616b6..9a6f7595 100644 --- a/.gitignore +++ b/.gitignore @@ -99,4 +99,5 @@ atlassian-ide-plugin.xml # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties -crashlytics-build.properties \ No newline at end of file +crashlytics-build.properties +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..73406a80 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,133 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +require 'yaml' + +unless File.exist?('config/vagrant.yml') + raise "There is no config/vagrant.yml file.\nCopy config/vagrant.template.yml, make any changes you need, then try again." +end + +settings = YAML.load_file 'config/vagrant.yml' + +$script = <