Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
304c9f55
Commit
304c9f55
authored
Nov 18, 2015
by
Daniel W Bond
Browse files
fixed the errors @nanyabusiness uncovered yesterday
parent
e36c9d61
Changes
2
Show whitespace changes
Inline
Side-by-side
roomlist/accounts/adapter.py
View file @
304c9f55
...
@@ -4,10 +4,13 @@ from datetime import datetime, timedelta
...
@@ -4,10 +4,13 @@ from datetime import datetime, timedelta
# core django imports
# core django imports
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.views.generic
import
FormView
from
django.views.generic
import
FormView
from
django.contrib
import
messages
from
django.http
import
HttpResponseRedirect
# third party imports
# third party imports
from
allauth.socialaccount.adapter
import
DefaultSocialAccountAdapter
from
allauth.socialaccount.adapter
import
DefaultSocialAccountAdapter
from
allauth.socialaccount.views
import
ConnectionsView
from
allauth.socialaccount.views
import
ConnectionsView
from
allauth.socialaccount.forms
import
DisconnectForm
from
allauth.socialaccount.forms
import
DisconnectForm
from
allauth.exceptions
import
ImmediateHttpResponse
from
braces.views
import
LoginRequiredMixin
from
braces.views
import
LoginRequiredMixin
class
AccountAdapter
(
DefaultSocialAccountAdapter
):
class
AccountAdapter
(
DefaultSocialAccountAdapter
):
...
@@ -40,6 +43,26 @@ class AccountAdapter(DefaultSocialAccountAdapter):
...
@@ -40,6 +43,26 @@ class AccountAdapter(DefaultSocialAccountAdapter):
'slug'
:
request
.
user
.
username
,
'slug'
:
request
.
user
.
username
,
})
})
def
authentication_error
(
self
,
request
,
provider_id
,
error
=
None
,
exception
=
None
,
extra_context
=
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 roomlist@lists.srct.gmu.edu."""
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
)
else
:
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
):
class
RemoveSocialConfirmationView
(
LoginRequiredMixin
,
ConnectionsView
):
template_name
=
"remove_social.html"
template_name
=
"remove_social.html"
...
@@ -48,8 +71,8 @@ class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView):
...
@@ -48,8 +71,8 @@ class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
user
.
socialaccount_set
.
all
():
if
not
request
.
user
.
socialaccount_set
.
all
():
# no social media accounts? back to the settings page with you!
# no social media accounts? back to the settings page with you!
return
reverse
(
'updateStudent'
,
return
HttpResponseRedirect
(
reverse
(
'updateStudent'
,
kwargs
=
{
'slug'
:
self
.
request
.
user
.
username
})
kwargs
=
{
'slug'
:
self
.
request
.
user
.
username
})
)
else
:
else
:
return
super
(
RemoveSocialConfirmationView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
return
super
(
RemoveSocialConfirmationView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
...
...
roomlist/settings/settings.py
View file @
304c9f55
...
@@ -106,6 +106,10 @@ MIDDLEWARE_CLASSES = (
...
@@ -106,6 +106,10 @@ MIDDLEWARE_CLASSES = (
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
)
)
# for bootstrap css classes
from
django.contrib.messages
import
constants
as
messages
MESSAGE_TAGS
=
{
messages
.
ERROR
:
'danger'
,}
ROOT_URLCONF
=
'settings.urls'
ROOT_URLCONF
=
'settings.urls'
WSGI_APPLICATION
=
'settings.wsgi.application'
WSGI_APPLICATION
=
'settings.wsgi.application'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment