-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update user model
- Loading branch information
Showing
18 changed files
with
276 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "_base.html" %} | ||
{% load i18n %} | ||
|
||
{% block html_title %}{% trans 'LGR Tools user edition' %}{% endblock %} | ||
|
||
{% block navbar-right %} | ||
<a class="header-link" href="{% url 'lgr_modes' %}">{% trans "Switch mode" %}</a> | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content-title %} | ||
{% blocktrans with email=user.email %}Edit user {{ email }}{% endblocktrans %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<form class="form-horizontal" method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{% include "lgr_editor/_form_field.html" with field=form.first_name control_width=8 %} | ||
{% include "lgr_editor/_form_field.html" with field=form.last_name control_width=8 %} | ||
{% include "lgr_editor/_form_field.html" with field=form.email control_width=8 %} | ||
{% include "lgr_editor/_form_field.html" with field=form.role control_width=8 %} | ||
<button id="submit" type="submit" class="btn btn-primary">{% trans "Update" %}</button> | ||
</form> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
views.py | ||
""" | ||
import logging | ||
|
||
from django.contrib import messages | ||
from django.urls import reverse | ||
from django.utils.translation import ugettext_lazy as _ | ||
from django.views.generic import UpdateView | ||
|
||
from lgr_auth.forms import UserForm | ||
from lgr_auth.models import LgrUser | ||
|
||
logger = logging.getLogger(__name__) | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
|
||
|
||
class LgrUserUpdateView(LoginRequiredMixin, UpdateView): | ||
model = LgrUser | ||
form_class = UserForm | ||
pk_url_kwarg = 'user_pk' | ||
template_name = 'lgr_auth/user_update.html' | ||
success_url_name = 'lgr_update_user' | ||
|
||
def get_queryset(self): | ||
return LgrUser.objects.filter(pk=self.request.user.pk) | ||
|
||
def get_success_url(self): | ||
return reverse(self.success_url_name, kwargs={'user_pk': self.kwargs[self.pk_url_kwarg]}) | ||
|
||
def form_valid(self, form): | ||
messages.add_message(self.request, messages.SUCCESS, _('User updated')) | ||
return super().form_valid(form) | ||
|
||
def form_invalid(self, form): | ||
messages.add_message(self.request, messages.ERROR, _('Failed to update user')) | ||
return super().form_invalid(form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.