Première version affichage des vhcs

This commit is contained in:
Ambulance Clerc
2022-11-09 18:07:18 +01:00
parent 0e8f4ab529
commit 5c52baa2cd
11 changed files with 77 additions and 6 deletions

View File

@@ -37,5 +37,5 @@ class _vhc_infos_admin(admin.ModelAdmin):
admin.site.register(vehicles_infos, _vhc_infos_admin)
admin.site.register(vehicles, _vhc_admin)
admin.site.register(Vehicles_infos, _vhc_infos_admin)
admin.site.register(Vehicles, _vhc_admin)

View File

@@ -21,7 +21,7 @@ TYPES_CHOICES = [
]
class vehicles(models.Model):
class Vehicles(models.Model):
sName = models.CharField("Indicatif", max_length=250)
nBases = models.CharField('Basé à ', max_length=1, choices=BASES_CHOICES, default=1)
nStatus = models.CharField('Statut', max_length=1, choices=STATUS_CHOICES, default=1)
@@ -34,8 +34,8 @@ class vehicles(models.Model):
verbose_name_plural = "véhicules"
class vehicles_infos(models.Model):
Vehicle = models.ForeignKey(vehicles, on_delete=models.CASCADE, verbose_name="Véhicule")
class Vehicles_infos(models.Model):
Vehicle = models.ForeignKey(Vehicles, on_delete=models.CASCADE, verbose_name="Véhicule")
nType = models.CharField('Type', max_length=1, choices=TYPES_CHOICES, default=1)
sTitle = models.CharField("Titre",max_length=250)
sDesc = models.TextField("Description")

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

View File

@@ -0,0 +1,15 @@
.main_container{
width: 100%;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-between;
height: 350px;
}
.child{
width: 350px;
color: green;
border: solid 1px black;
background-repeat: no-repeat, repeat;
background-size: contain;
}

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="{% static 'vehicles/style.css' %}">
</head>
<body>
<div class="main_container">
{% for vhc in list_vhc %}
{% with 'vehicles/images/ocvs_rtw_'|add:vhc.nStatus|add:'.png' as image_static %}
<div class="child">
<img width="350px" src="{% static image_static %}" >
{{vhc.sName}}
</div>
{% endwith %}
{% endfor %}
</div>
</body>
</html>

15
vehicles/urls.py Normal file
View File

@@ -0,0 +1,15 @@
from django.urls import path
from . import views
app_name = "vehicles"
urlpatterns = [
path('vhc', views.view_vhc, name='view_vhc'),
]

View File

@@ -1,3 +1,17 @@
from django.http import HttpResponse
from django.http import FileResponse
from django.shortcuts import render
from django.views import generic
from django.template import loader
from django.views.decorators.clickjacking import xframe_options_exempt
# Create your views here.
from vehicles.models import *
@xframe_options_exempt
def view_vhc(request):
template = loader.get_template("vhc/vhc.html")
context = {'list_vhc': Vehicles.objects.all()}
print("passs 1 ligne 12")
return HttpResponse(template.render(context,request))