Misc fixes

This commit is contained in:
2020-08-30 10:45:38 +01:00
parent 9198724748
commit bfe80db85e
10 changed files with 101 additions and 69 deletions

View File

@@ -230,6 +230,7 @@ class PaymentCreate(generic.CreateView):
class PaymentDelete(generic.DeleteView): class PaymentDelete(generic.DeleteView):
model = models.Payment model = models.Payment
template_name = 'payment_confirm_delete.html'
def get_success_url(self): def get_success_url(self):
return self.request.POST.get('next') return self.request.POST.get('next')

View File

@@ -199,13 +199,13 @@ class EventChecklistForm(forms.ModelForm):
self.items['v' + str(pk)] = item self.items['v' + str(pk)] = item
crewmembers = {key: val for key, val in self.data.items() crewmembers = {key: val for key, val in self.data.items()
if key.startswith('crewmember')} if key.startswith('crewmember')}
other_fields = ['start','role','end'] other_fields = ['start', 'role', 'end']
for key in crewmembers: for key in crewmembers:
pk = int(key.split('_')[1]) pk = int(key.split('_')[1])
for field in other_fields: for field in other_fields:
value = self.data['{}_{}'.format(field,pk)] value = self.data['{}_{}'.format(field, pk)]
if value == '': if value == '':
raise forms.ValidationError('Add a {} to crewmember {}'.format(field, pk), code='{}_mismatch'.format(field)) raise forms.ValidationError('Add a {} to crewmember {}'.format(field, pk), code='{}_mismatch'.format(field))

View File

@@ -0,0 +1,43 @@
# Generated by Django 3.1 on 2020-08-30 09:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('RIGS', '0049_auto_20200829_2313'),
]
operations = [
migrations.AlterField(
model_name='eventchecklist',
name='fd_earth_fault',
field=models.IntegerField(help_text='Earth Fault Loop Impedance (Z<small>S</small>)', verbose_name='Earth Fault Loop Impedance'),
),
migrations.AlterField(
model_name='eventchecklist',
name='fd_phase_rotation',
field=models.BooleanField(help_text='Phase Rotation<br><small>(if required)</small>', verbose_name='Phase Rotation'),
),
migrations.AlterField(
model_name='eventchecklist',
name='fd_pssc',
field=models.IntegerField(help_text='Prospective Short Circuit Current', verbose_name='PSCC'),
),
migrations.AlterField(
model_name='eventchecklist',
name='fd_voltage_l1',
field=models.IntegerField(help_text='L1 - N', verbose_name='First Distro Voltage L1-N'),
),
migrations.AlterField(
model_name='eventchecklist',
name='fd_voltage_l2',
field=models.IntegerField(help_text='L2 - N', verbose_name='First Distro Voltage L2-N'),
),
migrations.AlterField(
model_name='eventchecklist',
name='fd_voltage_l3',
field=models.IntegerField(help_text='L3 - N', verbose_name='First Distro Voltage L3-N'),
),
]

View File

