From d4a783b60745a158719ccad06aed7d0ddccc24b3 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Thu, 4 Mar 2021 17:45:29 +0100 Subject: [PATCH] Added settings to close registrations --- accounts/views.py | 8 ++++++-- interludes/settings.py | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index 1abacb6..db899e4 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,6 +1,8 @@ -from django.shortcuts import render, redirect +from django.conf import settings from django.contrib.auth import authenticate, login, logout from django.contrib.auth.decorators import login_required +from django.http import Http404 +from django.shortcuts import render, redirect from accounts.forms import CreateAccountForm @@ -12,6 +14,8 @@ def logout_view(request): def create_account(request): """Vue pour l'inscription""" + if not settings.REGISTRATION_USER_CREATION_OPEN: + raise Http404("La création de compte n'est pas ouverte actuellement") if request.method == 'POST': form = CreateAccountForm(request.POST) if form.is_valid(): @@ -29,4 +33,4 @@ def create_account(request): return redirect('home') else: form = CreateAccountForm() - return render(request, 'create_account.html', {'form': form}) + return render(request, 'registration/create_account.html', {'form': form}) diff --git a/interludes/settings.py b/interludes/settings.py index e82bcad..81b4e78 100644 --- a/interludes/settings.py +++ b/interludes/settings.py @@ -129,3 +129,8 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') LOGIN_REDIRECT_URL = 'home' + +# Blocks account creation when false +REGISTRATION_USER_CREATION_OPEN = True +# Blocks event inscription +REGISTRATION_EVENT_INSCRIPTIONS_OPEN = True -- GitLab