From 0ce121800f167ebad0246a5b4ff409048411073d Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Mon, 2 Mar 2020 12:58:21 +0530 Subject: fixed condtion issues --- arduino_blog/decorators.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'arduino_blog') diff --git a/arduino_blog/decorators.py b/arduino_blog/decorators.py index 6c185d5..c1985d2 100644 --- a/arduino_blog/decorators.py +++ b/arduino_blog/decorators.py @@ -43,23 +43,28 @@ def is_proposal_submitted(func): request, 'activation-status.html', context ) else: - _q = Proposal.objects - is_sub = _q.get(Q(user_id=user.id)&Q(proposal_status='0')) - if is_sub.proposal_status == 0: - context['success'] = True - context['msg'] = "You have alredy submited a \ + try: + _q = Proposal.objects + is_sub = _q.get(Q(user_id=user.id)&Q(proposal_status='0')) + if is_sub.proposal_status == 0: + context['success'] = True + context['msg'] = "You have alredy submited a \ proposal. Your proposal is under \ review" - return render( - request, 'dashboard.html', context - ) - else: - context['success'] = False - context['msg'] = "You can submit a new \ - proposal" - return render( - request, 'dashboard.html', context - ) + return render( + request, 'dashboard.html', context + ) + else: + context['success'] = False + context['msg'] = "You can submit a new \ + proposal" + return render( + request, 'dashboard.html', context + ) + except Proposal.DoesNotExist: + is_sub = None + print("-----------", is_sub) + return func(request, *args, **kwargs) except Exception as e: print (e) -- cgit From 74c85d5bb0e2e4f2db543a478d1b7bd5e57c0d50 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Mon, 2 Mar 2020 13:01:32 +0530 Subject: updated email function --- arduino_blog/views.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'arduino_blog') diff --git a/arduino_blog/views.py b/arduino_blog/views.py index 6cad284..c16cf9f 100644 --- a/arduino_blog/views.py +++ b/arduino_blog/views.py @@ -1,5 +1,6 @@ from django.http import HttpResponse from django.shortcuts import render, redirect, get_object_or_404 +from django.template.loader import render_to_string from django.template import loader from django.template import RequestContext from django.contrib.auth.forms import UserCreationForm @@ -205,9 +206,16 @@ def submitabstract(request): context['proposal_submit'] = True context['display_message'] = """Thank you for your submission! """ #mail function - #message = render_to_string('email/propodal_received.html', context) - #send_email(sender_email, to, subject, message, bcc_email) - return render_to_response('index.html', context) + context['name'] = social_user.first_name + ' ' + social_user.last_name + subject = ["test mail"] + message = render_to_string('email/proposal_received.html',\ + context) + print(message) + sender_email = [SENDER_EMAIL] + to = [social_user.email] + bcc_email = [BCC_EMAIL_ID] + send_email(sender_email, to, subject, message, bcc_email) + return my_render_to_response('index.html', context) else: print(form.errors) context['proposal_form'] = form @@ -219,7 +227,7 @@ def submitabstract(request): return render(request, 'submit-cfp.html', {'proposal_form': form}) else: context['login_required'] = True - return render_to_response('login.html', context) + return my_render_to_response('login.html', context) def send_email(sender_email, to, subject, message, bcc_email=None): @@ -232,5 +240,6 @@ def send_email(sender_email, to, subject, message, bcc_email=None): email.attach_alternative(message, "text/html") email.content_subtype = 'html' # Main content is text/html email.mixed_subtype = 'related' + print("mail sent") email.send(fail_silently=True) -- cgit From 3198b009bf9eb606200e2bdd03e8c48c169619e4 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Mon, 2 Mar 2020 13:03:59 +0530 Subject: added email template --- arduino_blog/templates/email/proposal_received.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 arduino_blog/templates/email/proposal_received.html (limited to 'arduino_blog') diff --git a/arduino_blog/templates/email/proposal_received.html b/arduino_blog/templates/email/proposal_received.html new file mode 100644 index 0000000..a1eb46b --- /dev/null +++ b/arduino_blog/templates/email/proposal_received.html @@ -0,0 +1,13 @@ + + +

Dear {{ name }},

+


Thank you for your submission! . We have received your proposal for the Open Source Hardware Project with the following details:

+

Your proposal is under review. You will receive an email as soon as it has been reviewed. 

+

 

+

Best Wishes,

+

Open Source Hardware Project Team,

+

FOSSEE, IIT Bombay

+

 

+
*** This is an automatically generated email, please do not reply***
+ + -- cgit