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
ae9bbb40
Commit
ae9bbb40
authored
Aug 23, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flash message template
parent
8e5e788b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
_message.html
apps/templates/_message.html
+7
-0
base.html
apps/templates/base.html
+1
-0
views.py
apps/users/views.py
+12
-2
No files found.
apps/templates/_message.html
0 → 100644
View file @
ae9bbb40
{% if messages %}
{% for message in messages %}
<div
class=
"alert alert-{{ message.tags }}"
style=
"margin: 20px auto 0px"
>
{{ message|safe }}
</div>
{% endfor %}
{% endif %}
apps/templates/base.html
View file @
ae9bbb40
...
...
@@ -20,6 +20,7 @@
{% include '_left_side_bar.html' %}
<div
id=
"page-wrapper"
class=
"gray-bg"
>
{% include '_header_bar.html' %}
{% include '_message.html' %}
{% block content %}{% endblock %}
{% include '_footer.html' %}
</div>
...
...
apps/users/views.py
View file @
ae9bbb40
# ~*~ coding: utf-8 ~*~
from
django.shortcuts
import
get_object_or_404
from
__future__
import
unicode_literals
from
django.shortcuts
import
get_object_or_404
,
reverse
from
django.urls
import
reverse_lazy
from
django.db.models
import
Q
from
django.views.generic.list
import
ListView
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
.models
import
User
,
UserGroup
,
Role
...
...
@@ -37,11 +40,12 @@ class UserListView(ListView):
return
context
class
UserAddView
(
CreateView
):
class
UserAddView
(
SuccessMessageMixin
,
CreateView
):
model
=
User
form_class
=
UserAddForm
template_name
=
'users/user_add.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
'添加用户 <a href="
%
s">
%
s</a> 成功 .'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserAddView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -54,6 +58,12 @@ class UserAddView(CreateView):
user
.
save
()
return
super
(
UserAddView
,
self
)
.
form_valid
(
form
)
def
get_success_message
(
self
,
cleaned_data
):
return
self
.
success_message
%
(
reverse_lazy
(
'users:user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,
)
class
UserUpdateView
(
UpdateView
):
model
=
User
...
...
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