all features OK, cleaned up (flake8) code except migrations files

This commit is contained in:
2025-05-06 10:38:27 +02:00
parent 29192378c2
commit 5227bf42b2
62 changed files with 3024 additions and 284 deletions

View File

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

View File

@@ -5,10 +5,12 @@ from django.contrib.auth.forms import UserCreationForm
class LoginForm(forms.Form):
username = forms.CharField(max_length=63, label='Nom dutilisateur')
password = forms.CharField(max_length=63, widget=forms.PasswordInput, label='Mot de passe')
password = forms.CharField(max_length=63,
widget=forms.PasswordInput,
label='Mot de passe')
class RegisterForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = get_user_model()
fields = ('username',)

View File

@@ -1,4 +1,3 @@
from django.db import models
from django.contrib.auth.models import AbstractUser

View File

@@ -25,11 +25,13 @@
{% csrf_token %}
<div class="form-group p-3">
{{ form.username }}
</div>
</div>
<div class="form-group p-3">
{{ form.password }}
</div>
<button type="submit" class="btn btn-primary self-align-right">Se connecter</button>
<div class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary">Se connecter</button>
</div>
</form>
</div>
</div>

View File

@@ -1,26 +1,30 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row justify-content-center mt-5">
<div class="row justify-content-center mt-5 mb-3">
<div class="col text-center">
<h2>Inscrivez-vous</h2>
</div>
</div>
<div class="row justify-content-center">
<div class="col-6 justify-content-around d-flex align-items-end">
<div class="row d-flex justify-content-center">
<div class="col-8">
<form method='post'>
{% csrf_token %}
{{ form.as_p }}
<div class="row justify-content-end">
<div class="col-3 order-2">
<button type="submit" class="btn btn-primary">S'inscrire</button>
</form>
</div>
<div class="col-3 order-1">
<a href="{% url 'login' %}" class="btn btn-primary">Retourner</a>
</div>
</div>
<div class="col-8 d-flex justify-content-end">
<div class="d-flex align-self-end m-2">
<a href="{% url 'login' %}" class="btn btn-primary">Retourner</a>
</div>
<div class="d-flex align-self-end m-2">
<button type="submit" class="btn btn-primary">S'inscrire</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

View File

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

View File

@@ -1,32 +1,7 @@
from django.shortcuts import render, redirect
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth import login
from django.conf import settings
from django import forms
from authentication.forms import LoginForm, RegisterForm
def login_page(request):
form = LoginForm()
message = ""
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
user = authenticate(
username=form.cleaned_data['username'],
password=form.cleaned_data['password'],
)
if user is not None:
login(request, user)
return redirect('home')
else:
message = "Identifiants invalides"
print(request.POST)
return render(request,
'authentication/login.html',
{'form': form})
from authentication.forms import RegisterForm
def register_page(request):