mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-14 10:39:41 +00:00
Fix defaults, will close #3
Moved to template now model as it both fixed the bug and consolidated edit points
This commit is contained in:
@@ -42,10 +42,10 @@ class BaseAsset(models.Model):
|
|||||||
asset_id = models.CharField(max_length=10)
|
asset_id = models.CharField(max_length=10)
|
||||||
description = models.CharField(max_length=120)
|
description = models.CharField(max_length=120)
|
||||||
category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE)
|
category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE)
|
||||||
status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE, default='Active')
|
status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE)
|
||||||
serial_number = models.CharField(max_length=150, blank=True)
|
serial_number = models.CharField(max_length=150, blank=True)
|
||||||
purchased_from = models.ForeignKey(to=Supplier, on_delete=models.CASCADE, blank=True, null=True)
|
purchased_from = models.ForeignKey(to=Supplier, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
date_acquired = models.DateField(default=datetime.date.today().strftime('%d %b %Y'))
|
date_acquired = models.DateField()
|
||||||
date_sold = models.DateField(blank=True, null=True)
|
date_sold = models.DateField(blank=True, null=True)
|
||||||
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
||||||
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
||||||
|
|||||||
@@ -73,7 +73,8 @@
|
|||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<select name="{{ form.status.name }}" id="{{ form.status.id_for_label }}" required>
|
<select name="{{ form.status.name }}" id="{{ form.status.id_for_label }}" required>
|
||||||
{% for id, choice in form.status.field.choices %}
|
{% for id, choice in form.status.field.choices %}
|
||||||
<option value="{{ id }}" {% if object.status.id == id %}selected{% endif %}>{{ choice }}</option>
|
<option value="{{ id }}"
|
||||||
|
{% if not object.status.id and choice == "Active" or object.status.id == id %}selected{% endif %}>{{ choice }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<label for="{{ form.status.id_for_label }}" class="bold-text">Status</label>
|
<label for="{{ form.status.id_for_label }}" class="bold-text">Status</label>
|
||||||
@@ -143,7 +144,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
{% render_field form.date_acquired|add_class:'datepicker' value=object.date_acquired|date %}
|
{% if object.date_acquired %}
|
||||||
|
{% render_field form.date_acquired|add_class:'datepicker' value=object.date_acquired|date %}
|
||||||
|
{% else %}
|
||||||
|
<input type="text" name="date_acquired" value="{% now "DATE_FORMAT" %}"
|
||||||
|
class="datepicker" id="id_date_acquired">
|
||||||
|
{% endif %}
|
||||||
<label for="{{ form.date_acquired.id_for_label }}" class="bold-text">Date Acquired</label>
|
<label for="{{ form.date_acquired.id_for_label }}" class="bold-text">Date Acquired</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user