Commit 8694484b authored by Jason D Yeomans's avatar Jason D Yeomans

changed allauth redirect, added ability to redirect new users to a welcome...

changed allauth redirect, added ability to redirect new users to a welcome page (page does not exist yet)
parent 32fede3e
from allauth.account.adapter import DefaultAccountAdapter
from django.conf import settings
from django.shortcuts import resolve_url
from datetime import datetime, timedelta
class AccountAdapter(DefaultAccountAdapter):
def get_login_redirect_url(self, request):
threshold = 90 #seconds
assert request.user.is_authenticated()
if (request.user.last_login - request.user.date_joined).seconds < threshold:
url = '/accounts/student/'
else:
url = '/accounts/student/'
return resolve_url(url)
......@@ -17,12 +17,12 @@ class CreateStudent(LoginRequiredMixin, CreateView):
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
login_url = '/accounts/login/'
# changeable student settings
class DetailStudentSettings(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
login_url = '/accounts/login/'
class DetailCurrentStudent(LoginRequiredMixin, DetailView):
......
......@@ -125,6 +125,8 @@ USE_TZ = True
SITE_ID = 2
ACCOUNT_ADAPTER = 'accounts.adapter.AccountAdapter'
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
......
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