From b9de08e42fcc62cc951ee12d3d5b484dd2d6119d Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Wed, 28 Aug 2024 16:41:04 +0200 Subject: [PATCH] Pongo a mano descuento y precio por litro antes de salvar 2 --- RepostajesDj/Makefile | 6 +++--- RepostajesDj/entrypoint.sh | 1 + RepostajesDj/nginx/Makefile | 6 +++--- RepostajesDj/vehiculos/repostajes/forms.py | 9 +-------- RepostajesDj/vehiculos/repostajes/views.py | 8 +++++++- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/RepostajesDj/Makefile b/RepostajesDj/Makefile index 3dad086..7c2bed4 100644 --- a/RepostajesDj/Makefile +++ b/RepostajesDj/Makefile @@ -1,8 +1,8 @@ install: - echo "Creando imagen con version ${IMG_VERSION}" + echo "Creando imagen con version '${IMG_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'" - docker build --no-cache -t registry.reymota.es/vehiculos-${ARQUITECTURA}:${IMG_VERSION} . - docker push registry.reymota.es/vehiculos-${ARQUITECTURA}:${IMG_VERSION} + docker build --no-cache -t ${REGISTRY}/vehiculos-${ARQUITECTURA}:${IMG_VERSION} . + docker push ${REGISTRY}/vehiculos-${ARQUITECTURA}:${IMG_VERSION} diff --git a/RepostajesDj/entrypoint.sh b/RepostajesDj/entrypoint.sh index 16a0c8d..01fa726 100755 --- a/RepostajesDj/entrypoint.sh +++ b/RepostajesDj/entrypoint.sh @@ -13,6 +13,7 @@ else echo "la base de datos no es postgres: '$DATABASE'" fi +python manage.py collectstatic --noinput #python manage.py flush --no-input #python manage.py migrate diff --git a/RepostajesDj/nginx/Makefile b/RepostajesDj/nginx/Makefile index ac286c5..41d9314 100644 --- a/RepostajesDj/nginx/Makefile +++ b/RepostajesDj/nginx/Makefile @@ -1,8 +1,8 @@ install: - echo "Creando imagen con version ${IMG_NGINX_VERSION} para la arquitectura ${ARQUITECTURA}" + echo "Creando imagen con version '${IMG_NGINX_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'" - docker build --no-cache -t registry.reymota.es/nginx-vehiculos-${ARQUITECTURA}:${IMG_NGINX_VERSION} . - docker push registry.reymota.es/nginx-vehiculos-${ARQUITECTURA}:${IMG_NGINX_VERSION} + docker build --no-cache -t ${REGISTRY}/nginx-vehiculos-${ARQUITECTURA}:${IMG_NGINX_VERSION} . + docker push ${REGISTRY}/nginx-vehiculos-${ARQUITECTURA}:${IMG_NGINX_VERSION} diff --git a/RepostajesDj/vehiculos/repostajes/forms.py b/RepostajesDj/vehiculos/repostajes/forms.py index dc1f3ea..2fb2388 100644 --- a/RepostajesDj/vehiculos/repostajes/forms.py +++ b/RepostajesDj/vehiculos/repostajes/forms.py @@ -22,6 +22,7 @@ class RepostajeForm(forms.ModelForm): class Meta: model = Repostaje fields = ['fecha', 'vehiculo', 'kms', 'litros', 'importe'] + exclude = ['descuento', 'precioxlitro'] fecha = forms.DateField( widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'})) @@ -41,14 +42,6 @@ class RepostajeForm(forms.ModelForm): aplica_descuento = forms.BooleanField(initial=False, required=False) - descuento = forms.DecimalField( - widget=calculation.FormulaInput('aplica_descuento ? parseFloat(importe*0.03).toFixed(2) : 0.0') - ) - - precioxlitro = forms.DecimalField( - widget=calculation.FormulaInput('(importe-descuento)/litros') - ) - class ReyMotaUserCreationForm(UserCreationForm): diff --git a/RepostajesDj/vehiculos/repostajes/views.py b/RepostajesDj/vehiculos/repostajes/views.py index b80653d..4786fb7 100644 --- a/RepostajesDj/vehiculos/repostajes/views.py +++ b/RepostajesDj/vehiculos/repostajes/views.py @@ -85,7 +85,13 @@ def nuevo_repostaje(request): if request.method == 'POST': form = RepostajeForm(request.POST, request.FILES) if form.is_valid(): - form.save() + instancia = form.save(commit=False) + + instancia.descuento = 99 + instancia.precioxlitro = 99 + + instancia.save() + return redirect('lista_repostajes') else: form = RepostajeForm()