From dec1a2cdd76e9a399fde57862e6cae1df1e68ffd Mon Sep 17 00:00:00 2001 From: Skia Date: Wed, 10 May 2017 21:59:22 +0200 Subject: [PATCH] Add profile form in matmat --- matmat/templates/matmat/user_tools.jinja | 4 ++++ matmat/urls.py | 1 + matmat/views.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/matmat/templates/matmat/user_tools.jinja b/matmat/templates/matmat/user_tools.jinja index 2278665d..ef145c52 100644 --- a/matmat/templates/matmat/user_tools.jinja +++ b/matmat/templates/matmat/user_tools.jinja @@ -14,6 +14,9 @@ {% else %}

{% trans matmat = user.matmat_user.matmat %}You are subscribed to the Matmatronch {{ matmat }}{% endtrans %}

+

Edit my profile

+
+
{% for u in user.matmat_user.matmat.users.exclude(id=user.matmat_user.id) %}
{{ u.user.get_display_name() }}
@@ -25,6 +28,7 @@ {% endif %}
{% endfor %} +
{% endif %} {% endblock %} diff --git a/matmat/urls.py b/matmat/urls.py index cc10b39e..61ba11f1 100644 --- a/matmat/urls.py +++ b/matmat/urls.py @@ -34,5 +34,6 @@ urlpatterns = [ url(r'^(?P[0-9]+)/new_comment$', MatmatCommentCreateView.as_view(), name='new_comment'), url(r'^comment/(?P[0-9]+)/edit$', MatmatCommentEditView.as_view(), name='edit_comment'), url(r'^tools$', UserMatmatToolsView.as_view(), name='user_tools'), + url(r'^profile$', UserMatmatEditProfileView.as_view(), name='profile'), ] diff --git a/matmat/views.py b/matmat/views.py index 9a8c736d..fdc2b152 100644 --- a/matmat/views.py +++ b/matmat/views.py @@ -118,6 +118,22 @@ class UserMatmatToolsView(QuickNotifMixin, TemplateView): kwargs['subscribe_form'] = UserMatmatForm() return kwargs +class UserMatmatEditProfileView(UpdateView): + model = User + form_class = modelform_factory(User, + fields=['second_email', 'phone', 'department', 'dpt_option', + 'quote', 'parent_address'], + labels={ + 'second_email': _("Personal email (not UTBM)"), + 'phone': _("Phone"), + 'parent_address': _("Native town"), + }) + template_name = "core/edit.jinja" + success_url = reverse_lazy('matmat:user_tools') + + def get_object(self): + return self.request.user + class MatmatCommentFormView(): """ Create/edit a matmat comment