Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
moved email authorization to allow registration emails
Browse files Browse the repository at this point in the history
  • Loading branch information
dtraviglia committed Nov 6, 2015
1 parent 23ab7ff commit 47b6fea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion developer/views.py
@@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from op_tasks.models import UserProfile, Product, Dataset, OpTask

# Create your views here.
Expand Down
38 changes: 21 additions & 17 deletions exp_portal/email.py
@@ -1,31 +1,35 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from op_tasks.models import UserProfile
from django.core import mail
from django.conf import settings
from tasks import user_authorized
from xdata.settings import LOGIN_URL

from django.contrib.auth.decorators import login_required


@login_required(login_url='/tasking/login')
def send_email(request):
print request
if request.method == 'POST':
email_to = request.POST.get('email_to', 'xdataonlineerrors@gmail.com')
subject = request.POST.get('email_subject', 'error')
message = request.POST.get('email_message', 'error')
print email_to, subject, message
status = mail.send_mail(subject, message, settings.EMAIL_HOST_USER, [email_to], fail_silently=False)
else:
status = 2

userprofiles = UserProfile.objects.all()
if status == 0:
statusMessage = "The email did not send. Try again."
elif status == 1:
statusMessage = "Email sent!"
elif status == 2:
statusMessage = ""
if user_authorized(request):
if request.method == 'POST':
email_to = request.POST.get('email_to', 'xdataonlineerrors@gmail.com')
subject = request.POST.get('email_subject', 'error')
message = request.POST.get('email_message', 'error')
print email_to, subject, message
status = mail.send_mail(subject, message, settings.EMAIL_HOST_USER, [email_to], fail_silently=False)
else:
status = 2
userprofiles = UserProfile.objects.all()
if status == 0:
statusMessage = "The email did not send. Try again."
elif status == 1:
statusMessage = "Email sent!"
elif status == 2:
statusMessage = ""
return render(request, 'email_form.html', {'userprofiles': userprofiles, 'status': status, 'statusMessage': statusMessage})
else:
return redirect(LOGIN_URL)


def printme(string):
Expand Down
2 changes: 1 addition & 1 deletion xdata/settings.py
Expand Up @@ -26,7 +26,7 @@

TEMPLATE_DEBUG = True

ADMINS = ADMIN_EMAILS
# ADMINS = ADMIN_EMAILS

ALLOWED_HOSTS = ['*']

Expand Down

0 comments on commit 47b6fea

Please sign in to comment.