Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
roomlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
roomlist
Commits
abc8d18b
Commit
abc8d18b
authored
Nov 16, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completely rewrote account adapter, created page to remove social media connections
parent
c2a08a84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
9 deletions
+129
-9
roomlist/accounts/adapter.py
roomlist/accounts/adapter.py
+50
-9
roomlist/accounts/templates/remove_social.html
roomlist/accounts/templates/remove_social.html
+74
-0
roomlist/accounts/urls.py
roomlist/accounts/urls.py
+5
-0
No files found.
roomlist/accounts/adapter.py
View file @
abc8d18b
...
...
@@ -2,19 +2,60 @@
from
__future__
import
absolute_import
,
print_function
from
datetime
import
datetime
,
timedelta
# core django imports
from
django.shortcuts
import
resolve_url
from
django.core.urlresolvers
import
reverse
from
django.views.generic
import
FormView
# third party imports
from
allauth.account.adapter
import
DefaultAccountAdapter
from
allauth.socialaccount.adapter
import
DefaultSocialAccountAdapter
from
allauth.socialaccount.views
import
ConnectionsView
from
allauth.socialaccount.forms
import
DisconnectForm
from
braces.views
import
LoginRequiredMixin
class
AccountAdapter
(
DefaultSocialAccountAdapter
):
class
AccountAdapter
(
DefaultAccountAdapter
):
# the request processed by the adapter is one from the successful oauth callback
def
get_login_redirect_url
(
self
,
request
):
threshold
=
90
# seconds
#def pre_social_login(self, request, sociallogin
):
#print(request.get_full_path(), 'pre_login')
def
populate_user
(
self
,
request
,
sociallogin
,
data
):
# we don't actually want to overwrite anything from the
# social media account user
user
=
sociallogin
.
user
return
user
def
get_connect_redirect_url
(
self
,
request
,
socialaccount
):
# where the user is sent if the social account is indeed authenticated
assert
request
.
user
.
is_authenticated
()
if
((
request
.
user
.
last_login
-
request
.
user
.
date_joined
).
seconds
<
threshold
):
url
=
'/accounts/student/'
#print(request.get_full_path())
#if 'welcome' in request.get_full_path():
# ergo, we go with more of an approximation (at least for now)
if
not
request
.
user
.
student
.
completedSocial
:
return
reverse
(
'welcomeSocial'
,
kwargs
=
{
'slug'
:
request
.
user
.
username
,
})
else
:
url
=
'/accounts/student/'
return
resolve_url
(
url
)
return
reverse
(
'updateStudent'
,
kwargs
=
{
'slug'
:
request
.
user
.
username
,
})
class
RemoveSocialConfirmationView
(
LoginRequiredMixin
,
ConnectionsView
):
template_name
=
"remove_social.html"
login_url
=
'login'
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'
,
kwargs
=
{
'slug'
:
self
.
request
.
user
.
username
})
else
:
return
super
(
RemoveSocialConfirmationView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
def
form_valid
(
self
,
form
):
return
super
(
RemoveSocialConfirmationView
,
self
).
form_valid
(
form
)
def
get_success_url
(
self
):
return
reverse
(
'updateStudent'
,
kwargs
=
{
'slug'
:
self
.
request
.
user
.
username
})
roomlist/accounts/templates/remove_social.html
0 → 100644
View file @
abc8d18b
{% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Remove Social Accounts {% endblock %}
{% block message_queue %}
{% endblock %}
{% block content %}
<div
class=
"page-header"
id=
"banner"
>
<div
class=
"row"
>
<div
class=
"col-md-12 text-center"
>
<h1><strong>
SRCT
</strong>
​
ROOMLIST
</h1>
<p
class=
"lead text-center"
>
Remove My Social Media Accounts
</p>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-8 col-md-offset-2"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h1
class=
"panel-title text-center"
><strong>
Connected Social Media Accounts
</strong></h1>
</div>
<div
class=
"panel-body"
>
<form
class=
"form-horizontal text-center"
method=
"post"
action=
""
>
{% csrf_token %}
<fieldset>
{% if form.non_field_errors %}
<div
id=
"errorMsg"
>
{{ form.non_field_errors }}
</div>
{% endif %}
{% for base_account in form.accounts %}
{% with base_account.get_provider_account as account %}
<div>
<p><label
for=
"id_account_{{ base_account.id }}"
style=
"font-size:20px"
>
<input
id=
"id_account_{{ base_account.id }}"
type=
"radio"
name=
"account"
value=
"{{ base_account.id }}"
/>
<span
class=
"socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}"
>
<i
class=
"fa fa-{{base_account.provider}} fa-lg fa-fw"
></i>
{{account.get_brand.name}}
</span>
<small><em>
{{ account }}
</em></small>
</label></p>
</div>
{% endwith %}
{% endfor %}
<div>
<input
type=
"submit"
value=
"Remove"
class=
"btn btn-danger"
/>
<input
type=
"cancel"
value=
"Never Mind"
class=
"btn btn-default"
onclick=
"history.back()"
/>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-8 col-md-offset-2 text-center"
>
<div
class=
"alert alert-danger"
role=
"alert"
>
<p><i
class=
"fa fa-exclamation-circle fa-fw fa-lg"
></i>
While this form will
immediately delete your account from our database, it may still exist for
a time on the related social media account's database. Check that social media
profile's authorized apps page for more information.
</p>
</div>
</div>
</div>
{% endblock %}
roomlist/accounts/urls.py
View file @
abc8d18b
...
...
@@ -8,6 +8,7 @@ from .views import (DetailStudent, UpdateStudent, DetailStudentSettings,
DetailCurrentStudent
,
DetailCurrentStudentSettings
,
ListMajors
,
DetailMajor
,
WelcomeName
,
WelcomePrivacy
,
WelcomeMajor
,
WelcomeSocial
,
CreateConfirmation
,
DeleteConfirmation
)
from
.adapter
import
RemoveSocialConfirmationView
urlpatterns
=
patterns
(
''
,
...
...
@@ -38,6 +39,10 @@ urlpatterns = patterns('',
cache_page
(
4
)(
UpdateStudent
.
as_view
()),
name
=
'updateStudent'
),
url
(
r
'^student/(?P<slug>[\w-]+)/settings/social/remove/$'
,
RemoveSocialConfirmationView
.
as_view
(),
name
=
'remove_social'
),
#url(r'^settings/$',
#cache_page(4)(DetailCurrentStudentSettings.as_view()),
#name='currentStudentSettings'),
...
...
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