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
3193c554
Commit
3193c554
authored
Apr 10, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/dev' into dev
parents
ed71e7d2
b8b78ffe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
signals_handler.py
apps/users/signals_handler.py
+20
-11
user.py
apps/users/views/user.py
+1
-0
No files found.
apps/users/signals_handler.py
View file @
3193c554
...
...
@@ -2,19 +2,29 @@
#
from
django.dispatch
import
receiver
from
django.db.models.signals
import
post_save
#
from django.db.models.signals import post_save
from
common.utils
import
get_logger
from
.models
import
User
from
.signals
import
post_user_create
# from .models import User
logger
=
get_logger
(
__file__
)
@receiver
(
post_save
,
sender
=
User
)
def
on_user_created
(
sender
,
instance
=
None
,
created
=
False
,
**
kwargs
):
if
created
:
logger
.
debug
(
"Receive user `{}` create signal"
.
format
(
instance
.
name
))
from
.utils
import
send_user_created_mail
logger
.
info
(
" - Sending welcome mail ..."
.
format
(
instance
.
name
))
if
instance
.
email
:
send_user_created_mail
(
instance
)
\ No newline at end of file
# @receiver(post_save, sender=User)
# def on_user_created(sender, instance=None, created=False, **kwargs):
# if created:
# logger.debug("Receive user `{}` create signal".format(instance.name))
# from .utils import send_user_created_mail
# logger.info(" - Sending welcome mail ...".format(instance.name))
# if instance.email:
# send_user_created_mail(instance)
@receiver
(
post_user_create
)
def
on_user_create
(
sender
,
user
=
None
,
**
kwargs
):
logger
.
debug
(
"Receive user `{}` create signal"
.
format
(
user
.
name
))
from
.utils
import
send_user_created_mail
logger
.
info
(
" - Sending welcome mail ..."
.
format
(
user
.
name
))
if
user
.
email
:
send_user_created_mail
(
user
)
apps/users/views/user.py
View file @
3193c554
...
...
@@ -79,6 +79,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
user
=
form
.
save
(
commit
=
False
)
user
.
created_by
=
self
.
request
.
user
.
username
or
'System'
user
.
save
()
post_user_create
.
send
(
self
.
__class__
,
user
=
user
)
return
super
()
.
form_valid
(
form
)
...
...
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