Merge remote branch 'remotes/amusablelemur/feature374'

This commit is contained in:
Christopher Allan Webber 2011-07-09 08:58:22 -05:00
commit d41cc42a66
6 changed files with 27 additions and 8 deletions

View File

@ -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/

View File

@ -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,11 @@ def register(request):
"""
Your classic registration view!
"""
# Redirects to indexpage if registrations are disabled
if not mg_globals.app_config["allow_registration"]:
return redirect(request, "index")
register_form = auth_forms.RegistrationForm(request.POST)
if request.method == 'POST' and register_form.validate():
@ -98,7 +104,8 @@ 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):

View File

@ -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()
celery_imports = string_list()

View File

@ -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 %}

View File

@ -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 ;) #}

View File

@ -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):