Browse Source

Función signup

politica
Celestino Rey 1 year ago
parent
commit
f55fcaf4d1
13 changed files with 65 additions and 1 deletions
  1. +0
    -0
      Libros/biblioteca/accounts/__init__.py
  2. +3
    -0
      Libros/biblioteca/accounts/admin.py
  3. +6
    -0
      Libros/biblioteca/accounts/apps.py
  4. +0
    -0
      Libros/biblioteca/accounts/migrations/__init__.py
  5. +3
    -0
      Libros/biblioteca/accounts/models.py
  6. +3
    -0
      Libros/biblioteca/accounts/tests.py
  7. +9
    -0
      Libros/biblioteca/accounts/urls.py
  8. +11
    -0
      Libros/biblioteca/accounts/views.py
  9. +1
    -0
      Libros/biblioteca/biblioteca/settings.py
  10. +3
    -0
      Libros/biblioteca/biblioteca/urls.py
  11. +1
    -1
      Libros/biblioteca/gestion/forms.py
  12. +13
    -0
      Libros/biblioteca/gestion/templates/registration/signup.html
  13. +12
    -0
      Libros/biblioteca/gestion/views.py

+ 0
- 0
Libros/biblioteca/accounts/__init__.py View File


+ 3
- 0
Libros/biblioteca/accounts/admin.py View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

+ 6
- 0
Libros/biblioteca/accounts/apps.py View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

+ 0
- 0
Libros/biblioteca/accounts/migrations/__init__.py View File


+ 3
- 0
Libros/biblioteca/accounts/models.py View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

+ 3
- 0
Libros/biblioteca/accounts/tests.py View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

+ 9
- 0
Libros/biblioteca/accounts/urls.py View File

@ -0,0 +1,9 @@
# accounts/urls.py
from django.urls import path
from .views import SignUpView
urlpatterns = [
path("signup/", SignUpView.as_view(), name="signup"),
]

+ 11
- 0
Libros/biblioteca/accounts/views.py View File

@ -0,0 +1,11 @@
# accounts/views.py
#from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views.generic import CreateView
from gestion.forms import ReyMotaUserCreationForm
class SignUpView(CreateView):
form_class = ReyMotaUserCreationForm
success_url = reverse_lazy("login")
template_name = "registration/signup.html"

+ 1
- 0
Libros/biblioteca/biblioteca/settings.py View File

@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'gestion',
'accounts',
]
MIDDLEWARE = [


+ 3
- 0
Libros/biblioteca/biblioteca/urls.py View File

@ -25,8 +25,11 @@ urlpatterns = [
path('obreros/', admin.site.urls),
path('gestion/', include('gestion.urls')),
path("accounts/", include("accounts.urls")), # new
path('accounts/login/', auth_views.LoginView.as_view(), name='login'),
path('accounts/logout/', auth_views.LogoutView.as_view(), name='logout'),
path("accounts/", include("django.contrib.auth.urls")),
path("", TemplateView.as_view(template_name="gestion/index.html"), name="principal"), # new
]


+ 1
- 1
Libros/biblioteca/gestion/forms.py View File

@ -38,4 +38,4 @@ class ReyMotaUserChangeForm(UserChangeForm):
class Meta:
model = ReyMotaUser
fields = ("email", "foto")
fields = ("email", "foto")

+ 13
- 0
Libros/biblioteca/gestion/templates/registration/signup.html View File

@ -0,0 +1,13 @@
<!-- templates/registration/signup.html -->
{% extends "base.html" %}
{% block title %}Sign Up{% endblock %}
{% block content %}
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
{{ form }}
<button type="submit">Sign Up</button>
</form>
{% endblock %}

+ 12
- 0
Libros/biblioteca/gestion/views.py View File

@ -1,5 +1,11 @@
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
@ -84,3 +90,9 @@ def eliminar_libro(request, libro_id):
libro = get_object_or_404(Libro, pk=libro_id)
libro.delete()
return redirect('lista_libros')
class SignUpView(CreateView):
form_class = UserCreationForm
success_url = reverse_lazy("login")
template_name = "registration/signup.html"

Loading…
Cancel
Save