generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #824 from ita-social-projects/799-admin-admin-regi…
…stration [Admin] [BackEnd] admin registration
- Loading branch information
Showing
8 changed files
with
116 additions
and
8 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
25 changes: 25 additions & 0 deletions
25
BackEnd/administration/templates/administration/email_template.html
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,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="uk"> | ||
<head> | ||
<style> | ||
body { | ||
color: black; | ||
font-family: Arial, sans-serif; | ||
} | ||
p, b { | ||
color: black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<img src="{{protocol}}://178.212.110.52/craftMerge-logo.png" alt="CRAFTMERGE"/> | ||
<p>Доброго дня,</p> | ||
<p>Ваш пароль для входу на платформу: {{ password }} </p> | ||
<p>Посилання для входу: {{ domain }}/login </p> | ||
|
||
<p>З повагою,</p> | ||
<p>Команда CraftMerge</p> | ||
</div> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,6 @@ drf-spectacular==0.26.5 | |
ratelimit==2.2.1 | ||
django-debug-toolbar==4.3.0 | ||
celery==5.4.0 | ||
passlib==1.7.4 | ||
|
||
|
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,5 @@ | ||
from passlib import pwd | ||
|
||
|
||
def generate_password(): | ||
return pwd.genword() |
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,33 @@ | ||
from decouple import config | ||
from django.conf import settings | ||
from django.core.mail import EmailMultiAlternatives | ||
from django.template.loader import render_to_string | ||
|
||
|
||
EMAIL_CONTENT_SUBTYPE = "html" | ||
PROTOCOL = "http" | ||
DOMAIN = config("ALLOWED_ENV_HOST") | ||
|
||
|
||
def send_email_about_admin_registration(email, password): | ||
context = { | ||
"protocol": PROTOCOL, | ||
"password": password, | ||
"domain": DOMAIN, | ||
} | ||
|
||
recipient = email | ||
email_body = render_to_string( | ||
"administration/email_template.html", context | ||
) | ||
email = EmailMultiAlternatives( | ||
subject="Generated password for administrator", | ||
body=email_body, | ||
from_email=settings.EMAIL_HOST_USER, | ||
to=[ | ||
recipient, | ||
], | ||
) | ||
|
||
email.content_subtype = EMAIL_CONTENT_SUBTYPE | ||
email.send(fail_silently=False) |