Browse Source

Pongo a mano descuento y precio por litro antes de salvar 2

politica
Celestino Rey 1 year ago
parent
commit
b9de08e42f
5 changed files with 15 additions and 15 deletions
  1. +3
    -3
      RepostajesDj/Makefile
  2. +1
    -0
      RepostajesDj/entrypoint.sh
  3. +3
    -3
      RepostajesDj/nginx/Makefile
  4. +1
    -8
      RepostajesDj/vehiculos/repostajes/forms.py
  5. +7
    -1
      RepostajesDj/vehiculos/repostajes/views.py

+ 3
- 3
RepostajesDj/Makefile View File

@ -1,8 +1,8 @@
install: 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}

+ 1
- 0
RepostajesDj/entrypoint.sh View File

@ -13,6 +13,7 @@ else
echo "la base de datos no es postgres: '$DATABASE'" echo "la base de datos no es postgres: '$DATABASE'"
fi fi
python manage.py collectstatic --noinput
#python manage.py flush --no-input #python manage.py flush --no-input
#python manage.py migrate #python manage.py migrate


+ 3
- 3
RepostajesDj/nginx/Makefile View File

@ -1,8 +1,8 @@
install: 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}

+ 1
- 8
RepostajesDj/vehiculos/repostajes/forms.py View File

@ -22,6 +22,7 @@ class RepostajeForm(forms.ModelForm):
class Meta: class Meta:
model = Repostaje model = Repostaje
fields = ['fecha', 'vehiculo', 'kms', 'litros', 'importe'] fields = ['fecha', 'vehiculo', 'kms', 'litros', 'importe']
exclude = ['descuento', 'precioxlitro']
fecha = forms.DateField( fecha = forms.DateField(
widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'})) 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) 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): class ReyMotaUserCreationForm(UserCreationForm):


+ 7
- 1
RepostajesDj/vehiculos/repostajes/views.py View File

@ -85,7 +85,13 @@ def nuevo_repostaje(request):
if request.method == 'POST': if request.method == 'POST':
form = RepostajeForm(request.POST, request.FILES) form = RepostajeForm(request.POST, request.FILES)
if form.is_valid(): if form.is_valid():
form.save()
instancia = form.save(commit=False)
instancia.descuento = 99
instancia.precioxlitro = 99
instancia.save()
return redirect('lista_repostajes') return redirect('lista_repostajes')
else: else:
form = RepostajeForm() form = RepostajeForm()


Loading…
Cancel
Save