Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add warning if e-mail fails (instead of HTTP 500)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Aug 24, 2016
1 parent 3f369b5 commit 203cc9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions sites/views.py
Expand Up @@ -119,10 +119,15 @@ def add(request):
site.save()
context['site'] = site

send_mail("Nikola Users addition request for {0}".format(site.url),
'{0} <{1}> has requested addition of "{2}" <{3}> to the Nikola Users site.\nPlease visit the admin panel to accept or reject it: https://users.getnikola.com/admin/'.format(
site.author, site.email, site.title, site.url),
'nikola-users@chriswarrick.com', ['users@getnikola.com'], fail_silently=False)
try:
send_mail(
"Nikola Users addition request for {0}".format(site.url),
'{0} <{1}> has requested addition of "{2}" <{3}> to the Nikola Users site.\nPlease visit the admin panel to accept or reject it: https://users.getnikola.com/admin/'.format(
site.author, site.email, site.title, site.url),
'nikola-users@chriswarrick.com', ['users@getnikola.com'], fail_silently=False)
context['email_succeeded'] = True
except Exception:
context['email_succeeded'] = False

return render(request, 'add-ack.html', context)
else:
Expand Down
5 changes: 4 additions & 1 deletion templates/add-ack.html
@@ -1,8 +1,11 @@
{% extends "base.html" %}
{% block content %}
<p class="text-success lead">Request sent!</p>

{% if email_succeeded %}
<p>Administrators were informed of your request. Your site will be added within 48 hours.</p>
{% else %}
<p class="text-warning">WARNING: Administrators were not informed of your request because sending e-mail failed. Please report this to <a href="https://getnikola.com/contact.html">the Nikola team</a> (preferably on Twitter, or personally to Chris through e-mail)</p>
{% endif %}

<p>The administrators reserve the right to alter the information, or reject your site altogether.</p>

Expand Down

0 comments on commit 203cc9c

Please sign in to comment.