diff --git a/.idea/PyRIGS.iml b/.idea/PyRIGS.iml
index 20d6af48..0952a30f 100644
--- a/.idea/PyRIGS.iml
+++ b/.idea/PyRIGS.iml
@@ -11,7 +11,7 @@
-
+
diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py
index 3bd31598..1f6bdbfe 100644
--- a/PyRIGS/settings.py
+++ b/PyRIGS/settings.py
@@ -134,4 +134,6 @@ STATIC_DIRS = (
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
-)
\ No newline at end of file
+)
+
+TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/pdf/terms.pdf"
\ No newline at end of file
diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py
index 1b28aa54..6c0cea8d 100644
--- a/RIGS/rigboard.py
+++ b/RIGS/rigboard.py
@@ -1,9 +1,20 @@
+import os
+import cStringIO as StringIO
+from io import BytesIO
+import urllib2
+
from django.views import generic
from django.core.urlresolvers import reverse_lazy
+from django.shortcuts import get_object_or_404
+from django.template import Context, RequestContext
+from django.template.loader import get_template
+from django.conf import settings
+from django.http import HttpResponse
+from z3c.rml import rml2pdf
+from PyPDF2 import PdfFileMerger, PdfFileReader
from RIGS import models, forms
-
__author__ = 'ghost'
@@ -35,6 +46,7 @@ class EventCreate(generic.CreateView):
def get_success_url(self):
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
+
class EventUpdate(generic.UpdateView):
model = models.Event
form_class = forms.EventForm
@@ -46,3 +58,43 @@ class EventUpdate(generic.UpdateView):
def get_success_url(self):
return reverse_lazy('event_detail', kwargs={'pk': self.object.pk})
+
+
+class EventPrint(generic.View):
+ def get(self, request, pk):
+ object = get_object_or_404(models.Event, pk=pk)
+ template = get_template('RIGS/event_print.xml')
+ copies = ('TEC', 'Client')
+ context = RequestContext(request, {
+ 'object': object,
+ 'fonts': {
+ 'opensans': {
+ 'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF',
+ 'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF',
+ }
+ },
+ })
+
+ merger = PdfFileMerger()
+
+ for copy in copies:
+ context['copy'] = copy
+ rml = template.render(context)
+ buffer = StringIO.StringIO()
+
+ buffer = rml2pdf.parseString(rml)
+
+ merger.append(PdfFileReader(buffer))
+
+ buffer.close()
+
+ terms = urllib2.urlopen(settings.TERMS_OF_HIRE_URL)
+ merger.append(StringIO.StringIO(terms.read()))
+
+ merged = BytesIO()
+ merger.write(merged)
+
+ response = HttpResponse(content_type='application/pdf')
+ response['Content-Disposition'] = "filename=N%05d | %s.pdf" % (object.pk, object.name)
+ response.write(merged.getvalue())
+ return response
diff --git a/RIGS/templates/RIGS/event_detail.html b/RIGS/templates/RIGS/event_detail.html
index 2a731246..fe410f0c 100644
--- a/RIGS/templates/RIGS/event_detail.html
+++ b/RIGS/templates/RIGS/event_detail.html
@@ -11,7 +11,7 @@
diff --git a/RIGS/templates/RIGS/event_print.xml b/RIGS/templates/RIGS/event_print.xml
new file mode 100644
index 00000000..1a586705
--- /dev/null
+++ b/RIGS/templates/RIGS/event_print.xml
@@ -0,0 +1,110 @@
+
+{% load multiply from filters %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TEC PA & Lighting
+
+
+ Portland Building
+ University Park
+ Nottingham
+ NG7 2RD
+ 0115 846 8720
+ info@nottinghamtec.co.uk
+
+
+
+ [{{ copy }} Copy]
+
+
+
+
+
+
+
+
+
+
+
+ [{{ copy }} Copy]
+
+
+
+
+
+
+ {% include "RIGS/event_print_page.xml" %}
+
+
+
\ No newline at end of file
diff --git a/RIGS/templates/RIGS/event_print_page.xml b/RIGS/templates/RIGS/event_print_page.xml
new file mode 100644
index 00000000..4e58b233
--- /dev/null
+++ b/RIGS/templates/RIGS/event_print_page.xml
@@ -0,0 +1,236 @@
+
+
+
+
+ | Event Date: |
+ {{ object.start_date }} |
+ JOB NUMBER: |
+ N{{ object.pk|stringformat:"05d" }} |
+
+
+
+
+
+
+Hirer
+{{ object.person.name }}
+{{ object.organisation.name|default_if_none:"" }}
+
+{% if object.person.phone %}
+ Tel: {{ object.person.phone }}
+{% elif object.organisation.phone %}
+ Tel: {{ object.organisation.phone }}
+{% endif %}
+
+{% if object.person.email %}
+ Email: {{ object.person.email }}
+{% elif object.organisation.email %}
+ Email: {{ object.organisation.email }}
+{% endif %}
+
+
+
+
+
+Venue
+{{ object.venue.name }}
+{{ object.venue.address|default_if_none:""|linebreaks }}
+
+
+
+
+Event Details
+
+
+ | Start Time |
+
+ {{ object.start_time|time:"H:i" }}
+
+ {{ object.start_date|date:"(d/m/Y)" }}
+
+ |
+
+
+ | End Time |
+
+ {{ object.end_time|time:"H:i" }}
+
+ {{ object.end_date|date:"(d/m/Y)" }}
+
+ |
+
+
+ | Earliest Access |
+
+ {{ object.access_at|time:"H:i" }}
+
+ {{ object.access_at|date:"d/m/Y" }}
+
+ |
+
+
+
+
+
+
+
+
+
+ {# Bold tags need to be in a para in order to render in reportlab #}
+ |
+
+ Equipment Details
+
+ |
+
+
+ Price
+
+ |
+
+
+ Qty
+
+ |
+
+
+ Sub-total
+
+ |
+
+{% for item in object.items.all %}
+
+
+ {{ item.name }}
+ {% if item.description %}
+
+ {{ item.description|linebreaks }}
+ {% endif %}
+
+ |
+ £ {{ item.cost|floatformat:2 }} |
+ {{ item.quantity }} |
+ £ {{ item.total_cost|floatformat:2 }} |
+
+{% endfor %}
+
+
+
+ | VAT may be charged at the current rate date of event ({{ object.vat_rate.as_percent|floatformat:2 }}%) |
+ Sum-total |
+ £ {{ object.sum_total|floatformat:2 }} |
+
+
+ | VAT Registration Number: 116252989 |
+ VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}% |
+ £ {{ object.vat|floatformat:2 }} |
+
+
+ |
+
+ The full hire fee is payable at least 10 days before the event.
+
+ |
+
+
+ Total
+
+ |
+
+
+ £ {{ object.total|floatformat:2 }}
+
+ |
+
+
+
+
+
+ |
+ Bookings will
+ not
+ be confirmed until payment is received and the contract is signed.
+
+ |
+
+
+ | 24 Hour Emergency Contacts: 07825 065681 or 07825 065678 |
+
+
+
+
+
+
+ | Payment Received: |
+ {{ object.payment_received }} |
+ Payment Method: |
+ {{ object.payment_method }} |
+
+
+
+
+
+To be signed on booking:
+
+{% if object.organisation.union_account %}
+
+
+ I agree that am authorised to sign this invoice. I agree that I am the President/Treasurer of the hirer, or
+ that I have provided written permission from either the President or Treasurer of the hirer stating that I can
+ sign for this invoice.
+
+
+
+
+ I have read, understood and fully accepted the current conditions of hire. I agree to return any dry hire
+ items to TEC PA & Lighting in the same condition at the end of the hire period.
+
+
+
+
+
+ Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
+
+
+
+
+ Please return this form directly to TEC PA & Lighting and not the Students' Union Finance Department.
+
+
+
+
+ | Account Code |
+ |
+ |
+
+
+
+{% else %}
+
+
+ I, the hirer, have read, understand and fully accept the current conditions of hire. This document forms a
+ binding contract between TEC PA & Lighting and the hirer, the aforementioned conditions of hire forming
+ an integral part of it.
+
+
+
+
+
+ Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
+
+
+
+ {% include "RIGS/event_print_signature.xml" %}
+
+
+ To be signed on the day of the event/hire:
+
+
+
+ I, the hirer, have received the goods/services as requested and in good order. I agree to return any dry hire
+ items to TEC PA & Lighting in a similar condition at the end of the hire period.
+
+
+{% endif %}
+
+{% include "RIGS/event_print_signature.xml" %}
\ No newline at end of file
diff --git a/RIGS/templates/RIGS/event_print_signature.xml b/RIGS/templates/RIGS/event_print_signature.xml
new file mode 100644
index 00000000..991fb8f4
--- /dev/null
+++ b/RIGS/templates/RIGS/event_print_signature.xml
@@ -0,0 +1,10 @@
+
+
+ | Signature |
+ |
+ Print Name |
+ |
+ Date |
+ |
+
+
\ No newline at end of file
diff --git a/RIGS/urls.py b/RIGS/urls.py
index f2a4c312..ab811bb2 100644
--- a/RIGS/urls.py
+++ b/RIGS/urls.py
@@ -59,6 +59,9 @@ urlpatterns = patterns('',
url(r'^event/(?P\d+)/$',
permission_required_with_403('RIGS.view_event')(rigboard.EventDetail.as_view()),
name='event_detail'),
+ url(r'^event/(?P\d+)/print/$',
+ permission_required_with_403('RIGS.view_event')(rigboard.EventPrint.as_view()),
+ name='event_print'),
url(r'^event/create/$',
permission_required_with_403('RIGS.add_event')(rigboard.EventCreate.as_view()),
name='event_create'),
diff --git a/db.sqlite3 b/db.sqlite3
index 624a04c3..bec0d22a 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/requirements.txt b/requirements.txt
index c7a586a1..8b7a7ba6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,4 +7,5 @@ sqlparse==0.1.13
simplejson==3.6.5
lxml==3.4.1
pil==1.1.7
-z3c.rlm==2.7.2
\ No newline at end of file
+z3c.rlm==2.7.2
+pyPDF2==1.23
\ No newline at end of file
diff --git a/z3c/rml/tests/expected/tag-selectField.pdf b/z3c/rml/tests/expected/tag-selectField.pdf
deleted file mode 100644
index e69de29b..00000000