Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
25b723e9
Commit
25b723e9
authored
Aug 27, 2014
by
Chris Reffett
Browse files
Send emails to notify about registration requests instead of writing to a file
parent
b89ba15b
Changes
5
Hide whitespace changes
Inline
Side-by-side
go/go/templates/registered.html
0 → 100644
View file @
25b723e9
{% 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 %}
go/go/views.py
View file @
25b723e9
...
...
@@ -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
\n
Message: %s
\n
Please 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'
,
{
},
)
go/settings/secret.py.template
View file @
25b723e9
...
...
@@ -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 = ""
go/settings/settings.py.template
View file @
25b723e9
...
...
@@ -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"
go/settings/urls.py
View file @
25b723e9
...
...
@@ -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
)),
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment