mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Rig paperwork printing enabled
This commit is contained in:
2
.idea/PyRIGS.iml
generated
2
.idea/PyRIGS.iml
generated
@@ -11,7 +11,7 @@
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 2.7.6 virtualenv at D:\Users\Ghost\.virtualenvs\pyrigs old" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 2.7.6 virtualenv at D:\Users\Ghost\.virtualenvs\pyrigs 2" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="sass-stdlib" level="application" />
|
||||
</component>
|
||||
|
||||
@@ -134,4 +134,6 @@ STATIC_DIRS = (
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(BASE_DIR, 'templates'),
|
||||
)
|
||||
)
|
||||
|
||||
TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/pdf/terms.pdf"
|
||||
@@ -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
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'event_update' event.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-edit"></span></a>
|
||||
<a href="{#% url event_print event.pk %#}" class="btn btn-default"><span
|
||||
<a href="{% url 'event_print' event.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-print"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
110
RIGS/templates/RIGS/event_print.xml
Normal file
110
RIGS/templates/RIGS/event_print.xml
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
{% load multiply from filters %}
|
||||
<!DOCTYPE document SYSTEM "rml.dtd">
|
||||
|
||||
<document filename="Event {{ object.id }} - {{ object.name }} - {{ object.start_date }}.pdf">
|
||||
<docinit>
|
||||
<registerTTFont faceName="OpenSans" fileName="{{ fonts.opensans.regular }}"/>
|
||||
<registerTTFont faceName="OpenSans-Bold" fileName="{{ fonts.opensans.bold }}"/>
|
||||
<registerFontFamily name="OpenSans" bold="OpenSans-Bold" boldItalic="OpenSans-BoldItalic"/>
|
||||
</docinit>
|
||||
|
||||
<stylesheet>
|
||||
<initialize>
|
||||
<color id="LightGray" RGB="#D3D3D3"/>
|
||||
</initialize>
|
||||
|
||||
<paraStyle name="style.para" fontName="OpenSans"/>
|
||||
<paraStyle name="blockPara" spaceAfter="5" spaceBefore="5"/>
|
||||
<paraStyle name="style.Heading1" fontName="OpenSans" fontSize="14" leading="10" spaceAfter="10"/>
|
||||
<paraStyle name="style.Heading2" fontName="OpenSans-Bold" fontSize="12" spaceAfter="5"/>
|
||||
<paraStyle name="style.Heading3" fontName="OpenSans" fontSize="11" spaceAfter="5"/>
|
||||
<paraStyle name="center" alignment="center"/>
|
||||
|
||||
<blockTableStyle id="headerTable">
|
||||
<blockFont name="OpenSans-Bold"/>
|
||||
<blockAlignment value="left"/>
|
||||
<blockLeftPadding start="0,0" stop="0,0" length="0"/>
|
||||
<blockBackground start="1,0" stop="1,0" colorName="LightGray"/>
|
||||
<blockBackground start="3,0" stop="3,0" colorName="LightGray"/>
|
||||
<lineStyle kind="box" start="1,0" stop="1,0" colorName="black"/>
|
||||
<lineStyle kind="box" start="3,0" stop="3,0" colorName="black"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="eventDetails">
|
||||
<blockValign value="top"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="itemTable">
|
||||
<blockValign value="top"/>
|
||||
<lineStyle kind="grid" colorName="black" thickness="1" start="0,0" stop="-1,-1"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="totalTable">
|
||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||
<lineStyle cap="default" kind="grid" colorName="black" thickness="1" start="1,0" stop="-1,-1"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="infoTable" keepWithNext="true">
|
||||
<blockLeftPadding start="0,0" stop="-1,-1" length="0"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="paymentTable">
|
||||
<blockBackground colorName="LightGray" start="0,1" stop="3,1"/>
|
||||
<blockFont name="OpenSans-Bold" start="0,1" stop="0,1"/>
|
||||
<blockFont name="OpenSans-Bold" start="2,1" stop="2,1"/>
|
||||
<lineStyle kind="outline" colorName="black" thickness="1" start="0,1" stop="3,1"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="signatureTable">
|
||||
<blockTopPadding length="20" />
|
||||
<blockLeftPadding start="0,0" stop="0,-1" length="0"/>
|
||||
<lineStyle kind="linebelow" start="1,0" stop="1,0" colorName="black"/>
|
||||
<lineStyle kind="linebelow" start="3,0" stop="3,0" colorName="black"/>
|
||||
<lineStyle kind="linebelow" start="5,0" stop="5,0" colorName="black"/>
|
||||
</blockTableStyle>
|
||||
</stylesheet>
|
||||
|
||||
<template>
|
||||
<pageTemplate id="Headed">
|
||||
<pageGraphics>
|
||||
<image file="http://images.nottinghamtec.co.uk/rigs_logo.jpg" x="50" y="702"/>
|
||||
<setFont name="OpenSans-Bold" size="14" leading="10"/>
|
||||
<drawString x="140" y="775">TEC PA & Lighting</drawString>
|
||||
|
||||
<setFont name="OpenSans" size="10"/>
|
||||
<drawString x="140" y="762">Portland Building</drawString>
|
||||
<drawString x="140" y="751">University Park</drawString>
|
||||
<drawString x="140" y="740">Nottingham</drawString>
|
||||
<drawString x="140" y="729">NG7 2RD</drawString>
|
||||
<drawString x="140" y="718">0115 846 8720</drawString>
|
||||
<drawString x="140" y="707">info@nottinghamtec.co.uk</drawString>
|
||||
|
||||
<image file="http://images.nottinghamtec.co.uk/rigs_union_logo.jpg" x="365" y="746"/>
|
||||
|
||||
<drawCenteredString x="302.5" y="50">[{{ copy }} Copy]</drawCenteredString>
|
||||
</pageGraphics>
|
||||
<frame id="jobDetails" x1="50" y1="682" width="495" height="20"/>
|
||||
<frame id="client" x1="50" y1="560" width="150" height="120" topPadding="5"
|
||||
rightPadding="5" bottomPadding="5" leftPadding="5"/>
|
||||
<frame id="venue" x1="221" y1="560" width="150" height="120" topPadding="5"
|
||||
rightPadding="5" bottomPadding="5" leftPadding="5"/>
|
||||
<frame id="event" x1="395" y1="560" width="150" height="120" topPadding="5"
|
||||
rightPadding="5" bottomPadding="5" leftPadding="5"/>
|
||||
<frame id="main" x1="50" y1="65" width="495" height="502"/>
|
||||
</pageTemplate>
|
||||
|
||||
<pageTemplate id="Main">
|
||||
<pageGraphics>
|
||||
<setFont name="OpenSans" size="10"/>
|
||||
<drawCenteredString x="302.5" y="50">[{{ copy }} Copy]</drawCenteredString>
|
||||
</pageGraphics>
|
||||
<frame id="main" x1="50" y1="65" width="495" height="727"/>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
|
||||
<story firstPageTemplate="Headed">
|
||||
{% include "RIGS/event_print_page.xml" %}
|
||||
</story>
|
||||
|
||||
</document>
|
||||
236
RIGS/templates/RIGS/event_print_page.xml
Normal file
236
RIGS/templates/RIGS/event_print_page.xml
Normal file
@@ -0,0 +1,236 @@
|
||||
<setNextFrame name="jobDetails"/>
|
||||
<nextFrame/>
|
||||
<blockTable style="headerTable" colWidths="123,124,123,123">
|
||||
<tr>
|
||||
<td>Event Date:</td>
|
||||
<td>{{ object.start_date }}</td>
|
||||
<td>JOB NUMBER:</td>
|
||||
<td>N{{ object.pk|stringformat:"05d" }}</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
<setNextFrame name="client"/>
|
||||
<nextFrame/>
|
||||
<keepInFrame>
|
||||
<h2>Hirer</h2>
|
||||
<h3>{{ object.person.name }}</h3>
|
||||
<h3>{{ object.organisation.name|default_if_none:"" }}</h3>
|
||||
|
||||
{% if object.person.phone %}
|
||||
<para>Tel: {{ object.person.phone }}</para>
|
||||
{% elif object.organisation.phone %}
|
||||
<para>Tel: {{ object.organisation.phone }}</para>
|
||||
{% endif %}
|
||||
|
||||
{% if object.person.email %}
|
||||
<para>Email: {{ object.person.email }}</para>
|
||||
{% elif object.organisation.email %}
|
||||
<para>Email: {{ object.organisation.email }}</para>
|
||||
{% endif %}
|
||||
</keepInFrame>
|
||||
|
||||
<setNextFrame name="venue"/>
|
||||
<nextFrame/>
|
||||
<keepInFrame>
|
||||
<h2>Venue</h2>
|
||||
<h3>{{ object.venue.name }}</h3>
|
||||
<para>{{ object.venue.address|default_if_none:""|linebreaks }}</para>
|
||||
</keepInFrame>
|
||||
|
||||
<setNextFrame name="event"/>
|
||||
<nextFrame/>
|
||||
<h2>Event Details</h2>
|
||||
<blockTable style="eventDetails" colWidths="75,75">
|
||||
<tr>
|
||||
<td>Start Time</td>
|
||||
<td>
|
||||
<para>{{ object.start_time|time:"H:i" }}
|
||||
<br/>
|
||||
{{ object.start_date|date:"(d/m/Y)" }}
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>End Time</td>
|
||||
<td>
|
||||
<para>{{ object.end_time|time:"H:i" }}
|
||||
<br/>
|
||||
{{ object.end_date|date:"(d/m/Y)" }}
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Earliest Access</td>
|
||||
<td>
|
||||
<para>{{ object.access_at|time:"H:i" }}
|
||||
<br/>
|
||||
{{ object.access_at|date:"d/m/Y" }}
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
<setNextTemplate name="Main"/>
|
||||
<setNextFrame name="main"/>
|
||||
<nextFrame/>
|
||||
|
||||
<blockTable style="itemTable" colWidths="300,80,35,80">
|
||||
<tr>
|
||||
{# Bold tags need to be in a para in order to render in reportlab #}
|
||||
<td>
|
||||
<para>
|
||||
<b>Equipment Details</b>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para>
|
||||
<b>Price</b>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para>
|
||||
<b>Qty</b>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para>
|
||||
<b>Sub-total</b>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
{% for item in object.items.all %}
|
||||
<tr>
|
||||
<td>
|
||||
<para>{{ item.name }}
|
||||
{% if item.description %}
|
||||
<br/>
|
||||
<em>{{ item.description|linebreaks }}</em>
|
||||
{% endif %}
|
||||
</para>
|
||||
</td>
|
||||
<td>£ {{ item.cost|floatformat:2 }}</td>
|
||||
<td>{{ item.quantity }}</td>
|
||||
<td>£ {{ item.total_cost|floatformat:2 }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</blockTable>
|
||||
<blockTable style="totalTable" colWidths="300,115,80">
|
||||
<tr>
|
||||
<td>VAT may be charged at the current rate date of event ({{ object.vat_rate.as_percent|floatformat:2 }}%)</td>
|
||||
<td>Sum-total</td>
|
||||
<td>£ {{ object.sum_total|floatformat:2 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>VAT Registration Number: 116252989</td>
|
||||
<td>VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}%</td>
|
||||
<td>£ {{ object.vat|floatformat:2 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para>
|
||||
<b>The full hire fee is payable at least 10 days before the event.</b>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para>
|
||||
<b>Total</b>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para>
|
||||
<b>£ {{ object.total|floatformat:2 }}</b>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
<blockTable style="infoTable">
|
||||
<tr>
|
||||
<td>
|
||||
<para>Bookings will
|
||||
<b>not</b>
|
||||
be confirmed until payment is received and the contract is signed.
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24 Hour Emergency Contacts: 07825 065681 or 07825 065678</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
<blockTable style="paymentTable" colWidths="100,146,93,154">
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>Payment Received:</td>
|
||||
<td>{{ object.payment_received }}</td>
|
||||
<td>Payment Method:</td>
|
||||
<td>{{ object.payment_method }}</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
</blockTable>
|
||||
|
||||
<para style="blockPara">
|
||||
<b>To be signed on booking:</b>
|
||||
</para>
|
||||
{% if object.organisation.union_account %}
|
||||
<para style="blockPara">
|
||||
<i>
|
||||
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>
|
||||
</para>
|
||||
<para style="blockPara">
|
||||
<i>
|
||||
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.
|
||||
</i>
|
||||
</para>
|
||||
|
||||
<para style="blockPara">
|
||||
<b>
|
||||
Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
|
||||
</b>
|
||||
</para>
|
||||
|
||||
<para style="blockPara">
|
||||
Please return this form directly to TEC PA & Lighting and not the Students' Union Finance Department.
|
||||
</para>
|
||||
|
||||
<blockTable style="signatureTable" colWidths="70,100,325">
|
||||
<tr>
|
||||
<td>Account Code</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
{% else %}
|
||||
<para style="blockPara">
|
||||
<i>
|
||||
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.
|
||||
</i>
|
||||
</para>
|
||||
|
||||
<para style="blockPara">
|
||||
<b>
|
||||
Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
|
||||
</b>
|
||||
</para>
|
||||
|
||||
{% include "RIGS/event_print_signature.xml" %}
|
||||
|
||||
<para style="blockPara">
|
||||
<b>To be signed on the day of the event/hire:</b>
|
||||
</para>
|
||||
<para style="blockPara">
|
||||
<i>
|
||||
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.
|
||||
</i>
|
||||
</para>
|
||||
{% endif %}
|
||||
|
||||
{% include "RIGS/event_print_signature.xml" %}
|
||||
10
RIGS/templates/RIGS/event_print_signature.xml
Normal file
10
RIGS/templates/RIGS/event_print_signature.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<blockTable style="signatureTable" colWidths="50,120,60,120,35,110">
|
||||
<tr>
|
||||
<td>Signature</td>
|
||||
<td></td>
|
||||
<td>Print Name</td>
|
||||
<td></td>
|
||||
<td>Date</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
@@ -59,6 +59,9 @@ urlpatterns = patterns('',
|
||||
url(r'^event/(?P<pk>\d+)/$',
|
||||
permission_required_with_403('RIGS.view_event')(rigboard.EventDetail.as_view()),
|
||||
name='event_detail'),
|
||||
url(r'^event/(?P<pk>\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'),
|
||||
|
||||
@@ -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
|
||||
z3c.rlm==2.7.2
|
||||
pyPDF2==1.23
|
||||
Reference in New Issue
Block a user