Add profile form in matmat

This commit is contained in:
Skia 2017-05-10 21:59:22 +02:00
parent e00c948da9
commit dec1a2cdd7
3 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,9 @@
</form>
{% else %}
<p>{% trans matmat = user.matmat_user.matmat %}You are subscribed to the Matmatronch {{ matmat }}{% endtrans %}</p>
<p><a href="{{ url("matmat:profile") }}">Edit my profile</a></p>
<hr>
<div>
{% for u in user.matmat_user.matmat.users.exclude(id=user.matmat_user.id) %}
<div class="ib">
<div>{{ u.user.get_display_name() }}</div>
@ -25,6 +28,7 @@
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
{% endblock %}

View File

@ -34,5 +34,6 @@ urlpatterns = [
url(r'^(?P<user_id>[0-9]+)/new_comment$', MatmatCommentCreateView.as_view(), name='new_comment'),
url(r'^comment/(?P<comment_id>[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'),
]

View File

@ -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