@@ -666,12 +666,12 @@ class EventChecklist(models.Model, RevisionMixin):
source_rcd = models.BooleanField(help_text="Source RCD protected?<br><small>(if cable is more than 3m long) </small>") source_rcd = models.BooleanField(help_text="Source RCD protected?<br><small>(if cable is more than 3m long) </small>")
labelling = models.BooleanField(help_text="Appropriate and clear labelling on distribution and cabling?") labelling = models.BooleanField(help_text="Appropriate and clear labelling on distribution and cabling?")
# First Distro # First Distro
fd_voltage_l1 = models.IntegerField(help_text="L1 - N") fd_voltage_l1 = models.IntegerField(verbose_name="First Distro Voltage L1-N", help_text="L1 - N")
fd_voltage_l2 = models.IntegerField(help_text="L2 - N") fd_voltage_l2 = models.IntegerField(verbose_name="First Distro Voltage L2-N", help_text="L2 - N")
fd_voltage_l3 = models.IntegerField(help_text="L3 - N") fd_voltage_l3 = models.IntegerField(verbose_name="First Distro Voltage L3-N", help_text="L3 - N")
fd_phase_rotation = models.BooleanField(help_text="Phase Rotation<br><small>(if required)</small>") fd_phase_rotation = models.BooleanField(verbose_name="Phase Rotation", help_text="Phase Rotation<br><small>(if required)</small>")
fd_earth_fault = models.IntegerField(help_text="Earth Fault Loop Impedance (Z<small>S</small>)") fd_earth_fault = models.IntegerField(verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
fd_pssc = models.IntegerField(help_text="Prospective Short Circuit Current") fd_pssc = models.IntegerField(verbose_name="PSCC", help_text="Prospective Short Circuit Current")
all_rcds_tested = models.BooleanField(help_text="All circuit RCDs tested?<small>(using test button)</small>") all_rcds_tested = models.BooleanField(help_text="All circuit RCDs tested?<small>(using test button)</small>")
public_sockets_tested = models.BooleanField(help_text="Public/Performer accessible circuits tested?<small>(using socket tester)</small>") public_sockets_tested = models.BooleanField(help_text="Public/Performer accessible circuits tested?<small>(using socket tester)</small>")

View File

@@ -286,7 +286,7 @@
<tr> <tr>
<td>{% render_field form.fd_voltage_l1 class+="form-control" %}</td> <td>{% render_field form.fd_voltage_l1 class+="form-control" %}</td>
<td>{% render_field form.fd_voltage_l2 class+="form-control" %}</td> <td>{% render_field form.fd_voltage_l2 class+="form-control" %}</td>
<td>{% render_field form.fd_voltage_l1 class+="form-control" %}</td> <td>{% render_field form.fd_voltage_l3 class+="form-control" %}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{{object|help_text:'fd_phase_rotation'|safe}}</th> <th scope="row">{{object|help_text:'fd_phase_rotation'|safe}}</th>

View File

@@ -96,17 +96,12 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="card card-default"> <div class="card">
<div class="card-body"> {% with object.event as object %}
{% with object.event as object %} {% include 'item_table.html' %}
{% include 'item_table.html' %} {% endwith %}
{% endwith %}
</div>
</div> </div>
</div> </div>
<div class="col-12 text-right">
{% include 'partials/last_edited.html' with target="invoice_history" %}
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -4,48 +4,40 @@
{% block title %}Add Payment{% endblock %} {% block title %}Add Payment{% endblock %}
{% block content %} {% block content %}
<div class="row"> <form action="{{ form.action|default:request.path }}" method="POST">
<div class="col-sm"> {% csrf_token %}
<form action="{{ form.action|default:request.path }}" method="POST"> <input type="hidden" name="{{ form.invoice.name }}" value="{{ form.invoice.value }}"/>
{% csrf_token %} {% include 'form_errors.html' %}
<input type="hidden" name="{{ form.invoice.name }}" value="{{ form.invoice.value }}"/> <div class="row pt-3">
<label class="col-sm-4 control-label"
<div class="row"> for="{{ form.date.id_for_label }}">{{ form.date.label }}</label>
{% include 'form_errors.html' %} <div class="col-sm-8">
<div class="form-group col-sm"> {% render_field form.date class+="form-control" %}
<label class="col-sm-2 control-label" </div>
for="{{ form.date.id_for_label }}">{{ form.date.label }}</label>
<div class="col-sm-10">
{% render_field form.date class+="form-control" %}
</div>
</div>
<div class="form-group col-xs-12">
<label class="col-sm-2 control-label"
for="{{ form.amount.id_for_label }}">{{ form.amount.label }}</label>
<div class="col-sm-10">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">£</span>
</div>
{% render_field form.amount class+="form-control" %}
</div>
</div>
</div>
<div class="form-group col-sm">
<label class="col-sm-2 control-label"
for="{{ form.method.id_for_label }}">{{ form.method.label }}</label>
<div class="col-sm-10">
{% render_field form.method class+="form-control" %}
</div>
</div>
<div class="float-right col-sm">
<div class="form-group">
<input type="submit" class="form-control btn btn-primary"/>
</div>
</div>
</div>
</form>
</div> </div>
</div> <div class="row pt-3">
<label class="col-sm-4 control-label"
for="{{ form.amount.id_for_label }}">{{ form.amount.label }}</label>
<div class="col-sm-8">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">£</span>
</div>
{% render_field form.amount class+="form-control" %}
</div>
</div>
</div>
<div class="row pt-3">
<label class="col-sm-4 control-label"
for="{{ form.method.id_for_label }}">{{ form.method.label }}</label>
<div class="col-sm-8">
{% render_field form.method class+="form-control" %}
</div>
</div>
<div class="row pt-3">
<div class="col-sm-12 text-right">
<input type="submit" class="form-control btn btn-primary"/>
</div>
</div>
</form>
{% endblock %} {% endblock %}

View File

@@ -137,6 +137,7 @@ def profile_by_index(value):
else: else:
return "" return ""
@register.filter @register.filter
def next(alist, current_index): def next(alist, current_index):
""" """
@@ -144,6 +145,6 @@ def next(alist, current_index):
Otherwise returns an empty string. Otherwise returns an empty string.
""" """
try: try:
return alist[int(current_index) + 1] # access the next element return alist[int(current_index) + 1] # access the next element
except: except BaseException:
return '' # return empty string in case of exception return '' # return empty string in case of exception

View File

@@ -4,7 +4,7 @@
<div class="input-group-prepend"> <div class="input-group-prepend">
<input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" /> <input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" />
</div> </div>
<select id="search-options" class="custom-select form-control"> <select id="search-options" class="custom-select form-control" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px;">
<option selected data-action="{% url 'event_archive' %}" href="#">Events</option> <option selected data-action="{% url 'event_archive' %}" href="#">Events</option>
<option data-action="{% url 'person_list' %}" href="#">People</option> <option data-action="{% url 'person_list' %}" href="#">People</option>
<option data-action="{% url 'organisation_list' %}" href="#">Organisations</option> <option data-action="{% url 'organisation_list' %}" href="#">Organisations</option>
@@ -16,7 +16,7 @@
<option data-action="{% url 'supplier_list' %}" href="#">Suppliers</option> <option data-action="{% url 'supplier_list' %}" href="#">Suppliers</option>
</select> </select>
</div> </div>
<button class="btn btn-primary form-control form-control-sm btn-sm">Search</button> <button class="btn btn-primary form-control form-control-sm btn-sm" style="border-top-left-radius: 0px;border-bottom-left-radius: 0px;">Search</button>
<a href="{% url 'search_help' %}" class="nav-link modal-href btn-sm"><span class="fas fa-question-circle"></span></a> <a href="{% url 'search_help' %}" class="nav-link modal-href btn-sm"><span class="fas fa-question-circle"></span></a>
</form> </form>
{% endif %} {% endif %}

View File

@@ -128,12 +128,12 @@ class ModelComparison(object):
item_dict = {} # build a list of items, key is the item_pk item_dict = {} # build a list of items, key is the item_pk
# FIXME Removing the if checks makes things REALLY slow... # FIXME Removing the if checks makes things REALLY slow...
for version in old_item_versions: # put all the old versions in a list for version in old_item_versions: # put all the old versions in a list
#if version.field_dict["event_id"] == int(self.new.pk): # if version.field_dict["event_id"] == int(self.new.pk):
compare = ModelComparison(old=version._object_version.object, **comparisonParams) compare = ModelComparison(old=version._object_version.object, **comparisonParams)
item_dict[version.object_id] = compare item_dict[version.object_id] = compare
for version in new_item_versions: # go through the new versions for version in new_item_versions: # go through the new versions
#if version.field_dict["event_id"] == int(self.new.pk): # if version.field_dict["event_id"] == int(self.new.pk):
try: try:
compare = item_dict[version.object_id] # see if there's a matching old version compare = item_dict[version.object_id] # see if there's a matching old version
compare.new = version._object_version.object # then add the new version to the dictionary compare.new = version._object_version.object # then add the new version to the dictionary