diff options
-rw-r--r-- | arduino_blog/decorators.py | 35 | ||||
-rw-r--r-- | arduino_blog/templates/email/proposal_received.html | 13 | ||||
-rw-r--r-- | arduino_blog/views.py | 17 |
3 files changed, 46 insertions, 19 deletions
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) 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 @@ +<html> +<body> +<p><span style="font-weight: 400;">Dear {{ name }},</span></p> +<p><span style="font-weight: 400;"><br /></span><span style="font-weight: 400;">Thank you for your submission! . We have received your proposal for the Open Source Hardware Project with the following details:</span></p> +<p><span style="font-weight: 400;">Your proposal is under review. You will receive an email as soon as it has been reviewed. </span></p> +<p> </p> +<p><span style="font-weight: 400;">Best Wishes,</span></p> +<p><span style="font-weight: 400;">Open Source Hardware Project Team,</span></p> +<p><span style="font-weight: 400;">FOSSEE, IIT Bombay</span></p> +<p> </p> +<h6 style="text-align: center;">*** This is an automatically generated email, please do not reply***</h6> +</body> +</html> 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) |