Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
red-group-test
red-ci-cd
Commits
719110c3
Commit
719110c3
authored
Nov 12, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #453 in RMS/api-main-service from red-develop to RMSv2
* commit '
125712fa
': bulk create user
parents
b66982e3
125712fa
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
82 deletions
+178
-82
app/applicationlayer/management/account/views.py
app/applicationlayer/management/account/views.py
+125
-81
app/helper/email_service/sender.py
app/helper/email_service/sender.py
+53
-1
No files found.
app/applicationlayer/management/account/views.py
View file @
719110c3
This diff is collapsed.
Click to expand it.
app/helper/email_service/sender.py
View file @
719110c3
import
os
from
django.core.mail
import
send_mail
from
django.core.mail
import
send_mail
,
EmailMessage
from
app.entities
import
models
from
django.conf
import
settings
from
django.core
import
mail
as
email_connection
from
django.db
import
transaction
@
transaction
.
atomic
def
batch_email_users
(
args
):
# print(args[0])
connection
=
email_connection
.
get_connection
()
messages
=
[]
connection
.
open
()
for
data
in
args
[
0
]
.
iterator
():
name
=
data
[
'name'
]
username
=
data
[
'username'
]
password
=
data
[
'password'
]
recipient
=
data
[
'email'
]
admin
=
args
[
1
]
F
=
open
(
os
.
path
.
join
(
settings
.
EMAIL_TEMPLATES_ROOT
,
'RMS-NEWUSER.html'
),
'r'
)
FC
=
F
.
read
()
FC
=
FC
.
replace
(
'{name}'
,
name
)
FC
=
FC
.
replace
(
'{username}'
,
username
)
FC
=
FC
.
replace
(
'{password}'
,
password
)
FC
=
FC
.
replace
(
'{url}'
,
settings
.
FRONT_END_URL
+
'/cms/profile'
)
send_mail
(
subject
=
'Resource Management System: Welcome!'
,
message
=
''
,
from_email
=
settings
.
EMAIL_DEFAULT_SENDER
,
recipient_list
=
(
recipient
,),
html_message
=
FC
,
fail_silently
=
False
)
models
.
UserHistory
.
objects
.
filter
(
username
=
username
)
.
update
(
sent
=
True
)
connection
.
close
()
return
True
def
batch_email_admin
(
args
):
filename
=
args
[
0
]
recipient
=
args
[
1
]
email
=
EmailMessage
(
'Resource Management System: Bulk Users!'
,
'kindly see the attach file.'
,
settings
.
EMAIL_DEFAULT_SENDER
,
[
recipient
]
)
email
.
attach_file
(
filename
)
email
.
send
()
os
.
remove
(
filename
)
def
account_created
(
args
):
...
...
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