diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index ba485a9e..82b94bb4 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -253,7 +253,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.messages.context_processors.messages", ], - 'debug': DEBUG or CI + 'debug': DEBUG }, }, ] diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 45da678f..99c913ad 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -11,7 +11,7 @@ import simplejson from PyPDF2 import PdfFileMerger, PdfFileReader from django.conf import settings from django.contrib import messages -from django.contrib.staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles import finders from django.core import signing from django.core.exceptions import SuspiciousOperation from django.core.mail import EmailMultiAlternatives @@ -274,6 +274,7 @@ class EventArchive(generic.ListView): class EventAuthorise(generic.UpdateView): template_name = 'eventauthorisation_form.html' success_template = 'eventauthorisation_success.html' + preview = False def form_valid(self, form): self.object = form.save() @@ -301,6 +302,7 @@ class EventAuthorise(generic.UpdateView): context['page_title'] = "{}: {}".format(self.event.display_id, self.event.name) if self.event.dry_hire: context['page_title'] += ' Dry Hire' + context['preview'] = self.preview return context def get(self, request, *args, **kwargs): @@ -387,7 +389,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix to=[email], reply_to=[self.request.user.email], ) - css = staticfiles_storage.path('css/email.css') + css = finders.find('css/email.css') html = premailer.Premailer(get_template("eventauthorisation_client_request.html").render(context), external_styles=css).transform() msg.attach_alternative(html, 'text/html') @@ -402,8 +404,7 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView): model = models.Event def render_to_response(self, context, **response_kwargs): - from django.contrib.staticfiles.storage import staticfiles_storage - css = staticfiles_storage.path('css/email.css') + css = finders.find('css/email.css') response = super(EventAuthoriseRequestEmailPreview, self).render_to_response(context, **response_kwargs) assert isinstance(response, HttpResponse) response.content = premailer.Premailer(response.rendered_content, external_styles=css).transform() @@ -417,4 +418,5 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView): 'sent_by': self.request.user.pk, }) context['to_name'] = self.request.GET.get('to_name', None) + context['target'] = 'event_authorise_form_preview' return context diff --git a/RIGS/signals.py b/RIGS/signals.py index e01deef6..e1fc37b0 100644 --- a/RIGS/signals.py +++ b/RIGS/signals.py @@ -6,7 +6,7 @@ from io import BytesIO from PyPDF2 import PdfFileReader, PdfFileMerger from django.conf import settings -from django.contrib.staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles import finders from django.core.cache import cache from django.core.mail import EmailMessage, EmailMultiAlternatives from django.db.models.signals import post_save @@ -63,7 +63,7 @@ def send_eventauthorisation_success_email(instance): reply_to=[settings.AUTHORISATION_NOTIFICATION_ADDRESS], ) - css = staticfiles_storage.path('css/email.css') + css = finders.find('css/email.css') html = Premailer(get_template("eventauthorisation_client_success.html").render(context), external_styles=css).transform() client_email.attach_alternative(html, 'text/html') @@ -121,7 +121,7 @@ def send_admin_awaiting_approval_email(user, request, **kwargs): to=[admin.email], reply_to=[user.email], ) - css = staticfiles_storage.path('css/email.css') + css = finders.find('css/email.css') html = Premailer(get_template("admin_awaiting_approval.html").render(context), external_styles=css).transform() email.attach_alternative(html, 'text/html') diff --git a/RIGS/templates/event_detail.html b/RIGS/templates/event_detail.html index 282f7e53..d9182e3d 100644 --- a/RIGS/templates/event_detail.html +++ b/RIGS/templates/event_detail.html @@ -7,7 +7,7 @@ {% if not request.is_ajax %} {% if perms.RIGS.view_event %}
- {% include 'event_detail_buttons.html' %} + {% include 'partials/event_detail_buttons.html' %}
{% endif %} {% endif %} @@ -77,7 +77,7 @@ {% endif %} {% if not request.is_ajax and perms.RIGS.view_event %}
- {% include 'event_detail_buttons.html' %} + {% include 'partials/event_detail_buttons.html' %}
{% endif %} {% if event.is_rig %} @@ -97,7 +97,7 @@ {% if not request.is_ajax and perms.RIGS.view_event %}
- {% include 'event_detail_buttons.html' %} + {% include 'partials/event_detail_buttons.html' %}
{% endif %} {% endif %} diff --git a/RIGS/templates/event_print.xml b/RIGS/templates/event_print.xml index 8248f95d..133fef1d 100644 --- a/RIGS/templates/event_print.xml +++ b/RIGS/templates/event_print.xml @@ -1,6 +1,5 @@ - diff --git a/RIGS/templates/eventauthorisation_client_request.html b/RIGS/templates/eventauthorisation_client_request.html index bdb72d5f..824bd8f5 100644 --- a/RIGS/templates/eventauthorisation_client_request.html +++ b/RIGS/templates/eventauthorisation_client_request.html @@ -1,10 +1,10 @@ {% extends 'base_client_email.html' %} {% block content %} - +

