Commit 0be05c89 authored by GuiΩ's avatar GuiΩ
Browse files

Profil form is filled with the user's fields

Password form doesn't work
parent 8383fc01
......@@ -13,7 +13,10 @@ class UtilisateurCreationForm(UserCreationForm):
class UtilisateurChangeForm(UserChangeForm):
class Meta:
model = Utilisateur
fields = ('username', 'email')
fields = ('username', 'email', 'first_name', 'last_name', 'nom_latex')
def get_object(self):
return self.request.user
class ClasseForm(ModelForm):
......@@ -14,11 +14,9 @@ from pdf2image import pdf2image
class Utilisateur(AbstractUser):
nom_latex = models.CharField("nom LaTeX", max_length=100)
def __str__(self):
return self.username
class Classe(models.Model):
objects = None
nom = models.CharField(max_length=100)
from django.contrib.auth import views as auth_views
from django.urls import include, path, reverse_lazy
from django.views.generic import TemplateView
from rest_framework.routers import SimpleRouter
from django.contrib.auth import views as auth_views
from am import views
......@@ -22,16 +22,17 @@ router.register(r'theme', views.ThemeViewSet, 'theme')
urlpatterns = [
path('', TemplateView.as_view(template_name='home.html'), name='home'),
path('password_reset/', auth_views.PasswordResetView.as_view(
path('', include('django.contrib.auth.urls')),
path('signup/', views.SignUpView.as_view(), name='signup'),
path('profile/', views.UserChangeView.as_view(), name='profile'),
path('api/', include((router.urls, app_name))),
path('api/annee_list/', views.AnneeView.as_view()),
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Max, Q
from django.http import HttpResponse, JsonResponse, FileResponse
from django.urls import reverse_lazy
from django.views import View
from django.views.generic.edit import CreateView
from django.views.generic.edit import CreateView, UpdateView
from rest_framework import permissions
from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied, ValidationError
......@@ -11,9 +12,9 @@ from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from am import serializers
from .forms import UtilisateurCreationForm
from .forms import UtilisateurCreationForm, UtilisateurChangeForm
from .models import Question, Classe, Feuille, Theme, QuestionPosee, Seance, LatexModel, QuestionOrder, \
LatexModelPart, Utilisateur
from .serializers import SeanceSerializerR, ThemeSerializer, LatexModelSerializer, \
......@@ -28,6 +29,17 @@ class SignUpView(CreateView):
template_name = 'registration/signup.html'
class UserChangeView(LoginRequiredMixin, UpdateView):
login_url = 'am:login' # if not logged
model = Utilisateur
form_class = UtilisateurChangeForm
success_url = reverse_lazy('am:home')
template_name = 'registration/profile.html'
def get_object(self, queryset=None):
return self.request.user
class AnneeView(View):
def get(request):
......@@ -38,7 +38,7 @@
<div class="right">
<button id="undo" :disabled="! hasUndoable" :title="undoMessage" @click="undo"></button>
<button id="redo" :disabled="! hasRedoable" :title="redoMessage" @click="redo"></button>
<span data-testid="username">{{ getusername() }}</span>
<span data-testid="username"><a href="./profile/">{{ getusername() }}</a></span>
<a href="logout/">Déconnexion</a>
......@@ -125,6 +125,9 @@ export default {
getusername() {
return username;
getuserid() {
showMessage(message) {
<!-- templates/registration/signup.html -->
{% extends 'base.html' %}
{% block title %} - Modifier mon profil{% endblock %}
{% block head %}
th {
vertical-align: top;
{% endblock %}
{% block content %}
<h1>Activités Mentales</h1>
<a href="/am/">Retour à l'accueil</a>
<h2>Modifier mon profil</h2>
<form method="post">
{% csrf_token %}
{{ form.as_table }}
<button type="submit">Enregistrer</button>
{% endblock %}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment