From d7a7749bc980a17bd787dfb5dd27b27d531127f6 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 13 Sep 2024 09:53:08 +0200 Subject: [PATCH] Correcciones para flake8 --- ReyMotaAppsDj/K8S/Makefile | 2 +- ReyMotaAppsDj/K8S/env-prod-configmap.yaml | 2 +- ReyMotaAppsDj/Makefile | 4 ++-- ReyMotaAppsDj/reymota/libros/forms.py | 3 +-- ReyMotaAppsDj/reymota/libros/models.py | 4 +--- ReyMotaAppsDj/reymota/libros/urls.py | 2 +- ReyMotaAppsDj/reymota/libros/views.py | 5 ----- ReyMotaAppsDj/reymota/lyrics/forms.py | 5 ++--- ReyMotaAppsDj/reymota/lyrics/models.py | 2 -- ReyMotaAppsDj/reymota/lyrics/urls.py | 2 +- ReyMotaAppsDj/reymota/repostajes/admin.py | 2 -- ReyMotaAppsDj/reymota/repostajes/forms.py | 1 - ReyMotaAppsDj/reymota/repostajes/models.py | 11 +---------- ReyMotaAppsDj/reymota/repostajes/urls.py | 2 +- ReyMotaAppsDj/reymota/reymota/settings.py | 4 ++-- ReyMotaAppsDj/reymota/reymota/urls.py | 3 +-- ReyMotaAppsDj/reymota/reymotausers/admin.py | 1 + ReyMotaAppsDj/reymota/reymotausers/forms.py | 1 + ReyMotaAppsDj/reymota/reymotausers/models.py | 2 +- 19 files changed, 18 insertions(+), 40 deletions(-) diff --git a/ReyMotaAppsDj/K8S/Makefile b/ReyMotaAppsDj/K8S/Makefile index b64dd1a..a08fbf5 100644 --- a/ReyMotaAppsDj/K8S/Makefile +++ b/ReyMotaAppsDj/K8S/Makefile @@ -1,7 +1,7 @@ export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') #export REGISTRY=registry.cube.local export REGISTRY=registry.reymota.es -export IMG_VERSION = 1.16 +export IMG_VERSION = 0.1 export IMG_NGINX_VERSION = 1.0 # limpia todo diff --git a/ReyMotaAppsDj/K8S/env-prod-configmap.yaml b/ReyMotaAppsDj/K8S/env-prod-configmap.yaml index 3166f80..de5d79b 100644 --- a/ReyMotaAppsDj/K8S/env-prod-configmap.yaml +++ b/ReyMotaAppsDj/K8S/env-prod-configmap.yaml @@ -16,4 +16,4 @@ metadata: labels: io.kompose.service: web-env-prod name: env-prod - namespace: finanzas + namespace: reymota diff --git a/ReyMotaAppsDj/Makefile b/ReyMotaAppsDj/Makefile index 9bf2173..73c0a45 100644 --- a/ReyMotaAppsDj/Makefile +++ b/ReyMotaAppsDj/Makefile @@ -2,7 +2,7 @@ install: echo "Creando imagen con version '${IMG_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'" - docker build --no-cache -t ${REGISTRY}/finanzas-${ARQUITECTURA}:${IMG_VERSION} . - docker push ${REGISTRY}/finanzas-${ARQUITECTURA}:${IMG_VERSION} + docker build --no-cache -t ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION} . + docker push ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION} diff --git a/ReyMotaAppsDj/reymota/libros/forms.py b/ReyMotaAppsDj/reymota/libros/forms.py index d1623e5..33b1ea3 100644 --- a/ReyMotaAppsDj/reymota/libros/forms.py +++ b/ReyMotaAppsDj/reymota/libros/forms.py @@ -1,5 +1,4 @@ from django import forms -from django.contrib.auth.forms import UserCreationForm, UserChangeForm from .models import Autor, Libro @@ -28,4 +27,4 @@ class LibroForm(forms.ModelForm): autor = forms.ModelChoiceField( queryset=Autor.objects.all(), - widget=forms.Select(attrs={'class': 'form-control'})) \ No newline at end of file + widget=forms.Select(attrs={'class': 'form-control'})) diff --git a/ReyMotaAppsDj/reymota/libros/models.py b/ReyMotaAppsDj/reymota/libros/models.py index 26a2e62..6e0d538 100644 --- a/ReyMotaAppsDj/reymota/libros/models.py +++ b/ReyMotaAppsDj/reymota/libros/models.py @@ -1,8 +1,6 @@ -from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.db import models import datetime from django.core.validators import MaxValueValidator, MinValueValidator -from django.utils.translation import gettext_lazy as _ def current_year(): @@ -31,4 +29,4 @@ class Libro(models.Model): portada = models.ImageField(upload_to='portadas/', blank=True, null=True) # Nuevo campo def __str__(self): - return self.titulo \ No newline at end of file + return self.titulo diff --git a/ReyMotaAppsDj/reymota/libros/urls.py b/ReyMotaAppsDj/reymota/libros/urls.py index b6f02ad..7c32fdf 100644 --- a/ReyMotaAppsDj/reymota/libros/urls.py +++ b/ReyMotaAppsDj/reymota/libros/urls.py @@ -2,7 +2,7 @@ from django.urls import path from . import views -app_name='libros' +app_name = 'libros' urlpatterns = [ path('', views.principal, name='principal'), diff --git a/ReyMotaAppsDj/reymota/libros/views.py b/ReyMotaAppsDj/reymota/libros/views.py index fb53b3e..6ace635 100644 --- a/ReyMotaAppsDj/reymota/libros/views.py +++ b/ReyMotaAppsDj/reymota/libros/views.py @@ -1,10 +1,6 @@ from django.shortcuts import render, get_object_or_404, redirect from django.contrib.auth.decorators import login_required -from django.views.generic import CreateView -from django.contrib.auth.forms import UserCreationForm -from django.urls import reverse_lazy - from .models import Autor, Libro from .forms import AutorForm, LibroForm @@ -105,4 +101,3 @@ def eliminar_libro(request, libro_id): libro = get_object_or_404(Libro, pk=libro_id) libro.delete() return redirect('lista_libros') - diff --git a/ReyMotaAppsDj/reymota/lyrics/forms.py b/ReyMotaAppsDj/reymota/lyrics/forms.py index 721b786..87ae947 100644 --- a/ReyMotaAppsDj/reymota/lyrics/forms.py +++ b/ReyMotaAppsDj/reymota/lyrics/forms.py @@ -20,14 +20,13 @@ class AlbumForm(forms.ModelForm): fields = ['name', 'artist', 'year', 'cover_image'] year = forms.DateField( - widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'})) + widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'})) artist = forms.ModelChoiceField( queryset=Artista.objects.all(), widget=forms.Select(attrs={'class': 'form-control'})) - class SongForm(forms.ModelForm): class Meta: model = Song @@ -41,5 +40,5 @@ class SongForm(forms.ModelForm): widget=forms.Select(attrs={'class': 'form-control'})) album = forms.ModelChoiceField( - queryset=Album.objects.all(), # habría que seleccionar los álbumes del artista + queryset=Album.objects.all(), # habría que seleccionar los álbumes del artista widget=forms.Select(attrs={'class': 'form-control'})) diff --git a/ReyMotaAppsDj/reymota/lyrics/models.py b/ReyMotaAppsDj/reymota/lyrics/models.py index 813ed35..28536af 100644 --- a/ReyMotaAppsDj/reymota/lyrics/models.py +++ b/ReyMotaAppsDj/reymota/lyrics/models.py @@ -1,7 +1,6 @@ from django.db import models import datetime from django.core.validators import MaxValueValidator, MinValueValidator -from django.utils.translation import gettext_lazy as _ def current_year(): @@ -41,4 +40,3 @@ class Song(models.Model): def __str__(self): return self.title - diff --git a/ReyMotaAppsDj/reymota/lyrics/urls.py b/ReyMotaAppsDj/reymota/lyrics/urls.py index 81cac53..dc60b53 100644 --- a/ReyMotaAppsDj/reymota/lyrics/urls.py +++ b/ReyMotaAppsDj/reymota/lyrics/urls.py @@ -3,7 +3,7 @@ from django.urls import path from . import views -app_name='lyrics' +app_name = 'lyrics' urlpatterns = [ path('', views.principal, name='principal'), diff --git a/ReyMotaAppsDj/reymota/repostajes/admin.py b/ReyMotaAppsDj/reymota/repostajes/admin.py index a9e0c3e..4805a7b 100644 --- a/ReyMotaAppsDj/reymota/repostajes/admin.py +++ b/ReyMotaAppsDj/reymota/repostajes/admin.py @@ -7,5 +7,3 @@ from .models import Vehiculo, Repostaje admin.site.register(Vehiculo) admin.site.register(Repostaje) - - diff --git a/ReyMotaAppsDj/reymota/repostajes/forms.py b/ReyMotaAppsDj/reymota/repostajes/forms.py index 67e8a54..5f14278 100644 --- a/ReyMotaAppsDj/reymota/repostajes/forms.py +++ b/ReyMotaAppsDj/reymota/repostajes/forms.py @@ -39,4 +39,3 @@ class RepostajeForm(forms.ModelForm): widget=forms.NumberInput(attrs={'class': 'form-control'})) aplica_descuento = forms.BooleanField(initial=False, required=False) - diff --git a/ReyMotaAppsDj/reymota/repostajes/models.py b/ReyMotaAppsDj/reymota/repostajes/models.py index 4dab635..53c7456 100644 --- a/ReyMotaAppsDj/reymota/repostajes/models.py +++ b/ReyMotaAppsDj/reymota/repostajes/models.py @@ -1,14 +1,5 @@ from django.db import models -import datetime -from django.core.validators import MaxValueValidator, MinValueValidator -from django.utils.translation import gettext_lazy as _ - -def current_year(): - return datetime.date.today().year - - -def max_value_current_year(value): - return MaxValueValidator(current_year())(value) +from django.core.validators import MaxValueValidator class Vehiculo(models.Model): diff --git a/ReyMotaAppsDj/reymota/repostajes/urls.py b/ReyMotaAppsDj/reymota/repostajes/urls.py index 3e620d4..0b5ba04 100644 --- a/ReyMotaAppsDj/reymota/repostajes/urls.py +++ b/ReyMotaAppsDj/reymota/repostajes/urls.py @@ -2,7 +2,7 @@ from django.urls import path from . import views -app_name='repostajes' +app_name = 'repostajes' urlpatterns = [ path('', views.principal, name='principal'), diff --git a/ReyMotaAppsDj/reymota/reymota/settings.py b/ReyMotaAppsDj/reymota/reymota/settings.py index 857a39c..24048c4 100644 --- a/ReyMotaAppsDj/reymota/reymota/settings.py +++ b/ReyMotaAppsDj/reymota/reymota/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path - +import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -60,7 +60,7 @@ ROOT_URLCONF = 'reymota.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ BASE_DIR / 'templates' ], + 'DIRS': [BASE_DIR / 'templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/ReyMotaAppsDj/reymota/reymota/urls.py b/ReyMotaAppsDj/reymota/reymota/urls.py index 71da657..eff3e50 100644 --- a/ReyMotaAppsDj/reymota/reymota/urls.py +++ b/ReyMotaAppsDj/reymota/reymota/urls.py @@ -22,7 +22,7 @@ from django.views.generic.base import TemplateView # new urlpatterns = [ path('obreros/', admin.site.urls), - + path('libros/', include('libros.urls')), path('repostajes/', include('repostajes.urls')), @@ -36,4 +36,3 @@ urlpatterns = [ path("", TemplateView.as_view(template_name="index.html"), name="principal"), # new ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) - diff --git a/ReyMotaAppsDj/reymota/reymotausers/admin.py b/ReyMotaAppsDj/reymota/reymotausers/admin.py index 431d572..1892dd2 100644 --- a/ReyMotaAppsDj/reymota/reymotausers/admin.py +++ b/ReyMotaAppsDj/reymota/reymotausers/admin.py @@ -7,6 +7,7 @@ from django.contrib.auth.admin import UserAdmin from reymotausers.models import ReyMotaUser from reymotausers.forms import ReyMotaUserCreationForm, ReyMotaUserChangeForm + class ReyMotaUserAdmin(UserAdmin): add_form = ReyMotaUserCreationForm form = ReyMotaUserChangeForm diff --git a/ReyMotaAppsDj/reymota/reymotausers/forms.py b/ReyMotaAppsDj/reymota/reymotausers/forms.py index 5d348fd..5e8af6c 100644 --- a/ReyMotaAppsDj/reymota/reymotausers/forms.py +++ b/ReyMotaAppsDj/reymota/reymotausers/forms.py @@ -3,6 +3,7 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm from .models import ReyMotaUser + class ReyMotaUserCreationForm(UserCreationForm): class Meta: diff --git a/ReyMotaAppsDj/reymota/reymotausers/models.py b/ReyMotaAppsDj/reymota/reymotausers/models.py index a4b57fd..63b7226 100644 --- a/ReyMotaAppsDj/reymota/reymotausers/models.py +++ b/ReyMotaAppsDj/reymota/reymotausers/models.py @@ -7,6 +7,7 @@ from .managers import ReyMotaUserManager # Create your models here. + class ReyMotaUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_("email address"), unique=True) foto = models.ImageField(upload_to="profile_images", default="profile_images/default.jpg", blank=True) @@ -21,4 +22,3 @@ class ReyMotaUser(AbstractBaseUser, PermissionsMixin): def __str__(self): return self.email -