Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
moved email authorization to allow registration emails
  • Loading branch information
dtraviglia committed Nov 6, 2015
1 parent 23ab7ff commit 47b6feaa8ae7d187c0642a832fef55dcf4945d23
Showing 3 changed files with 23 additions and 19 deletions.
@@ -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.
@@ -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):
@@ -26,7 +26,7 @@

TEMPLATE_DEBUG = True

ADMINS = ADMIN_EMAILS
# ADMINS = ADMIN_EMAILS

ALLOWED_HOSTS = ['*']

0 comments on commit 47b6fea

Please sign in to comment.