Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
25d9dbe9
Commit
25d9dbe9
authored
Sep 06, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge with cmdb
parents
02b5483d
3c6f50b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
88 additions
and
112 deletions
+88
-112
forms.py
apps/assets/forms.py
+1
-1
asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+1
-1
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
_header_bar.html
apps/templates/_header_bar.html
+7
-1
_user_profile.html
apps/templates/_user_profile.html
+1
-1
forms.py
apps/users/forms.py
+13
-8
models.py
apps/users/models.py
+1
-1
_user.html
apps/users/templates/users/_user.html
+2
-3
forgot_password.html
apps/users/templates/users/forgot_password.html
+1
-1
login.html
apps/users/templates/users/login.html
+4
-8
user_detail.html
apps/users/templates/users/user_detail.html
+3
-3
user_list.html
apps/users/templates/users/user_list.html
+3
-3
user_update.html
apps/users/templates/users/user_update.html
+2
-2
urls.py
apps/users/urls.py
+31
-11
utils.py
apps/users/utils.py
+2
-2
views.py
apps/users/views.py
+16
-66
No files found.
apps/assets/forms.py
View file @
25d9dbe9
...
...
@@ -16,7 +16,7 @@ class AssetForm(forms.ModelForm):
]
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'
Join asset
groups'
)}),
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'
Select asset
groups'
)}),
}
...
...
apps/assets/templates/assets/asset_group_list.html
View file @
25d9dbe9
...
...
@@ -29,7 +29,7 @@
<td
class=
"text-center"
>
{{ asset_group.assets.count }}
</td>
<td
class=
"text-center"
>
{{ asset_group.comment }}
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'assets:asset-group-update' pk=asset_group.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Edit
' %}
</a>
<a
href=
"{% url 'assets:asset-group-update' pk=asset_group.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Update
' %}
</a>
<a
href=
"{% url 'assets:asset-group-delete' pk=asset_group.id %}"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
</td>
</tr>
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
25d9dbe9
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
25d9dbe9
This diff is collapsed.
Click to expand it.
apps/templates/_header_bar.html
View file @
25d9dbe9
...
...
@@ -19,9 +19,15 @@
</a>
</li>
<li>
{% if user.is_authenticated %}
<a
href=
"{% url 'users:logout' %}"
>
<i
class=
"fa fa-sign-out"
></i>
Log out
<i
class=
"fa fa-sign-out"
></i>
{% trans 'Logout' %}
</a>
{% else %}
<a
href=
"{% url 'users:login' %}"
>
<i
class=
"fa fa-sign-in"
></i>
{% trans 'Login' %}
</a>
{% endif %}
</li>
</ul>
</nav>
...
...
apps/templates/_user_profile.html
View file @
25d9dbe9
...
...
@@ -8,7 +8,7 @@
<a
data-toggle=
"dropdown"
class=
"dropdown-toggle"
href=
"#"
>
<span
class=
"clear"
>
<span
class=
"block m-t-xs"
>
<strong
class=
"font-bold"
>
{{
request.
user.name }}
<span
style=
"color: #8095a8"
></span></strong>
<strong
class=
"font-bold"
>
{{ user.name }}
<span
style=
"color: #8095a8"
></span></strong>
</span>
<span
class=
"text-muted text-xs block"
>
{{ request.user.get_role_display | default:_('User') }}
<b
class=
"caret"
></b>
...
...
apps/users/forms.py
View file @
25d9dbe9
# ~*~ coding: utf-8 ~*~
from
django.forms
import
ModelForm
from
django
import
forms
from
captcha.fields
import
CaptchaField
from
django.contrib.auth.forms
import
AuthenticationForm
from
django.utils.translation
import
gettext_lazy
as
_
from
captcha.fields
import
CaptchaField
from
.models
import
User
,
UserGroup
class
UserLoginForm
(
forms
.
Form
):
class
UserLoginForm
(
Authentication
Form
):
username
=
forms
.
CharField
(
label
=
_
(
'Username'
),
max_length
=
100
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
100
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
100
,
strip
=
False
)
captcha
=
CaptchaField
()
class
UserCreateForm
(
ModelForm
):
class
UserCreateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
...
...
@@ -32,7 +35,8 @@ class UserCreateForm(ModelForm):
}
class
UserUpdateForm
(
ModelForm
):
class
UserUpdateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
...
...
@@ -47,11 +51,12 @@ class UserUpdateForm(ModelForm):
}
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Join usergroups'
)}),
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Join user
groups'
)}),
}
class
UserGroupForm
(
ModelForm
):
class
UserGroupForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
UserGroup
...
...
apps/users/models.py
View file @
25d9dbe9
...
...
@@ -106,7 +106,7 @@ class User(AbstractUser):
username
=
models
.
CharField
(
max_length
=
20
,
unique
=
True
,
verbose_name
=
_
(
'Username'
))
name
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
verbose_name
=
_
(
'Name'
))
email
=
models
.
EmailField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Email'
))
groups
=
models
.
ManyToManyField
(
UserGroup
,
related_name
=
'users'
,
blank
=
True
,
verbose_name
=
_
(
'Usergroup'
))
groups
=
models
.
ManyToManyField
(
UserGroup
,
related_name
=
'users'
,
blank
=
True
,
verbose_name
=
_
(
'User
group'
))
role
=
models
.
CharField
(
choices
=
ROLE_CHOICES
,
default
=
'User'
,
max_length
=
10
,
blank
=
True
,
verbose_name
=
_
(
'Role'
))
avatar
=
models
.
ImageField
(
upload_to
=
"avatar"
,
verbose_name
=
_
(
'Avatar'
))
wechat
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
,
verbose_name
=
_
(
'Wechat'
))
...
...
apps/users/templates/users/_user.html
View file @
25d9dbe9
...
...
@@ -14,7 +14,7 @@
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
{%
trans 'Create user'
%}
</h5>
<h5>
{%
block user_template_title %}{% trans 'Create user' %}{% endblock
%}
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
@@ -94,4 +94,4 @@
});
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
apps/users/templates/users/forg
e
t_password.html
→
apps/users/templates/users/forg
o
t_password.html
View file @
25d9dbe9
...
...
@@ -23,7 +23,7 @@
<div
class=
"ibox-content"
>
<img
src=
"{% static 'img/logo.png' %}"
style=
"margin: auto"
width=
"82"
height=
"82"
>
<h2
class=
"font-bold"
style=
"display: inline"
>
{% trans 'Forg
e
t password' %} ?
</h2>
<h2
class=
"font-bold"
style=
"display: inline"
>
{% trans 'Forg
o
t password' %} ?
</h2>
<h1></h1>
{% if errors %}
...
...
apps/users/templates/users/login.html
View file @
25d9dbe9
...
...
@@ -45,11 +45,10 @@
{% if form.errors %}
{% if 'captcha' in form.errors %}
<p
class=
"red-fonts"
>
{% trans 'Captcha invalid' %}
</p>
{% else %}
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
{% endif %}
{% endif %}
{% if errors %}
<p
class=
"red-fonts"
>
{{ errors }}
</p>
{% endif %}
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
>
</div>
...
...
@@ -61,8 +60,8 @@
</div>
<button
type=
"submit"
class=
"btn btn-primary block full-width m-b"
>
{% trans 'Login' %}
</button>
<a
href=
"{% url 'users:forg
e
t-password' %}"
>
<small>
Forgot password
?
</small>
<a
href=
"{% url 'users:forg
o
t-password' %}"
>
<small>
{% trans 'Forgot password' %}
?
</small>
</a>
<p
class=
"text-muted text-center"
>
...
...
@@ -84,7 +83,4 @@
</div>
</div>
</body>
</html>
apps/users/templates/users/user_detail.html
View file @
25d9dbe9
...
...
@@ -178,7 +178,7 @@
<div
class=
"panel panel-info"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Usergroup' %}
<i
class=
"fa fa-info-circle"
></i>
{% trans 'User
group' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
...
...
@@ -186,7 +186,7 @@
<form>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans '
Select user
groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans '
Join user
groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for group in groups %}
<option
value=
"{{ group.id }}"
>
{{ group.name }}
</option>
{% endfor %}
...
...
@@ -195,7 +195,7 @@
</tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<button
type=
"button"
class=
"btn btn-info btn-small"
>
{% trans '
Add
' %}
</button>
<button
type=
"button"
class=
"btn btn-info btn-small"
>
{% trans '
Join
' %}
</button>
</td>
</tr>
</form>
...
...
apps/users/templates/users/user_list.html
View file @
25d9dbe9
...
...
@@ -12,7 +12,7 @@
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=name"
>
{% trans 'Name' %}
</a></th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'Usergroup' %}
</th>
<th
class=
"text-center"
>
{% trans 'User
group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=date_expired"
>
{% trans 'Active' %}
</a></th>
<th
class=
"text-center"
></th>
...
...
@@ -34,14 +34,14 @@
<td
class=
"text-center"
title=
"{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"
>
{{ user.groups.all|join_queryset_attr:"name" }}
</td>
<th
class=
"text-center"
>
{{ user.name }}
</th>
<td
class=
"text-center"
>
{% if user.is_expired %}
{% if user.is_expired
and user.is_active
%}
<i
class=
"fa fa-times text-danger"
></i>
{% else %}
<i
class=
"fa fa-check text-navy"
></i>
{% endif %}
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'users:user-update' pk=user.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Edit
' %}
</a>
<a
href=
"{% url 'users:user-update' pk=user.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Update
' %}
</a>
<a
href=
"{% url 'users:user-delete' pk=user.id %}"
class=
"btn btn-xs btn-danger del {% if user.id == request.user.id or user.username == 'admin' %} disabled {% endif %}"
>
{% trans 'Delete' %}
</a>
</td>
</tr>
...
...
apps/users/templates/users/user_update.html
View file @
25d9dbe9
{% extends 'users/_user.html' %}
{% load i18n %}
{% block user_template_title %}{% trans "Update user" %}{% endblock %}
{% block username %}
<div
class=
"form-group"
>
<label
for=
"{{ form.username.id_for_label }}"
class=
"col-sm-2 control-label"
>
{% trans 'Username' %}
</label>
...
...
@@ -16,4 +17,4 @@
<input
id=
"password"
name=
"password"
type=
"password"
class=
"form-control"
>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
apps/users/urls.py
View file @
25d9dbe9
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
url
from
django.contrib.auth
import
views
as
auth_views
from
django.u
rls
import
reverse_lazy
from
django.u
tils.translation
import
ugettext
as
_
import
views
import
api
from
.forms
import
UserLoginForm
app_name
=
'users'
urlpatterns
=
[
url
(
r'^login$'
,
views
.
UserLoginView
.
as_view
(),
name
=
'login'
),
url
(
r'^logout$'
,
views
.
UserLogoutView
.
as_view
(),
name
=
'logout'
),
url
(
r'^password/forget$'
,
views
.
UserForgetPasswordView
.
as_view
(),
name
=
'forget-password'
),
url
(
r'^password/forget/sendmail-success$'
,
views
.
UserForgetPasswordSendmailSuccessView
.
as_view
(),
name
=
'forget-password-sendmail-success'
),
url
(
r'^login$'
,
auth_views
.
login
,
{
'template_name'
:
"users/login.html"
,
'authentication_form'
:
UserLoginForm
,
'redirect_authenticated_user'
:
True
},
name
=
'login'
),
url
(
r'^logout$'
,
auth_views
.
logout
,
{
"template_name"
:
"common/flash_message_standalone.html"
,
"extra_context"
:
{
'title'
:
_
(
'Logout success'
),
'messages'
:
_
(
'Logout success, return login page'
),
'redirect_url'
:
'/users/login'
,
'auto_redirect'
:
True
,
}
},
name
=
'logout'
),
url
(
r'^password/forgot$'
,
views
.
UserForgotPasswordView
.
as_view
(),
name
=
'forgot-password'
),
url
(
r'^password/forgot/sendmail-success$'
,
views
.
UserForgotPasswordSendmailSuccessView
.
as_view
(),
name
=
'forgot-password-sendmail-success'
),
url
(
r'^password/reset$'
,
views
.
UserResetPasswordView
.
as_view
(),
name
=
'reset-password'
),
url
(
r'^password/reset/success$'
,
views
.
UserResetPasswordSuccessView
.
as_view
(),
name
=
'reset-password-success'
),
url
(
r'^password/reset/success$'
,
views
.
UserResetPasswordSuccessView
.
as_view
(),
name
=
'reset-password-success'
),
url
(
r'^user$'
,
views
.
UserListView
.
as_view
(),
name
=
'user-list'
),
url
(
r'^user/(?P<pk>[0-9]+)$'
,
views
.
UserDetailView
.
as_view
(),
name
=
'user-detail'
),
url
(
r'^user/create$'
,
views
.
UserCreateView
.
as_view
(),
name
=
'user-create'
),
...
...
@@ -30,8 +48,10 @@ urlpatterns = [
urlpatterns
+=
[
url
(
r'^v1/users$'
,
api
.
UserListAddApi
.
as_view
(),
name
=
'user-list-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)$'
,
api
.
UserDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-detail-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)$'
,
api
.
UserDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-detail-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)/active$'
,
api
.
UserActiveApi
.
as_view
(),
name
=
'user-active-api'
),
url
(
r'^v1/usergroups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/usergroups/(?P<pk>[0-9]+)$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
url
(
r'^v1/user-groups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
]
apps/users/utils.py
View file @
25d9dbe9
...
...
@@ -86,7 +86,7 @@ def user_add_success_next(user):
'name'
:
user
.
name
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
'rest_password_token'
:
user
.
generate_reset_token
(),
'forget_password_url'
:
reverse
(
'users:forg
e
t-password'
,
external
=
True
),
'forget_password_url'
:
reverse
(
'users:forg
o
t-password'
,
external
=
True
),
'email'
:
user
.
email
,
'login_url'
:
reverse
(
'users:login'
,
external
=
True
),
}
...
...
@@ -117,7 +117,7 @@ def send_reset_password_mail(user):
'name'
:
user
.
name
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
'rest_password_token'
:
user
.
generate_reset_token
(),
'forget_password_url'
:
reverse
(
'users:forg
e
t-password'
,
external
=
True
),
'forget_password_url'
:
reverse
(
'users:forg
o
t-password'
,
external
=
True
),
'email'
:
user
.
email
,
'login_url'
:
reverse
(
'users:login'
,
external
=
True
),
}
...
...
apps/users/views.py
View file @
25d9dbe9
...
...
@@ -4,78 +4,28 @@ from __future__ import unicode_literals
import
logging
from
django.shortcuts
import
get_object_or_404
,
reverse
,
render
,
Http404
,
redirect
from
django.conf
import
settings
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.db.models
import
Q
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
get_object_or_404
,
reverse
from
django.urls
import
reverse_lazy
from
django.utils.translation
import
ugettext
as
_
from
django.db.models
import
Q
from
django.views.generic.base
import
View
,
TemplateView
from
django.views.generic.base
import
TemplateView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
UpdateView
,
ProcessFormView
,
FormView
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
UpdateView
from
django.views.generic.detail
import
DetailView
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.conf
import
settings
from
django.http
import
HttpResponseRedirect
from
django.contrib.auth
import
views
as
auth_view
,
authenticate
,
login
,
logout
from
common.utils
import
get_object_or_none
from
.models
import
User
,
UserGroup
from
.forms
import
UserCreateForm
,
UserUpdateForm
,
UserGroupForm
,
UserLoginForm
from
.utils
import
AdminUserRequiredMixin
,
ssh_key_gen
,
user_add_success_next
,
send_reset_password_mail
from
.utils
import
AdminUserRequiredMixin
,
user_add_success_next
,
send_reset_password_mail
logger
=
logging
.
getLogger
(
'jumpserver.users.views'
)
class
UserLoginView
(
FormView
):
template_name
=
'users/login.html'
form_class
=
UserLoginForm
redirect_field_name
=
'next'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
is_staff
:
return
redirect
(
request
.
POST
.
get
(
self
.
redirect_field_name
,
reverse
(
'index'
)))
# Todo: Django have bug, lose context issue: https://github.com/django/django/pull/7202
# so we jump it and use origin method render_to_response
# return super(UserLoginView, self).get(request, *args, **kwargs)
return
self
.
render_to_response
(
self
.
get_context_data
(
**
kwargs
))
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
self
.
get_form
()
if
not
form
.
is_valid
():
return
self
.
form_invalid
(
form
)
username
=
form
[
'username'
]
.
value
()
password
=
form
[
'password'
]
.
value
()
user
=
authenticate
(
username
=
username
,
password
=
password
)
if
user
is
None
:
kwargs
.
update
({
'errors'
:
_
(
'Username or password invalid'
)})
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
login
(
request
,
user
)
return
redirect
(
request
.
GET
.
get
(
self
.
redirect_field_name
,
reverse
(
'index'
)))
class
UserLogoutView
(
TemplateView
):
template_name
=
'common/flash_message_standalone.html'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
logout
(
request
)
return
super
(
UserLogoutView
,
self
)
.
get
(
request
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'title'
:
_
(
'Logout success'
),
'messages'
:
_
(
'Logout success, return login page'
),
'redirect_url'
:
reverse
(
'users:login'
),
'auto_redirect'
:
True
,
}
kwargs
.
update
(
context
)
return
super
(
UserLogoutView
,
self
)
.
get_context_data
(
**
kwargs
)
class
UserListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
User
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
...
@@ -106,7 +56,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
form_class
=
UserCreateForm
template_name
=
'users/user_create.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
_
(
'Create user<a href="
%
s">
%
s</a> success.'
)
success_message
=
_
(
'Create user
<a href="
%
s">
%
s</a> success.'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -150,7 +100,7 @@ class UserUpdateView(AdminUserRequiredMixin, UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'
Edit
user'
)})
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'
Update
user'
)})
return
context
...
...
@@ -192,7 +142,7 @@ class UserGroupListView(AdminUserRequiredMixin, ListView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserGroupListView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Usergroup list'
),
'keyword'
:
self
.
keyword
})
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'User
group list'
),
'keyword'
:
self
.
keyword
})
return
context
...
...
@@ -230,8 +180,8 @@ class UserGroupDeleteView(DeleteView):
pass
class
UserForg
e
tPasswordView
(
TemplateView
):
template_name
=
'users/forg
e
t_password.html'
class
UserForg
o
tPasswordView
(
TemplateView
):
template_name
=
'users/forg
o
t_password.html'
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
email
=
request
.
POST
.
get
(
'email'
)
...
...
@@ -240,10 +190,10 @@ class UserForgetPasswordView(TemplateView):
return
self
.
get
(
request
,
errors
=
_
(
'Email address invalid, input again'
))
else
:
send_reset_password_mail
(
user
)
return
HttpResponseRedirect
(
reverse
(
'users:forg
e
t-password-sendmail-success'
))
return
HttpResponseRedirect
(
reverse
(
'users:forg
o
t-password-sendmail-success'
))
class
UserForg
e
tPasswordSendmailSuccessView
(
TemplateView
):
class
UserForg
o
tPasswordSendmailSuccessView
(
TemplateView
):
template_name
=
'common/flash_message_standalone.html'
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -253,7 +203,7 @@ class UserForgetPasswordSendmailSuccessView(TemplateView):
'redirect_url'
:
reverse
(
'users:login'
),
}
kwargs
.
update
(
context
)
return
super
(
UserForg
e
tPasswordSendmailSuccessView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
UserForg
o
tPasswordSendmailSuccessView
,
self
)
.
get_context_data
(
**
kwargs
)
class
UserResetPasswordSuccessView
(
TemplateView
):
...
...
Write
Preview
Markdown
is supported
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