diff --git a/subscribers/urls.py b/subscribers/urls.py index 8d16b13..cf4eac3 100644 --- a/subscribers/urls.py +++ b/subscribers/urls.py @@ -2,8 +2,8 @@ from subscribers import views urlpatterns = [ - re_path(r'^signup$', views.sign_up, name='sign up'), - re_path(r'^subscribe/(?P[\w{}.-]{20})$', views.subscribe, name='subscribe'), + # re_path(r'^signup$', views.sign_up, name='sign up'), + # re_path(r'^subscribe/(?P[\w{}.-]{20})$', views.subscribe, name='subscribe'), re_path(r'^unsubscribe/(?P[\w{}.-]{20})$', views.unsubscribe, name='unsubscribe'), - re_path(r'^notifysubscribers', views.notify_subscribers, name='notify subscribers'), + # re_path(r'^notifysubscribers', views.notify_subscribers, name='notify subscribers'), ] \ No newline at end of file diff --git a/subscribers/views.py b/subscribers/views.py index c4341c6..45ef9df 100644 --- a/subscribers/views.py +++ b/subscribers/views.py @@ -8,68 +8,68 @@ from scotuswebcites.mail import send_email -def sign_up(request): - if request.method == 'POST': - new_subscriber = False - - # App email not configured yet - if settings.EMAIL_HOST_USER == 'YOUR_GMAIL_ADDRESS': - flash_type = messages.WARNING - flash_message = 'It looks like the host is not configured to send emails quite yet' - else: - proceed = True - valid_email = True - email = request.POST.get('email', '') - - # Already subscribed - if Subscriber.objects.filter(email=email): - subscriber = Subscriber.objects.get(email=email) - if subscriber.subscribed: - proceed = False - flash_type = messages.SUCCESS - flash_message = 'Good news, it looks like you are already subscribed!' - else: - try: - # Create database record - subscriber = Subscriber(email=email) - subscriber._set_hash() - subscriber.save() - new_subscriber = True - except: - valid_email = False - - if valid_email and proceed: - try: - # Success! - _send_confirmation_email(request, subscriber) - flash_type = messages.SUCCESS - flash_message = "Thanks for subscribing! We've sent a confirmation email to %s." % email - except: - valid_email = False - if new_subscriber: - subscriber.delete() - - # Bad email provided - if not valid_email: - flash_type = messages.WARNING - flash_message = 'It looks like you submitted an invalid email address' - messages.add_message(request, flash_type, flash_message) - - return HttpResponseRedirect(request.META.get('HTTP_REFERER')) - - -def subscribe(request, hash_key): - subscriber = Subscriber.objects.get(hash_key=hash_key) - if subscriber and not subscriber.subscribed: - subscriber.subscribed = True - subscriber.save() - _notify_admin_of_new_subscriber(subscriber.email) - messages.add_message( - request, - messages.SUCCESS, - 'Thanks for confirming your subscription!' - ) - return HttpResponseRedirect('/') +# def sign_up(request): +# if request.method == 'POST': +# new_subscriber = False +# +# # App email not configured yet +# if settings.EMAIL_HOST_USER == 'YOUR_GMAIL_ADDRESS': +# flash_type = messages.WARNING +# flash_message = 'It looks like the host is not configured to send emails quite yet' +# else: +# proceed = True +# valid_email = True +# email = request.POST.get('email', '') +# +# # Already subscribed +# if Subscriber.objects.filter(email=email): +# subscriber = Subscriber.objects.get(email=email) +# if subscriber.subscribed: +# proceed = False +# flash_type = messages.SUCCESS +# flash_message = 'Good news, it looks like you are already subscribed!' +# else: +# try: +# # Create database record +# subscriber = Subscriber(email=email) +# subscriber._set_hash() +# subscriber.save() +# new_subscriber = True +# except: +# valid_email = False +# +# if valid_email and proceed: +# try: +# # Success! +# _send_confirmation_email(request, subscriber) +# flash_type = messages.SUCCESS +# flash_message = "Thanks for subscribing! We've sent a confirmation email to %s." % email +# except: +# valid_email = False +# if new_subscriber: +# subscriber.delete() +# +# # Bad email provided +# if not valid_email: +# flash_type = messages.WARNING +# flash_message = 'It looks like you submitted an invalid email address' +# messages.add_message(request, flash_type, flash_message) +# +# return HttpResponseRedirect(request.META.get('HTTP_REFERER')) + + +# def subscribe(request, hash_key): +# subscriber = Subscriber.objects.get(hash_key=hash_key) +# if subscriber and not subscriber.subscribed: +# subscriber.subscribed = True +# subscriber.save() +# _notify_admin_of_new_subscriber(subscriber.email) +# messages.add_message( +# request, +# messages.SUCCESS, +# 'Thanks for confirming your subscription!' +# ) +# return HttpResponseRedirect('/') def unsubscribe(request, hash_key): @@ -85,10 +85,10 @@ def unsubscribe(request, hash_key): return HttpResponseRedirect('/') -@login_required() -def notify_subscribers(request): - call_command('notifysubscribers') - return HttpResponseRedirect('/citations/') +# @login_required() +# def notify_subscribers(request): +# call_command('notifysubscribers') +# return HttpResponseRedirect('/citations/') def _send_confirmation_email(request, subscriber): diff --git a/templates/overview.html b/templates/overview.html index b912ca5..d5b5042 100644 --- a/templates/overview.html +++ b/templates/overview.html @@ -112,17 +112,17 @@

How does this work?

This site was developed by Phil Ardery and is hosted by UC Berkeley Law Library.

-

Subscribe

- + + + + + + + + + + +