FEAT: More handy buttons

This commit is contained in:
2020-02-17 21:25:25 +00:00
parent 6e15f12fbf
commit 75660644eb
4 changed files with 65 additions and 8 deletions

View File

@@ -29,8 +29,8 @@ class Command(BaseCommand):
def create_profile(self):
name = "Fred Johnson"
models.Profile.objects.create(username=name.replace(" ", ""), first_name=name.split(" ")[0], last_name=name.split(" ")[-1],
email=name.replace(" ", "") + "@example.com",
initials="".join([j[0].upper() for j in name.split()]))
email=name.replace(" ", "") + "@example.com",
initials="".join([j[0].upper() for j in name.split()]))
def create_categories(self):
categories = ['Case', 'Video', 'General', 'Sound', 'Lighting', 'Rigging']

View File

@@ -104,7 +104,7 @@ class Asset(models.Model, RevisionMixin):
length = models.DecimalField(decimal_places=1, max_digits=10,
blank=True, null=True, help_text='m')
csa = models.DecimalField(decimal_places=2, max_digits=10,
blank=True, null=True, help_text='mm^2')
blank=True, null=True, help_text='mm²')
circuits = models.IntegerField(blank=True, null=True)
cores = models.IntegerField(blank=True, null=True)

View File

@@ -14,6 +14,9 @@
function setLength(length) {
$('#id_length').val(length);
}
function setCSA(CSA) {
$('#id_csa').val(CSA);
}
function checkIfCableHidden() {
if (document.getElementById("id_is_cable").checked) {
document.getElementById("cable-table").hidden = false;
@@ -106,19 +109,23 @@
</div>
</div>
<div class="col-sm-4">
<btn class="btn btn-danger" onclick="setLength('5');">5m</btn>
<btn class="btn btn-success" onclick="setLength('10');">10m</btn>
<btn class="btn btn-info" onclick="setLength('20');">20m</btn>
</div>
<btn class="btn btn-danger" onclick="setLength('5');">5{{ form.length.help_text }}</btn>
<btn class="btn btn-success" onclick="setLength('10');">10{{ form.length.help_text }}</btn>
<btn class="btn btn-info" onclick="setLength('20');">20{{ form.length.help_text }}</btn>
</div>
</div>
<div class="form-group">
<label for="{{ form.csa.id_for_label }}" class="col-sm-2 control-label">Cross Sectional Area</label>
<div class="col-sm-10">
<div class="col-sm-6">
<div class="input-group">
{% render_field form.csa|add_class:'form-control' value=object.csa %}
<span class="input-group-addon">{{ form.csa.help_text }}</span>
</div>
</div>
<div class="col-sm-4">
<btn class="btn btn-default" onclick="setCSA('1.5');">1.5{{ form.csa.help_text }}</btn>
<btn class="btn btn-default" onclick="setCSA('2.5');">2.5{{ form.csa.help_text }}</btn>
</div>
</div>
<div class="form-group">
<label for="{{ form.circuits.id_for_label }}" class="col-sm-2 control-label">Circuits</label>

View File

@@ -0,0 +1,50 @@
{% load widget_tweaks %}
<div id="cable-table">
<div class="form-group">
<label for="{{ form.plug.id_for_label }}" class="col-sm-2 control-label">Plug</label>
<div class="col-sm-10">
{% render_field form.plug|add_class:'form-control'%}
</div>
</div>
<div class="form-group">
<label for="{{ form.socket.id_for_label }}" class="col-sm-2 control-label">Socket</label>
<div class="col-sm-10">
{% render_field form.socket|add_class:'form-control'%}
</div>
</div>
<div class="form-group">
<label for="{{ form.length.id_for_label }}" class="col-sm-2 control-label">Length</label>
<div class="col-sm-6">
<div class="input-group">
{% render_field form.length|add_class:'form-control' %}
<span class="input-group-addon">{{ form.length.help_text }}</span>
</div>
</div>
<div class="col-sm-4">
<btn class="btn btn-danger btn-xs" onclick="setLength('5');">5m</btn>
<btn class="btn btn-success btn-xs" onclick="setLength('10');">10m</btn>
<btn class="btn btn-info btn-xs" onclick="setLength('20');">20m</btn>
</div>
</div>
<div class="form-group">
<label for="{{ form.csa.id_for_label }}" class="col-sm-2 control-label">Cross Sectional Area</label>
<div class="col-sm-10">
<div class="input-group">
{% render_field form.csa|add_class:'form-control' value=object.csa %}
<span class="input-group-addon">{{ form.csa.help_text }}</span>
</div>
</div>
</div>
<div class="form-group">
<label for="{{ form.circuits.id_for_label }}" class="col-sm-2 control-label">Circuits</label>
<div class="col-sm-10">
{% render_field form.circuits|add_class:'form-control' value=object.circuits %}
</div>
</div>
<div class="form-group">
<label for="{{ form.cores.id_for_label }}" class="col-sm-2 control-label">Cores</label>
<div class="col-sm-10">
{% render_field form.cores|add_class:'form-control' value=object.cores %}
</div>
</div>
</div>