Added all event views and urls.

Added event detail template.

Added itemisation templates.
This commit is contained in:
tec
2014-11-11 20:08:36 +00:00
parent d1b351a201
commit 806215f35e
6 changed files with 220 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
from django.views import generic
from django.core.urlresolvers import reverse_lazy
from RIGS import models
__author__ = 'ghost'
@@ -13,4 +14,29 @@ class RigboardIndex(generic.TemplateView):
# call out method to get current events
context['events'] = models.Event.objects.current_events()
return context
return context
class EventDetail(generic.DetailView):
model = models.Event
class EventCreate(generic.CreateView):
model = models.Event
def get_context_data(self, **kwargs):
context = super(EventCreate, self).get_context_data(**kwargs)
context['edit'] = True
return context
def get_success_url(self):
return reverse_laze('event_detail', kwargs={'pk': self.object.pk})
class EventUpdate(generic.UpdateView):
model = models.Event
def get_context_data(self, **kwargs):
context = super(EventUpdate, self).get_context_data(**kwargs)
context['edit'] = True
return context
def get_success_url(self):
return reverse_laze('event_detail', kwargs={'pk': self.object.pk})

View File

@@ -0,0 +1,117 @@
{% extends 'base.html' %}
{% block title %}Event {% if object.is_rig %}N{{object.pk|stringformat:"05d"}}{% else %}{{object.pk}}{% endif %}{% endblock %}
{% block content %}
<div class="col-sm-12">
<div class="col-sm-8">
<h1>N{{object.pk|stringformat:"05d"}}</h1>
</div>
<div class="col-sm-4 text-right">
<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 class="glyphicon glyphicon-print"></span></a>
</div>
</div>
</div>
{% if object.is_rig %}
{# only need contact details for a rig #}
<div class="col-sm-5">
<div class="panel panel-default">
<div class="panel-heading">Contact Details</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Person</dt>
<dd>{{object.person.name}}</dd>
<dt>Email</dt>
<dd>{{object.person.email}}</dd>
<dt>Phone Number</dt>
<dd>{{object.person.phone}}</dd>
</dl>
</div>
</div>
{% if event.organisation %}
<div class="panel panel-default">
<div class="panel-heading">Organisation</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Organisation</dt>
<dd>{{object.organisation.name}}</dd>
<dt>Phone Number</dt>
<dd>{{object.organisation.phone}}</dd>
<dt>Has SU Account</dt>
<dd>{{event.organisation.union_account|yesno|capfirst}}</dd>
</dl>
</div>
</div>
{% endif %}
</div>
{% endif %}
<div class="col-sm-{{event.is_rig|yesno:"7,12"}}">
<div class="panel panel-info">
<div class="panel-heading">{{object.name}}</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Event Venue</dt>
<dd>{{object.venue}}</dd>
<dt>Event MIC</dt>
<dd>{{event.mic.get_full_name}}</dd>
<dd>&nbsp;</dd>
{% if event.is_rig %}
<dt>Crew Meet</dt>
<dd>{{event.meet_at|date:"d M Y H:i"|default:""}}</dd>
<dd>{{event.meet_info|default:""}}</dd>
<dt>Access From</dt>
<dd>{{event.access_at|date:"d M Y H:i"|default:""}}</dd>
{% endif %}
<dt>Event Starts</dt>
<dd>{{event.start_date|date:"d M Y"}} {{event.start_time|date:"H:i"}}</dd>
<dt>Event Ends</dt>
<dd>{{event.end_date|date:"d M Y"}} {{event.end_time|date:"H:i"}}</dd>
<dd>&nbsp;</dd>
<dt>Event Description</dt>
<dd>{{event.description|linebreaksbr}}</dd>
</dl>
</div>
</div>
</div>
<div class="col-sm-12 text-right">
<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 class="glyphicon glyphicon-print"></span></a>
</div>
</div>
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">Event Details</div>
<div class="panel-body">
<div class="well well-sm">
<h4>Notes</h4>
{{event.notes|linebreaksbr}}
</div>
{% if event.is_rig %}
{% include 'RIGS/item_table.html' %}
{% endif %}
</div>
</div>
</div>
<div class="col-sm-12 text-right">
<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 class="glyphicon glyphicon-print"></span></a>
</div>
<div>Last edited at {{object.last_edited_at|date:"SHORT_DATETIME_FORMAT"}} by {{object.last_edited_by}}.</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,25 @@
<tr id="item-{{item.pk}}" data-url="{#% url item_row item.pk %#}" data-pk="{{item.pk}}">
<td>
{{ item.name }}
{% if item.description %}
<br />
<em>{{item.description|linebreaksbr}}</em>
{% endif %}
</td>
<td>£&nbsp;{{item.cost}}</td>
<td>{{item.quantity}}</td>
<td class="sub-total" data-subtotal="{{item.total_cost}}">£&nbsp;{{item.total_cost}}</td>
{% if response.edit %}
<td class="vert-align text-right">
<button type="button" class="item-edit btn btn-xs btn-default"
data-pk="{{item.pk}}"
data-toggle="modal" data-target="#itemModal">
<span class="glyphicon glyphicon-edit"></span>
</button>
<button type="button" class="item-delete btn btn-xs btn-danger"
data-pk="{{item.pk}}">
<span class="glyphicon glyphicon-remove"></span>
</button>
</td>
{% endif %}
</tr>

View File

@@ -0,0 +1,42 @@
<div class="panel">
<table class="table table-hover" id="item-table">
<thead>
<tr>
<td>Item</td>
<td>Price</td>
<td>Quantity</td>
<td>Sub-total</td>
{% if response.edit %}
<td class="text-right">
<button type="button" class="btn btn-default btn-xs item-add"
data-url="{#% url eventitem_add object.pk %#}" data-toggle="modal"
data-target="#itemModal">
<span class="glyphicon glyphicon-plus"></span>
</button>
</td>
{% endif %}
</tr>
</thead>
<tbody>
{% for item in object.items.all %}
{% include 'RIGS/item_row.html' %}
{% endfor %}
</tbody>
<tfoot>
<tr>
<td rowspan="3" colspan="2"></td>
<td>Sum Total</td>
<td colspan="2">£ <span id="sumtotal">{{object.sum_total}}</span></td>
</tr>
<tr>
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @
{{object.vat_rate.as_percent|floatformat}}%</td>
<td colspan="2">£ <span id="vat">{{object.vat|floatformat:2}}</span></td>
</tr>
<tr>
<td>Total</td>
<td colspan="2">£ <span id="total">{{object.total|floatformat:2}}</span></td>
</tr>
</tfoot>
</table>
</div>

View File

@@ -55,5 +55,14 @@ urlpatterns = patterns('',
# Rigboard
url(r'^rigboard/$', rigboard.RigboardIndex.as_view(), name='rigboard'),
url(r'^event/(?P<pk>\d+)/$',
permission_required_with_403('RIGS.view_event')(rigboard.EventDetail.as_view()),
name='event_detail'),
url(r'^event/create/$',
permission_required_with_403('RIGS.add_event')(rigboard.EventCreate.as_view()),
name='event_create'),
url(r'^event/(?P<pk>\d+)/edit/$',
permission_required_with_403('RIGS.change_event')(rigboard.EventUpdate.as_view()),
name='event_update'),
)

Binary file not shown.