Commit 25b723e9 authored by Chris Reffett's avatar Chris Reffett

Send emails to notify about registration requests instead of writing to a file

parent b89ba15b
{% extends 'base.html' %}
{% block title %}
Go - Registration Email Sent
{% endblock %}
{% block content %}
<p>
Your registration request has been sent! Please be patient, our
administrators will handle it as soon as they can.
</p>
{% endblock %}
......@@ -6,6 +6,7 @@ from django.http import Http404, HttpResponseServerError
from django.utils import timezone
from django.contrib.auth.models import User
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, get_object_or_404, redirect
import os
......@@ -183,8 +184,6 @@ def signup(request):
This view presents the user with a registration form. You can register
yourself, or another person.
TODO: Add email notification to sysadmin that a new registration has
occurred.
"""
form = SignupForm()
......@@ -197,23 +196,13 @@ def signup(request):
description = form.cleaned_data.get('description')
"""
This code simply writes out to a file the registration.
Ideally, we will be sending an administrator an email instead.
But we need an email account to do that.
"""
f = open(os.path.join(settings.MEDIA_ROOT, 'registrations.txt'), 'a')
f.write( str(timezone.now()) )
f.write( str('\n') )
f.write( str(username) )
f.write( str('\n') )
f.write( str(full_name) )
f.write( str('\n') )
f.write( str(description) )
f.write( str('\n\n\n') )
f.close()
return redirect('index')
send_mail('Signup from %s' % (username), '%s signed up at %s\n'
'Username: %s\nMessage: %s\nPlease attend to this request at '
'your earliest convenience.' % (str(full_name),
str(timezone.now()).strip(), str(username), str(description)),
settings.EMAIL_FROM, [settings.EMAIL_TO])
return redirect('registered')
return render(request, 'signup.html', {
'form': form,
......@@ -255,3 +244,7 @@ def about(request):
},
)
def registered(request):
return render(request, 'registered.html', {
},
)
......@@ -7,3 +7,11 @@ DB_HOST = ""
PIWIK_SITE_ID = ""
PIWIK_URL = ""
# Do not include a final slash!
SERVERURL = ""
EMAIL_HOST = ""
EMAIL_PORT = ""
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
......@@ -147,3 +147,14 @@ AUTH_LDAP_ALWAYS_UPDATE_USER = True
PIWIK_SITE_ID = secret.PIWIK_SITE_ID
PIWIK_URL = secret.PIWIK_URL
SERVERURL = secret.SERVERURL
# Mail settings
EMAIL_HOST = secret.EMAIL_HOST
EMAIL_PORT = secret.EMAIL_PORT
EMAIL_HOST_USER = secret.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
EMAIL_FROM = "example@example.com"
EMAIL_TO = "to@example.com"
......@@ -26,6 +26,9 @@ urlpatterns = patterns('go.views',
# /delete/<short> - Delete a link, no content display.
url(r'^delete/(?P<short>\w+)$', 'delete', name = 'delete'),
# /registered - registration complete page
url(r'^registered/?$', 'registered', name = 'registered'),
# /admin - Administrator interface.
url(r'^admin/?', include(admin.site.urls)),
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment