Ajout d'une interface d'édition du profil de l'utilisateur courant
This commit is contained in:
parent
5783b5caa0
commit
9430b8b0c8
@ -35,6 +35,7 @@ from .models import (
|
|||||||
Place,
|
Place,
|
||||||
RecurrentImport,
|
RecurrentImport,
|
||||||
Tag,
|
Tag,
|
||||||
|
UserProfile,
|
||||||
)
|
)
|
||||||
from .templatetags.event_extra import event_field_verbose_name, field_to_html
|
from .templatetags.event_extra import event_field_verbose_name, field_to_html
|
||||||
from .templatetags.utils_extra import int_to_abc
|
from .templatetags.utils_extra import int_to_abc
|
||||||
@ -971,3 +972,12 @@ class MessageEventForm(ModelForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields["message"].label = _("Add a comment")
|
self.fields["message"].label = _("Add a comment")
|
||||||
|
|
||||||
|
|
||||||
|
class UserProfileForm(ModelForm):
|
||||||
|
|
||||||
|
user = CharField(widget=HiddenInput())
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = UserProfile
|
||||||
|
fields = "__all__"
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -123,6 +123,7 @@
|
|||||||
</article>
|
</article>
|
||||||
<article>
|
<article>
|
||||||
<p>Vous êtes connecté(e) en tant que {{ user }}.</p>
|
<p>Vous êtes connecté(e) en tant que {{ user }}.</p>
|
||||||
|
<a role="button" href="{% url 'edit_profile' %}">Modifier le profil</a>
|
||||||
<a role="button" href="{% url 'logout' %}?next={% url 'home' %}">Déconnexion</a>
|
<a role="button" href="{% url 'logout' %}?next={% url 'home' %}">Déconnexion</a>
|
||||||
</article>
|
</article>
|
||||||
</aside>
|
</aside>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
{% extends "agenda_culturel/page-admin.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% block title %}
|
||||||
|
{% block og_title %}Modification du profil de {{ object.user }}{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block fluid %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h1>Modification du profil de {{ object.user }}</h1>
|
||||||
|
</header>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.media }}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<div class="grid buttons">
|
||||||
|
<a href="{% url 'administration' %}" role="button" class="secondary">Annuler</a>
|
||||||
|
<input type="submit" value="Envoyer">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
@ -105,6 +105,7 @@ from .views import (
|
|||||||
apply_categorisation_rules,
|
apply_categorisation_rules,
|
||||||
moderation_rules,
|
moderation_rules,
|
||||||
import_requirements,
|
import_requirements,
|
||||||
|
UserProfileUpdateView,
|
||||||
)
|
)
|
||||||
|
|
||||||
event_dict = {
|
event_dict = {
|
||||||
@ -464,6 +465,7 @@ urlpatterns = [
|
|||||||
name="cached-sitemap",
|
name="cached-sitemap",
|
||||||
),
|
),
|
||||||
path("cache/clear", clear_cache, name="clear_cache"),
|
path("cache/clear", clear_cache, name="clear_cache"),
|
||||||
|
path("profile/edit", UserProfileUpdateView.as_view(), name="edit_profile"),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
@ -80,6 +80,7 @@ from .forms import (
|
|||||||
TagRenameForm,
|
TagRenameForm,
|
||||||
URLSubmissionFormSet,
|
URLSubmissionFormSet,
|
||||||
URLSubmissionFormWithContact,
|
URLSubmissionFormWithContact,
|
||||||
|
UserProfileForm,
|
||||||
)
|
)
|
||||||
from .import_tasks.extractor import Extractor
|
from .import_tasks.extractor import Extractor
|
||||||
from .models import (
|
from .models import (
|
||||||
@ -95,6 +96,7 @@ from .models import (
|
|||||||
StaticContent,
|
StaticContent,
|
||||||
Tag,
|
Tag,
|
||||||
remove_accents,
|
remove_accents,
|
||||||
|
UserProfile,
|
||||||
)
|
)
|
||||||
from .utils import PlaceGuesser
|
from .utils import PlaceGuesser
|
||||||
|
|
||||||
@ -2984,3 +2986,17 @@ def clear_cache(request):
|
|||||||
request,
|
request,
|
||||||
"agenda_culturel/clear_cache.html",
|
"agenda_culturel/clear_cache.html",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UserProfileUpdateView(
|
||||||
|
SuccessMessageMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
|
):
|
||||||
|
model = UserProfile
|
||||||
|
success_message = _("Your user profile has been successfully modified.")
|
||||||
|
success_url = reverse_lazy("administration")
|
||||||
|
form_class = UserProfileForm
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.user.userprofile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user