-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
147 lines (125 loc) · 2.62 KB
/
utils.py
File metadata and controls
147 lines (125 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# utils.py
import os
import dotenv
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
def send_verification_mail(emailid: str, verify_url: str) -> None:
""" Used to send verification mail """
dotenv.load_dotenv(".env")
email = os.environ.get("KAKE_EMAILID")
message = Mail(
from_email=email,
to_emails=emailid,
subject='Kake app verification',
html_content=HTML.replace("#something", verify_url))
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
except Exception as e:
print(e)
def send_checkout_token(emailid: str, token: str) -> None:
""" Send checkout token to email id """
dotenv.load_dotenv(".env")
email = os.environ.get("KAKE_EMAILID")
message = Mail(
from_email=email,
to_emails=emailid,
subject='Kake app checkout token',
html_content=CHECKOUT_HTML.replace("#token", token))
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
except Exception as e:
print(e)
print("sent token", token)
CHECKOUT_HTML = """
<html>
<style>
* {
padding: 10px;
margin: 0;
background-color: aqua;
}
.center {
text-align: center;
}
.token {
background-color: gray;
color: gray;
transition: 1s;
}
.token:hover {
color: white;
}
div {
padding: 20px;
}
div h3 {
padding: 10px;
background-color: chocolate;
}
button {
padding: 10px;
border: 0;
color: white;
margin: 5px;
background-color: #555;
}
button:hover {
background-color: #111;
}
div p {
padding: 10px;
}
</style>
<body>
<div>
<h3 class="center">Checkout token</h3>
This is the token used for checking out of the cart. Please ensure that it is not shared with anyone.
<div class="token center">#token</div>
</div>
</body>
</html>
"""
HTML = """
<html>
<style>
* {
padding: 0;
margin: 0;
background-color: aqua;
}
.center {
text-align: center;
}
div {
padding: 20px;
}
div h3{
padding: 10px;
background-color: chocolate;
}
button {
padding: 10px;
border: 0;
color: white;
margin: 5px;
background-color: #555;
}
button:hover {
background-color: #111;
}
div p {
padding: 10px;
}
</style>
<body>
<div class='center'>
<h3>Verification Email</h3>
<p>Your profile registration will be done as soon as you click on verify below.</p>
<a href="#something"><button>Verify!</button></a>
<p>If you did not make this registration, please change your email access and take necessary precautions.</p>
</div>
</body>
</html>
"""