How to use get_html_message method in Slash

Best Python code snippet using slash

emails.py

Source:emails.py Github

copy

Full Screen

1from django.core.mail import send_mail2from conf.constants import DEFAULT_FROM_EMAIL3def get_html_message(body):4 html_message = """5 <!DOCTYPE html>6 <html>7 <head>8 <style>9 .jumbotron {{10 padding: 2rem 1rem;11 margin-bottom: 2rem;12 background-color: #e9ecef;13 border-radius: .3rem;14 }}15 </style>16 </head>17 <body>18 {0}19 </body>20 </html>21 """.format(body)22 return html_message23class VerifyEmail:24 def __init__(self, request, token, user):25 self.request = request26 self.token = token27 self.user = user28 self.uri = self.get_uri()29 def get_uri(self):30 return '{0}?token={1}&email={2}'.format(self.request.build_absolute_uri(), self.token.name, self.user.email)31 def get_html_message(self):32 body = """33 <div class="jumbotron">34 <h1 class="display-4">이메일 인증요청입니다.</h1>35 <hr class="my-4">36 <p>{0}님 turnthepage 이메일 인증요청입니다. 아래 버튼을 클릭해서 인증해주세요:)</p>37 <a class="btn btn-primary btn-lg" href="{1}" role="button">인증하기</a>38 </div>39 """.format(self.user.username, self.uri)40 return get_html_message(body)41 def send_email(self):42 subject = '[turnthepage] 이메일 인증요청입니다.'43 html_message = self.get_html_message()44 send_mail(subject=subject, message=None, from_email=DEFAULT_FROM_EMAIL, recipient_list=[self.user.email],45 html_message=html_message)46class WinAPrizeEmail:47 def __init__(self, request, form, user, book):48 self.request = request49 self.form = form50 self.user = user51 self.book = book52 def get_html_message(self):53 body = """54 <div class="jumbotron">55 <h1 class="display-4">미션 성공 알람입니다.</h1>56 <hr class="my-4">57 <p>{0}님 turnthepage 미션을 성공했습니다. 축하드립니다. 아래 QR코드를 촬영하면 스타벅스 무료 쿠폰이 발급됩니다.</p>58 <img src="{1}/static/images/QR.png">59 </div>60 """.format(self.user.username, self.request.META['HTTP_HOST'])61 return get_html_message(body)62 def send_mail(self):63 if self.book.page_number != self.form.cleaned_data['total_number']:64 return65 subject = '[turnthepage] 미션 성공 알람입니다.'66 html_message = self.get_html_message()67 send_mail(subject=subject, message=None, from_email=DEFAULT_FROM_EMAIL, recipient_list=[self.user.email],...

Full Screen

Full Screen

serializers.py

Source:serializers.py Github

copy

Full Screen

...13 fields = '__all__'14class OrderSerializer(serializers.ModelSerializer):15 # html_message = serializers.SerializerMethodField()16 email_is_sent = serializers.SerializerMethodField()17 # def get_html_message(self):18 # return self.html_message()19 def get_email_is_sent(self, obj):20 return obj.email is not None21 class Meta:22 model = Order23 fields = ["id", "status", "date", "destination", "edited_at", "date_finished", "number", "finished", "count",24 "cartridge", "take_old_away", "supply", "email", "email_is_sent", "html_message"]25class ServiceSerializer(serializers.ModelSerializer):26 email_is_sent = serializers.SerializerMethodField()27 # def get_html_message(self):28 # return self.html_message()29 def get_email_is_sent(self, obj):30 return obj.email is not None31 class Meta:32 model = Service33 fields = ["id", "status", "date", "destination", "edited_at", "date_finished", "number", "finished",34 "printer", "inv_number", "email", "email_is_sent", "defect_description", "html_message"]35class MailSerializer(serializers.ModelSerializer):36 # decoded_body = serializers.SerializerMethodField()37 class Meta:38 model = Message39 fields = ['id', 'subject', 'message_id', 'from_header', 'to_header', 'outgoing', 'processed', 'read', 'mailbox',40 'in_reply_to', 'text', 'html']41 # def get_decoded_body(self, obj):...

Full Screen

Full Screen

email.py

Source:email.py Github

copy

Full Screen

...23 Thank you, {data["name"]} for contatcting us. We will get in touch with you as soon as possible.24 Please check your phone number 📞(+1{data["phone"]}) and email 📧({data["email"]}) again.25 '''26 return message_to_client, message_to_websiteholder27def get_html_message(data):28 return render_to_string('email.html', data)29def send_appoitment_registration(data):30 31 client_text, wh_text = get_text_messages(data)32 client_sub, wh_sub = get_subjects(data)33 client_html_msg = get_html_message(data)34 35 client_msg = EmailMultiAlternatives(client_sub, client_text, settings.EMAIL_HOST_USER, [data['email']])36 wh_msg = EmailMultiAlternatives(wh_sub, wh_text, settings.EMAIL_HOST_USER, [settings.WEBSITEHOLDEREMAIL])37 38 client_msg.attach_alternative(client_html_msg, "text/html")39 try:40 client_msg.send(fail_silently=False)41 wh_msg.send(fail_silently=False)42 except Exception:43 return False44 else:45 return True...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful