Amélioration visuel véhicule

This commit is contained in:
Ambulance Clerc
2022-11-10 14:24:11 +01:00
parent 2e0b61b336
commit 1665831e4e
3 changed files with 48 additions and 20 deletions

View File

@@ -26,11 +26,30 @@ class Vehicles(models.Model):
nBases = models.CharField('Basé à ', max_length=1, choices=BASES_CHOICES, default=1)
nStatus = models.CharField('Statut', max_length=1, choices=STATUS_CHOICES, default=1)
a_infos = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.a_infos = None
def get_all_infos(self):
infos = Vehicles_infos.filter(Vehicles__id=self.id)
print(infos)
def get_all_infos(self,nType):
if self.a_infos is not None:
return self.a_infos[f"{nType}"]
self.a_infos = {"1": [], "2": [], "3": []}
infos = Vehicles_infos.objects.filter(Vehicle__id=self.id,bEnabled=1)
for info in infos:
self.a_infos[f"{info.nType}"].append(info)
print(self.a_infos[f"{nType}"])
return self.a_infos[f"{nType}"]
def get_all_infos_tech(self):
return self.get_all_infos(1)
def get_all_infos_mat(self):
return self.get_all_infos(2)
def get_all_infos_perempt(self):
return self.get_all_infos(3)
@@ -55,6 +74,12 @@ class Vehicles_infos(models.Model):
dtUpdated = models.DateTimeField('date updated', auto_now=True)
dtCreated = models.DateTimeField('date published', auto_now_add=True)
def get_Start_formated(self):
return self.dtStart.strftime("%d.%m")
def get_Author_formated(self):
return self.Author.username.replace("@clerc.ch",'')
def __str__(self):
return self.sDesc

View File

@@ -21,32 +21,34 @@
<div class="child_box" style="height: 70%;">
<div style="width: 46%; padding: 2px;">
<b>Infos techniques</b>
{% for info in vhc.get_all_infos_tech %}
<div style="margin-top: 15px">
fasdfasd fasdf asd fasdf ad
<br><span>10.11.2022 MC33</span>
{{info.sDesc}}
<br><span style="font-style: italic;">{{info.get_Start_formated}} {{info.get_Author_formated}}</span>
</div>
{% endfor %}
</div>
<div style="width: 46%;padding: 2px;">
<b>Matériels manquants</b>
{% for info in vhc.get_all_infos_mat %}
<div style="margin-top: 15px">
fasdfasd fasdf asd fasdf ad
<br><span>10.11.2022 MC33</span>
</div>
<div style="margin-top: 15px">
fasdfasd fasdf asd fasdf ad
<br><span>10.11.2022 MC33</span>
{{info.sDesc}}
<br><span style="font-style: italic;">{{info.get_Start_formated}} {{info.get_Author_formated}}</span>
</div>
{% endfor %}
</div>
<div style="width: 350px; ">
<b>Péremptions</b>
<ul>
<li>fdaf afasd afdf asd f</li>
<li>fdaf afasd afdf asd f</li>
<li>fdaf afasd afdf asd f</li>
<li>fdaf afasd afdf asd f</li>
<li>fdaf afasd afdf asd f</li>
</ul>
<div style="display: flex; border: 1px solid white; width: 125px">
{% for info in vhc.get_all_infos_perempt %}
<div>
{{info.sDesc}}
</div>
{% endfor %}
</div>
</div>
</div>

View File

@@ -10,7 +10,8 @@ from vehicles.models import *
@xframe_options_exempt
def view_vhc(request):
template = loader.get_template("vhc/vhc.html")
context = {'list_vhc': Vehicles.objects.all()}
a_vhc = Vehicles.objects.all()
context = {'list_vhc': a_vhc}
print("passs 1 ligne 12")