mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 16:32:15 +00:00
And now the same for generic forms
This commit is contained in:
@@ -25,15 +25,15 @@ forms.DateField.widget = forms.DateInput(attrs={'type': 'date'})
|
||||
|
||||
class InvoiceIndex(generic.ListView):
|
||||
model = models.Invoice
|
||||
template_name = 'invoice_list_active.html'
|
||||
template_name = 'invoice_list.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(InvoiceIndex, self).get_context_data(**kwargs)
|
||||
total = 0
|
||||
for i in context['object_list']:
|
||||
total += i.balance
|
||||
context['total'] = total
|
||||
context['count'] = len(list(context['object_list']))
|
||||
context['page_title'] = "Outstanding Invoices ({} Events, £{:.2f})".format(len(list(context['object_list'])), total)
|
||||
context['description'] = "Paperwork for these events has been sent to treasury, but the full balance has not yet appeared on a ledger"
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -130,6 +130,12 @@ class InvoiceArchive(generic.ListView):
|
||||
template_name = 'invoice_list_archive.html'
|
||||
paginate_by = 25
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(InvoiceArchive, self).get_context_data(**kwargs)
|
||||
context['page_title'] = "Invoice Archive"
|
||||
context['description'] = "This page displays all invoices: outstanding, paid, and void"
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
q = self.request.GET.get('q', "")
|
||||
|
||||
@@ -169,8 +175,7 @@ class InvoiceWaiting(generic.ListView):
|
||||
total = 0
|
||||
for obj in self.get_objects():
|
||||
total += obj.sum_total
|
||||
context['total'] = total
|
||||
context['count'] = len(self.get_objects())
|
||||
context['page_title'] = "Events for Invoice ({} Events, £{:.2f})".format(len(self.get_objects()), total)
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
{% load widget_tweaks %}
|
||||
{% load static %}
|
||||
{% load multiply from filters %}
|
||||
{% load button from filters %}
|
||||
|
||||
{% block css %}
|
||||
{{ block.super }}
|
||||
@@ -171,11 +172,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 text-right form-hws form-non_rig my-3">
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary" title="Save"><i
|
||||
class="fas fa-save"></i> Save
|
||||
</button>
|
||||
</div>
|
||||
{% button 'submit' %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
{% extends 'base_rigs.html' %}
|
||||
{% load paginator from filters %}
|
||||
{% load button from filters %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Invoices{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-12">
|
||||
<h2>{% block heading %}Invoices{% endblock %}</h2>
|
||||
{% block description %}{% endblock %}
|
||||
{{ description }}
|
||||
{% block search %}{% endblock %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-bordered table-sm">
|
||||
<table class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Invoice #</th>
|
||||
@@ -51,7 +49,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="{% url 'invoice_detail' invoice.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span></a>
|
||||
{% button 'view' url='invoice_detail' pk=invoice.pk %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{% extends 'invoice_list.html' %}
|
||||
|
||||
{% block title %}
|
||||
Outstanding Invoices
|
||||
{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
Outstanding Invoices ({{ count }} Events, £{{ total|floatformat:2 }})
|
||||
{% endblock %}
|
||||
|
||||
{% block description %}
|
||||
<p>Paperwork for these events has been sent to treasury, but the full balance has not yet appeared on a ledger</p>
|
||||
{% endblock %}
|
||||
@@ -1,23 +1,7 @@
|
||||
{% extends 'invoice_list.html' %}
|
||||
|
||||
{% block title %}
|
||||
Invoice Archive
|
||||
{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
All Invoices
|
||||
{% endblock %}
|
||||
|
||||
{% block description %}
|
||||
<p>This page displays all invoices: outstanding, paid, and void</p>
|
||||
{% endblock %}
|
||||
|
||||
{% block search %}
|
||||
<div class="col-md-6">
|
||||
<form class="form form-horizontal">
|
||||
<div class="form-group">
|
||||
<input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}" class="form-control"/>
|
||||
</div>
|
||||
</form>
|
||||
<div class="py-3">
|
||||
{% include 'partials/list_search.html' %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
{% load paginator from filters %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Events for Invoice{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{% static "js/tooltip.js" %}"></script>
|
||||
<script>
|
||||
@@ -15,9 +13,8 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-12">
|
||||
<h2>Events for Invoice ({{count}} Events, £{{ total|floatformat:2 }})</h2>
|
||||
<p>These events have happened, but paperwork has not yet been sent to treasury</p>
|
||||
<div class="table-responsive col-sm-12">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Organisation{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-offset-1 col-sm-10">
|
||||
<h3>{{ object.pk|yesno:"Edit,Add" }} Organisation</h3>
|
||||
|
||||
<form action="{{ form.action|default:request.path }}" method="post" class="form-horizontal">{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% include 'form_errors.html' %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.name.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.name.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.name class+="form-control" placeholder=form.name.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.phone.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.phone.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.phone class+="form-control" type="tel" placeholder=form.phone.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.email.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.email.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.email class+="form-control" type="email" placeholder=form.email.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.address.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.address.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.address class+="form-control" placeholder=form.address.label %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="{{ form.notes.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-10 col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
{% render_field form.union_account %} {{ form.union_account.label }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary pull-right" type="submit"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,68 +0,0 @@
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Person{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-offset-1 col-sm-10">
|
||||
<h3>{{ object.pk|yesno:"Edit,Add" }} Person</h3>
|
||||
|
||||
<form action="{{ form.action|default:request.path }}" method="post" class="form-horizontal">{% csrf_token %}
|
||||
<div class="row">
|
||||
{% include 'form_errors.html' %}
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="{{ form.name.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.name.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.name class+="form-control" placeholder=form.name.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.phone.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.phone.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.phone class+="form-control" type="tel" placeholder=form.phone.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.email.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.email.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.email class+="form-control" type="email" placeholder=form.email.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.address.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.address.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.address class+="form-control" placeholder=form.address.label %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="{{ form.notes.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary pull-right" type="submit"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,82 +0,0 @@
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_rigs.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{{ object.pk|yesno:"Edit,Add" }} Venue{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-offset-1 col-sm-10">
|
||||
<h3>{{ object.pk|yesno:"Edit,Add" }} Venue</h3>
|
||||
|
||||
<form action="{{ form.action|default:request.path }}" method="post" class="form-horizontal">{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% include 'form_errors.html' %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.name.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.name.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.name class+="form-control" placeholder=form.name.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.phone.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.phone.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.phone class+="form-control" type="tel" placeholder=form.phone.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.email.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.email.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.email class+="form-control" type="email" placeholder=form.email.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.address.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.address.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.address class+="form-control" placeholder=form.address.label %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="{{ form.notes.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-10 col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
{% render_field form.three_phase_available %} {{ form.three_phase_available.label }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary pull-right" type="submit"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -152,7 +152,7 @@ class TestEventCreate(BaseRigboardTest):
|
||||
# animation_is_finished doesn't work for whatever reason...
|
||||
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
|
||||
self.assertTrue(modal.is_open)
|
||||
self.assertIn("Add Person", modal.header)
|
||||
self.assertIn("Create Person", modal.header)
|
||||
|
||||
# Fill person form out and submit
|
||||
person_name = "Test Person"
|
||||
@@ -171,7 +171,7 @@ class TestEventCreate(BaseRigboardTest):
|
||||
modal = self.page.add_person()
|
||||
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
|
||||
self.assertTrue(modal.is_open)
|
||||
self.assertIn("Add Person", modal.header)
|
||||
self.assertIn("Create Person", modal.header)
|
||||
|
||||
person_name = "Test Person 2"
|
||||
modal.name = person_name
|
||||
|
||||
@@ -20,7 +20,7 @@ from RIGS import models, forms
|
||||
from assets import models as asset_models
|
||||
from functools import reduce
|
||||
|
||||
from PyRIGS.views import GenericListView, GenericDetailView
|
||||
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin
|
||||
|
||||
|
||||
class PersonList(GenericListView):
|
||||
@@ -48,40 +48,20 @@ class PersonDetail(GenericDetailView):
|
||||
return context
|
||||
|
||||
|
||||
class PersonCreate(generic.CreateView):
|
||||
template_name = 'person_form.html'
|
||||
class PersonCreate(GenericCreateView, ModalURLMixin):
|
||||
model = models.Person
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('person_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('person_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('person_update', 'person_detail')
|
||||
|
||||
|
||||
class PersonUpdate(generic.UpdateView):
|
||||
template_name = 'person_form.html'
|
||||
class PersonUpdate(GenericUpdateView, ModalURLMixin):
|
||||
model = models.Person
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('person_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('person_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('person_update', 'person_detail')
|
||||
|
||||
|
||||
class OrganisationList(GenericListView):
|
||||
@@ -109,40 +89,20 @@ class OrganisationDetail(GenericDetailView):
|
||||
return context
|
||||
|
||||
|
||||
class OrganisationCreate(generic.CreateView):
|
||||
template_name = 'organisation_form.html'
|
||||
class OrganisationCreate(GenericCreateView, ModalURLMixin):
|
||||
model = models.Organisation
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'union_account']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('organisation_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('organisation_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('organisation_update', 'organisation_detail')
|
||||
|
||||
|
||||
class OrganisationUpdate(generic.UpdateView):
|
||||
template_name = 'organisation_form.html'
|
||||
class OrganisationUpdate(GenericUpdateView, ModalURLMixin):
|
||||
model = models.Organisation
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'union_account']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('organisation_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('organisation_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('organisation_update', 'organisation_detail')
|
||||
|
||||
|
||||
class VenueList(GenericListView):
|
||||
@@ -168,37 +128,17 @@ class VenueDetail(GenericDetailView):
|
||||
return context
|
||||
|
||||
|
||||
class VenueCreate(generic.CreateView):
|
||||
template_name = 'venue_form.html'
|
||||
class VenueCreate(GenericCreateView, ModalURLMixin):
|
||||
model = models.Venue
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('venue_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('venue_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('venue_update', 'venue_detail')
|
||||
|
||||
|
||||
class VenueUpdate(generic.UpdateView):
|
||||
template_name = 'venue_form.html'
|
||||
class VenueUpdate(GenericUpdateView, ModalURLMixin):
|
||||
model = models.Venue
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('venue_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('venue_detail', kwargs={
|
||||
'pk': self.object.pk,
|
||||
})
|
||||
return url
|
||||
return self.get_close_url('venue_update', 'venue_detail')
|
||||
|
||||
Reference in New Issue
Block a user