Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GuiΩ
ActivitesMentales_Django
Commits
0be05c89
Commit
0be05c89
authored
May 07, 2022
by
GuiΩ
Browse files
Profil form is filled with the user's fields
Password form doesn't work
parent
8383fc01
Changes
6
Hide whitespace changes
Inline
Side-by-side
am/forms.py
View file @
0be05c89
...
...
@@ -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
):
...
...
am/models.py
View file @
0be05c89
...
...
@@ -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
)
...
...
am/urls.py
View file @
0be05c89
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
(
success_url
=
reverse_lazy
(
'am:password_reset_done'
),
),
name
=
'password_reset'
success_url
=
reverse_lazy
(
'am:password_reset_done'
),
),
name
=
'password_reset'
),
path
(
'reset/<uidb64>/<token>/'
,
auth_views
.
PasswordResetConfirmView
.
as_view
(
success_url
=
reverse_lazy
(
'am:password_reset_complete'
)),
name
=
'password_reset_confirm'
),
),
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
()),
]
am/views.py
View file @
0be05c89
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
LatexModelPart
,
Utilisateur
from
.serializers
import
SeanceSerializerR
,
ThemeSerializer
,
LatexModelSerializer
,
\
LatexModelPartSerializer
...
...
@@ -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
):
@
staticmethod
def
get
(
request
):
...
...
src/components/Home.vue
View file @
0be05c89
...
...
@@ -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>
</div>
</div>
...
...
@@ -125,6 +125,9 @@ export default {
getusername
()
{
return
username
;
},
getuserid
()
{
return
user
.
id
;
},
showMessage
(
message
)
{
console
.
log
(
message
)
this
.
$refs
.
messageBox
.
show
(
message
);
...
...
templates/registration/profile.html
0 → 100644
View file @
0be05c89
<!-- templates/registration/signup.html -->
{% extends 'base.html' %}
{% block title %} - Modifier mon profil{% endblock %}
{% block head %}
<style>
th
{
vertical-align
:
top
;
}
</style>
{% endblock %}
{% block content %}
<h1>
Activités Mentales
</h1>
<a
href=
"/am/"
>
Retour à l'accueil
</a>
<h2>
Modifier mon profil
</h2>
<form
method=
"post"
>
<table>
{% csrf_token %}
{{ form.as_table }}
</table>
<button
type=
"submit"
>
Enregistrer
</button>
</form>
{% endblock %}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment