mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 05:52:15 +00:00
Allow two decimal places in cable length, show training item IDs in selectpicker
Will close #540
This commit is contained in:
@@ -135,10 +135,11 @@ class SecureAPIRequest(generic.View):
|
||||
query = reduce(operator.and_, queries)
|
||||
objects = self.models[model].objects.filter(query)
|
||||
for o in objects:
|
||||
name = o.display_name if hasattr(o, 'display_name') else o.name
|
||||
data = {
|
||||
'pk': o.pk,
|
||||
'value': o.pk,
|
||||
'text': o.name,
|
||||
'text': name,
|
||||
}
|
||||
try: # See if there is a valid update URL
|
||||
data['update'] = reverse(f"{model}_update", kwargs={'pk': o.pk})
|
||||
@@ -183,7 +184,7 @@ class ModalURLMixin:
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy(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 + "'")
|
||||
messages.info(self.request, f"modalobject[0]['update_url']='{update_url}'")
|
||||
else:
|
||||
url = reverse_lazy(detail, kwargs={
|
||||
'pk': self.object.pk,
|
||||
|
||||
18
assets/migrations/0028_alter_asset_length.py
Normal file
18
assets/migrations/0028_alter_asset_length.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.19 on 2023-05-24 22:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('assets', '0027_asset_nickname'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='asset',
|
||||
name='length',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, help_text='m', max_digits=10, null=True),
|
||||
),
|
||||
]
|
||||
@@ -135,7 +135,7 @@ class Asset(models.Model, RevisionMixin):
|
||||
# Cable assets
|
||||
is_cable = models.BooleanField(default=False)
|
||||
cable_type = models.ForeignKey(to=CableType, blank=True, null=True, on_delete=models.SET_NULL)
|
||||
length = models.DecimalField(decimal_places=1, max_digits=10,
|
||||
length = models.DecimalField(decimal_places=2, 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²')
|
||||
@@ -192,5 +192,5 @@ class Asset(models.Model, RevisionMixin):
|
||||
return str(self.asset_id)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
def display_name(self):
|
||||
return f"{self.display_id} | {self.description}"
|
||||
|
||||
@@ -105,6 +105,10 @@ class TrainingItem(models.Model):
|
||||
def display_id(self):
|
||||
return f"{self.category.reference_number}.{self.reference_number}"
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
return f"{self.display_id} | {self.name}"
|
||||
|
||||
@display_id.filter
|
||||
@classmethod
|
||||
def display_id(cls, lookup, value):
|
||||
|
||||
Reference in New Issue
Block a user