Hi {{ to_name|default:"there" }},

-

{{ request.user.get_full_name }} has requested that you authorise N{{ object.pk|stringformat:"05d" }} +

{{ request.user.get_full_name }} has requested that you authorise {{ object.display_id }} | {{ object.name }}{% if not to_name %} on behalf of {{ object.person.name }}{% endif %}.

@@ -23,7 +23,7 @@ diff --git a/RIGS/templates/eventauthorisation_form.html b/RIGS/templates/eventauthorisation_form.html index 155cdeb7..771ddeaa 100644 --- a/RIGS/templates/eventauthorisation_form.html +++ b/RIGS/templates/eventauthorisation_form.html @@ -1,9 +1,6 @@ {% extends 'eventauthorisation.html' %} {% load widget_tweaks %} -{% block js %} -{% endblock %} - {% block authorisation %}
@@ -86,7 +83,7 @@
- +
diff --git a/RIGS/templates/eventauthorisation_request.html b/RIGS/templates/eventauthorisation_request.html index de9fa73d..b70c8180 100644 --- a/RIGS/templates/eventauthorisation_request.html +++ b/RIGS/templates/eventauthorisation_request.html @@ -30,14 +30,6 @@ {% render_field form.email type="email" class+="form-control" %}
-
-
- -
-
@@ -48,3 +40,14 @@ }); {% endblock %} + +{% block footer %} +
+
+ Preview + +
+
+{% endblock %} diff --git a/RIGS/templates/partials/auth_details.html b/RIGS/templates/partials/auth_details.html index b788ba48..0c34e984 100644 --- a/RIGS/templates/partials/auth_details.html +++ b/RIGS/templates/partials/auth_details.html @@ -1,15 +1,15 @@
Client Authorisation
-
+
Authorisation Request
{{ object.auth_request_to|yesno:"Yes,No" }}
@@ -22,8 +22,8 @@
To
{{ object.auth_request_to }}
-
 
-
+
+
Authorised
{{ object.authorised|yesno:"Yes,No" }}
diff --git a/RIGS/templates/event_detail_buttons.html b/RIGS/templates/partials/event_detail_buttons.html similarity index 95% rename from RIGS/templates/event_detail_buttons.html rename to RIGS/templates/partials/event_detail_buttons.html index 7e9ead8c..6e402ce5 100644 --- a/RIGS/templates/event_detail_buttons.html +++ b/RIGS/templates/partials/event_detail_buttons.html @@ -9,7 +9,7 @@ {% if event.internal %} - + {% if event.authorised %} Authorised diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 097e4678..07263d67 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -173,7 +173,7 @@ def title_spaced(string): @register.filter(needs_autoescape=True) def namewithnotes(obj, url, autoescape=True): if hasattr(obj, 'notes') and obj.notes is not None and len(obj.notes) > 0: - return mark_safe(obj.name + " ".format(reverse(url, kwargs={'pk': obj.pk}))) + return mark_safe(obj.name + " ".format(reverse(url, kwargs={'pk': obj.pk}))) else: return obj.name diff --git a/RIGS/urls.py b/RIGS/urls.py index 3b44c450..4e7cc6fc 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -132,6 +132,8 @@ urlpatterns = [ name='event_authorise_preview'), re_path(r'^event/(?P\d+)/(?P[-:\w]+)/$', rigboard.EventAuthorise.as_view(), name='event_authorise'), + re_path(r'^event/(?P\d+)/(?P[-:\w]+)/preview/$', rigboard.EventAuthorise.as_view(preview=True), + name='event_authorise_form_preview'), # ICS Calendar - API key authentication re_path(r'^ical/(?P\d+)/(?P\w+)/rigs.ics$', api_key_required(ical.CalendarICS()), diff --git a/assets/templates/partials/asset_buttons.html b/assets/templates/partials/asset_buttons.html index d1941eff..77a3d047 100644 --- a/assets/templates/partials/asset_buttons.html +++ b/assets/templates/partials/asset_buttons.html @@ -5,7 +5,7 @@ {% button 'submit' %} {% elif duplicate %} - + {% else %}
diff --git a/templates/base_embed.html b/templates/base_embed.html index e5615c20..43208abb 100644 --- a/templates/base_embed.html +++ b/templates/base_embed.html @@ -11,10 +11,7 @@ - - -
- + Complete Authorisation Form