aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin.ini3
-rw-r--r--mediagoblin/auth/views.py28
-rw-r--r--mediagoblin/config_spec.ini5
-rw-r--r--mediagoblin/submit/routing.py5
-rw-r--r--mediagoblin/submit/views.py5
-rw-r--r--mediagoblin/templates/mediagoblin/auth/login.html4
-rw-r--r--mediagoblin/templates/mediagoblin/root.html10
-rw-r--r--mediagoblin/templates/mediagoblin/submit/success.html22
-rw-r--r--mediagoblin/views.py4
9 files changed, 39 insertions, 47 deletions
diff --git a/mediagoblin.ini b/mediagoblin.ini
index 596107dc..e889646a 100644
--- a/mediagoblin.ini
+++ b/mediagoblin.ini
@@ -8,6 +8,9 @@ email_sender_address = "notice@mediagoblin.example.org"
# set to false to enable sending notices
email_debug_mode = true
+# Set to false to disable registrations
+allow_registration = true
+
## Uncomment this to put some user-overriding templates here
#local_templates = %(here)s/user_dev/templates/
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
index 2450023f..7fe507b1 100644
--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -19,6 +19,7 @@ import uuid
from webob import exc
from mediagoblin import messages
+from mediagoblin import mg_globals
from mediagoblin.util import render_to_response, redirect
from mediagoblin.db.util import ObjectId
from mediagoblin.auth import lib as auth_lib
@@ -30,6 +31,14 @@ def register(request):
"""
Your classic registration view!
"""
+ # Redirects to indexpage if registrations are disabled
+ if not mg_globals.app_config["allow_registration"]:
+ messages.add_message(
+ request,
+ messages.WARNING,
+ ('Sorry, registration is disabled on this instance.'))
+ return redirect(request, "index")
+
register_form = auth_forms.RegistrationForm(request.POST)
if request.method == 'POST' and register_form.validate():
@@ -52,7 +61,7 @@ def register(request):
entry['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
request.POST['password'])
entry.save(validate=True)
-
+
send_verification_email(entry, request)
return redirect(request, "mediagoblin.auth.register_success")
@@ -98,13 +107,14 @@ def login(request):
'mediagoblin/auth/login.html',
{'login_form': login_form,
'next': request.GET.get('next') or request.POST.get('next'),
- 'login_failed': login_failed})
+ 'login_failed': login_failed,
+ 'allow_registration': mg_globals.app_config["allow_registration"]})
def logout(request):
# Maybe deleting the user_id parameter would be enough?
request.session.delete()
-
+
return redirect(request, "index")
@@ -128,16 +138,16 @@ def verify_email(request):
user.save()
verification_successful = True
messages.add_message(
- request,
- messages.SUCCESS,
+ request,
+ messages.SUCCESS,
('Your email address has been verified. '
'You may now login, edit your profile, and submit images!'))
else:
verification_successful = False
- messages.add_message(request,
- messages.ERROR,
- 'The verification key or user id is incorrect')
-
+ messages.add_message(request,
+ messages.ERROR,
+ 'The verification key or user id is incorrect')
+
return render_to_response(
request,
'mediagoblin/user_pages/user.html',
diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini
index aadf5c21..b6356b0e 100644
--- a/mediagoblin/config_spec.ini
+++ b/mediagoblin/config_spec.ini
@@ -21,6 +21,9 @@ direct_remote_path = string(default="/mgoblin_static/")
email_debug_mode = boolean(default=True)
email_sender_address = string(default="notice@mediagoblin.example.org")
+# Set to false to disable registrations
+allow_registration = boolean(default=True)
+
# By default not set, but you might want something like:
# "%(here)s/user_dev/templates/"
local_templates = string()
@@ -73,4 +76,4 @@ celeryd_eta_scheduler_precision = float()
# known lists
celery_routes = string_list()
-celery_imports = string_list() \ No newline at end of file
+celery_imports = string_list()
diff --git a/mediagoblin/submit/routing.py b/mediagoblin/submit/routing.py
index 3edbab70..5585ecb0 100644
--- a/mediagoblin/submit/routing.py
+++ b/mediagoblin/submit/routing.py
@@ -18,7 +18,4 @@ from routes.route import Route
submit_routes = [
Route('mediagoblin.submit.start', '/',
- controller='mediagoblin.submit.views:submit_start'),
- Route('mediagoblin.submit.success', '/success/',
- template='mediagoblin/submit/success.html',
- controller='mediagoblin.views:simple_template_render')]
+ controller='mediagoblin.submit.views:submit_start')]
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index 4c7476b0..1848f5e5 100644
--- a/mediagoblin/submit/views.py
+++ b/mediagoblin/submit/views.py
@@ -95,8 +95,3 @@ def submit_start(request):
request,
'mediagoblin/submit/start.html',
{'submit_form': submit_form})
-
-
-def submit_success(request):
- return render_to_response(
- request, 'mediagoblin/submit/success.html', {})
diff --git a/mediagoblin/templates/mediagoblin/auth/login.html b/mediagoblin/templates/mediagoblin/auth/login.html
index 2303ce5c..e25783ea 100644
--- a/mediagoblin/templates/mediagoblin/auth/login.html
+++ b/mediagoblin/templates/mediagoblin/auth/login.html
@@ -35,7 +35,9 @@
<input type="hidden" name="next" value="{{ next }}" class="button"
style="display: none;"/>
{% endif %}
- <p>Don't have an account yet?<br /><a href="{{ request.urlgen('mediagoblin.auth.register') }}">Create one here!</a></p>
+ {% if allow_registration %}
+ <p>Don't have an account yet?<br /><a href="{{ request.urlgen('mediagoblin.auth.register') }}">Create one here!</a></p>
+ {% endif %}
</div>
</form>
{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/root.html b/mediagoblin/templates/mediagoblin/root.html
index 5b744999..bae033c4 100644
--- a/mediagoblin/templates/mediagoblin/root.html
+++ b/mediagoblin/templates/mediagoblin/root.html
@@ -29,10 +29,12 @@
If you have an account, you can
<a href="{{ request.urlgen('mediagoblin.auth.login') }}">Login</a>.
</p>
- <p>
- If you don't have an account, please
- <a href="{{ request.urlgen('mediagoblin.auth.register') }}">Register</a>.
- </p>
+ {% if allow_registration %}
+ <p>
+ If you don't have an account, please
+ <a href="{{ request.urlgen('mediagoblin.auth.register') }}">Register</a>.
+ </p>
+ {% endif %}
{% endif %}
{# temporarily, an "image gallery" that isn't one really ;) #}
diff --git a/mediagoblin/templates/mediagoblin/submit/success.html b/mediagoblin/templates/mediagoblin/submit/success.html
deleted file mode 100644
index afc9f9d1..00000000
--- a/mediagoblin/templates/mediagoblin/submit/success.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{#
-# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 Free Software Foundation, Inc
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#}
-{% extends "mediagoblin/base.html" %}
-
-{% block mediagoblin_content %}
- Woohoo! Submitted!
-{% endblock %}
diff --git a/mediagoblin/views.py b/mediagoblin/views.py
index 5b6d9773..e7d9dbdd 100644
--- a/mediagoblin/views.py
+++ b/mediagoblin/views.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from mediagoblin import mg_globals
from mediagoblin.util import render_to_response
from mediagoblin.db.util import DESCENDING
@@ -23,7 +24,8 @@ def root_view(request):
return render_to_response(
request, 'mediagoblin/root.html',
- {'media_entries': media_entries})
+ {'media_entries': media_entries,
+ 'allow_registration': mg_globals.app_config["allow_registration"]})
def simple_template_render(request):