Commit 304c9f55 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

fixed the errors @nanyabusiness uncovered yesterday

parent e36c9d61
......@@ -4,10 +4,13 @@ from datetime import datetime, timedelta
# core django imports
from django.core.urlresolvers import reverse
from django.views.generic import FormView
from django.contrib import messages
from django.http import HttpResponseRedirect
# third party imports
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from allauth.socialaccount.views import ConnectionsView
from allauth.socialaccount.forms import DisconnectForm
from allauth.exceptions import ImmediateHttpResponse
from braces.views import LoginRequiredMixin
class AccountAdapter(DefaultSocialAccountAdapter):
......@@ -40,6 +43,26 @@ class AccountAdapter(DefaultSocialAccountAdapter):
'slug': request.user.username,
def authentication_error(self, request, provider_id, error=None, exception=None,
error_message = """Looks like something went awry with your social
authentication. Wait a moment and try your username and
password again. If things are still broken, let us know by
sending an email to"""
if not request.user.student.completedSocial:
messages.add_message(request, messages.ERROR, error_message)
social_redirect = HttpResponseRedirect(reverse('welcomeSocial', kwargs={
'slug': request.user.username,
raise ImmediateHttpResponse(social_redirect)
messages.add_message(request, messages.ERROR, error_message)
update_redirect = HttpResponseRedirect(reverse('updateStudent', kwargs={
'slug': request.user.username,
raise ImmediateHttpResponse(update_redirect)
class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView):
template_name = "remove_social.html"
......@@ -48,8 +71,8 @@ class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView):
def get(self, request, *args, **kwargs):
if not request.user.socialaccount_set.all():
# no social media accounts? back to the settings page with you!
return reverse('updateStudent',
return HttpResponseRedirect(reverse('updateStudent',
return super(RemoveSocialConfirmationView, self).get(request, *args, **kwargs)
......@@ -106,6 +106,10 @@ MIDDLEWARE_CLASSES = (
# for bootstrap css classes
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {messages.ERROR: 'danger',}
ROOT_URLCONF = 'settings.urls'
WSGI_APPLICATION = 'settings.wsgi.application'
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