Commit 04d830b6 authored by Daniel W Bond's avatar Daniel W Bond

changes made to blueridge merged into master

parents 28df18d9 ea31ab92
Pipeline #1357 passed with stage
in 3 minutes and 45 seconds
......@@ -4,9 +4,13 @@ from __future__ import absolute_import, print_function
from django.core.urlresolvers import reverse
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.views.generic import FormView
from django.forms import Form
# third party imports
from allauth.account.adapter import get_adapter as get_account_adapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from allauth.socialaccount.views import ConnectionsView
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.signals import social_account_removed
from allauth.exceptions import ImmediateHttpResponse
from braces.views import LoginRequiredMixin
......@@ -69,24 +73,79 @@ class AccountAdapter(DefaultSocialAccountAdapter):
raise ImmediateHttpResponse(update_redirect)
class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView):
class RemoveSocialConfirmationView(LoginRequiredMixin, FormView):
"""To customize where users are sent when removing their social media connections.
We have written our own template to handle this feature that is much prettier than
the one provided by allauth."""
template_name = "remove_social.html"
# we're not using this, but we're not allowed to have None
form_class = Form
template_name = "social/remove_social.html"
login_url = 'login'
def get(self, request, *args, **kwargs):
if not request.user.socialaccount_set.all():
current_url = self.request.get_full_path()
# [u'', u'accounts', u'student', u'dbond2', u'settings', u'social', u'github', u'remove', u'']
social_application = current_url.split('/')[6]
connected_accounts = [account.provider
for account in request.user.socialaccount_set.all()]
# first, check that the user has an account of the type specified in the url
if not(social_application in connected_accounts):
# no social media accounts? back to the settings page with you!
messages.add_message(self.request,
messages.INFO,
"Select a social media icon to connect an account.")
return HttpResponseRedirect(reverse('update_student',
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_context_data(self, **kwargs):
context = super(RemoveSocialConfirmationView, self).get_context_data(**kwargs)
current_url = self.request.get_full_path()
social_application = current_url.split('/')[6]
for account in self.request.user.socialaccount_set.all():
if account.provider == social_application:
branding = account.get_provider().name
context['branding'] = branding
context['application'] = social_application
return context
def post(self, request, *args, **kwargs):
current_url = self.request.get_full_path()
social_application = current_url.split('/')[6]
for account in request.user.socialaccount_set.all():
if account.provider == social_application:
social_account = account
branding = account.get_provider().name
# we do not need to use validate_disconnect, because accounts are not
# associated with being able to log in
try:
social_account.delete()
social_account_removed.send(sender=SocialAccount,
request=request,
socialaccount=social_account)
message = "%s has been successfully disconnected." % branding
messages.add_message(self.request,
messages.SUCCESS,
message)
# if multiple posts went in, there won't be any 'social_account' or 'branding'
# basically, that means it's already gone and it already works
except UnboundLocalError:
get_account_adapter().add_message(self.request,
messages.SUCCESS,
'socialaccount/messages/'
'account_disconnected.txt')
return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
return reverse('update_student',
......
......@@ -160,6 +160,18 @@ class Student(TimeStampedModel):
(OTHER, 'other'),
)
RESIDENT = 'Resident'
RA = 'Resident Advisor'
RD = 'Resident Director'
LEAD_CHOICES = (
(RESIDENT, 'Resident'),
(RA, 'Resident Advisor'),
(RD, 'Resident Director'),
)
lead = models.CharField(max_length=100, choices=LEAD_CHOICES, default=RESIDENT)
# selectmultiple in forms
gender = MultiSelectField(max_length=100, choices=GENDER_CHOICES, blank=True)
show_gender = models.BooleanField(default=False)
......@@ -284,6 +296,12 @@ class Student(TimeStampedModel):
else:
return self.user.get_full_name()
def is_staff(self):
staff = False
if self.lead == 'Resident Advisor' or self.lead == 'Resident Director':
staff = True
return staff
# how recently has the student joined roomlist? changes some messages displayed
def is_noob(self):
now = timezone.now()
......
{% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Student | {{ student.get_full_name_or_uname }} | Delete {% endblock %}
{% block title %} SRCT RoomList • Delete My Account {% endblock %}
{% block message_queue %}
{% endblock %}
......@@ -10,8 +10,7 @@
<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">Delete <strong>{{ student.get_full_name_or_uname }}</strong></p>
<h1><strong>Delete My Account</strong></h1>
</div>
</div>
</div>
......
{% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | Majors | {{ major.name }} {% endblock title %}
{% block title %}
SRCT Roomlist &bull; Majors &bull; {{ major.name }}
{% endblock title %}
{% block content %}
{% load cache %}
{% cache 15 major_students request.user.username major %}
......@@ -7,8 +9,7 @@
<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"><strong>{{ major.name }}</strong></p>
<h1><strong>{{ major.name }}</strong></h1>
</div>
</div>
</div>
......
{% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | {{ student.user.first_name }} {{ student.user.last_name }} {% endblock title %}
{% block title %}
SRCT Roomlist &bull; {{ student.user.first_name }} {{ student.user.last_name }}
{% endblock title %}
{% block content %}
{% load socialaccount %}
{% load gravatar %}
......@@ -14,10 +16,16 @@
</div>
<div class="col-md-6 text-center">
<h1><strong>{{ student.get_full_name_or_uname }}</strong></h1>
<h1>
<strong>{{ student.get_full_name_or_uname }}</strong>
{% if student.is_staff %}
<br />
<small><span class="text-info">{{ student.lead }}</span></small>
{% endif %}
</h1>
{% if shares %}
<p class="lead"><strong>
{% if not student.on_campus %}
{% if not student.on_campus and not student.is_staff %}
{{ student.get_first_name_or_uname }} doesn't live on campus.
{% elif student.room == None %}
{{ student.get_first_name_or_uname }} hasn't set their room yet.
......@@ -117,56 +125,61 @@
</td>
<td class="col-md-8">
{% if accounts.facebook and shares %}
<h4><a href="https://facebook.com/{{ accounts.facebook.0.uid }}" target="_blank">
Facebook account</a></h4>
<h4>
<a href="https://facebook.com/{{ accounts.facebook.0.uid }}" target="_blank">
Facebook account</a>
</h4>
{% else %} <h4>&mdash;</h4> {% endif %}
</td>
</tr>
<tr>
<td>
<h4><i class="fa fa-twitter fa-lg"></i></h4>
</td>
<td>
{% if accounts.twitter and shares %}
<h4><a href="https://twitter.com/{{ accounts.twitter.0.extra_data.screen_name }}" target="_blank">
@{{ accounts.twitter.0.extra_data.screen_name }}</a></h4>
<h4>
<a href="https://twitter.com/{{ accounts.twitter.0.extra_data.screen_name }}" target="_blank">
@{{ accounts.twitter.0.extra_data.screen_name }}</a></h4>
{% else %} <h4>&mdash;</h4> {% endif %}
</td>
</tr>
<tr>
<td>
<h4><i class="fa fa-google fa-lg"></i></h4>
</td>
<td>
{% if accounts.google and shares %}
<h4><a href="https://plus.google.com/{{ accounts.google.0.uid }}" target="_blank">
Google+ account</a></h4>
<h4>
<a href="https://plus.google.com/{{ accounts.google.0.uid }}" target="_blank">
Google+ account</a>
</h4>
{% else %} <h4>&mdash;</h4> {% endif %}
</td>
</tr>
{% if accounts.instagram and shares %}
<tr>
<td>
<h4><i class="fa fa-instagram fa-lg"></i></h4>
</td>
<td>
<h4><a href="https://instagram.com/{{ accounts.instagram.0.extra_data.username }}"
target="_blank">@{{ accounts.instagram.0.extra_data.username }}</a></h4>
<h4>
<a href="https://instagram.com/{{ accounts.instagram.0.extra_data.username }}"
target="_blank">@{{ accounts.instagram.0.extra_data.username }}</a>
</h4>
</td>
</tr>
{% endif %}
{% if accounts.tumblr and shares %}
<tr>
<td>
<h4><i class="fa fa-tumblr fa-lg"></i></h4>
</td>
<td>
<h4><a href="https://{{ accounts.tumblr.0.extra_data.name }}.tumblr.com"
target="_blank">@{{ accounts.tumblr.0.extra_data.name }}</a></h4>
<h4>
<a href="https://{{ accounts.tumblr.0.extra_data.name }}.tumblr.com"
target="_blank">@{{ accounts.tumblr.0.extra_data.name }}</a>
</h4>
</td>
</tr>
{% endif %}
......
{% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | Majors {% endblock title %}
{% block title %} SRCT Roomlist &bull; Majors {% endblock title %}
{% block og_metadata %}
<meta property="og:title" content="SRCT Roomlist Majors"/>
......@@ -22,8 +22,7 @@
<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"><strong>Majors</strong></p>
<h1><strong>Majors</strong></h1>
</div>
</div>
</div>
......
......@@ -8,9 +8,8 @@ SRCT Roomlist &bull; Search Students
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12">
<h1 class="text-center"><strong>SRCT</strong>&#8203;ROOMLIST</h1>
<p class="lead text-center"><strong>Search</strong></p>
<div class="col-md-12 text-center">
<h1><strong>Search Students</strong></h1>
</div>
</div>
</div>
......
......@@ -10,56 +10,23 @@
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12 text-center">
<h1><strong>SRCT</strong>&#8203;ROOMLIST</h1>
<p class="lead text-center">Remove My Social Media Accounts</p>
<h1><i class="fa fa-fw fa-2x fa-times"></i> <i class="fa fa-fw fa-2x fa-{{ application }}"></i></h1>
<p class="lead">Remove My {{ branding }} Account</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>
<form class="form-horizontal text-center" method="post" action="">{% csrf_token %}
<input type="submit" value="Remove" class="btn btn-danger"/>
<input type="cancel" value="Never Mind" class="btn btn-default" onclick="history.back()"/>
</form>
</div>
</div>
<hr/ >
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<div class="alert alert-danger" role="alert">
......
{% load socialaccount %}
{% get_social_accounts request.user as accounts %}
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center"><strong>Social Media Settings</strong></h1>
</div>
<div class="panel-body">
<p class="text-center">Verify your social media accounts to link them to other students.</p>
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.facebook %}
<a href="{% url 'remove_social' request.user.username 'facebook' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-facebook fa-2x"></i></h4>
<h4>Facebook</h4>
{% else %}
<a href="{% provider_login_url 'facebook' process='connect' %}">
<h4><i class="fa fa-facebook fa-2x"></i></h4>
<h4>Facebook</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.google %}
<a href="{% url 'remove_social' request.user.username 'google' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-google fa-2x"></i></h4>
<h4>Google</h4>
{% else %}
<a href="{% provider_login_url 'google' process='connect' %}">
<h4><i class="fa fa-google fa-2x"></i></h4>
<h4>Google</h4>
</a>
{% endif %}
</div>
</div>
<br />
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.twitter %}
<a href="{% url 'remove_social' request.user.username 'twitter' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-twitter fa-2x"></i></h4>
<h4>Twitter</h4>
{% else %}
<a href="{% provider_login_url 'twitter' process='connect' %}">
<h4><i class="fa fa-twitter fa-2x"></i></h4>
<h4>Twitter</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.instagram %}
<a href="{% url 'remove_social' request.user.username 'instagram' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-instagram fa-2x"></i></h4>
<h4>Instagram</h4>
{% else %}
<a href="{% provider_login_url 'instagram' process='connect' %}">
<h4><i class="fa fa-instagram fa-2x"></i></h4>
<h4>Instagram</h4>
</a>
{% endif %}
</div>
</div>
<br />
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.tumblr %}
<a href="{% url 'remove_social' request.user.username 'tumblr' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-tumblr fa-2x"></i></h4>
<h4>Tumblr</h4>
{% else %}
<a href="{% provider_login_url 'tumblr' process='connect' %}">
<h4><i class="fa fa-tumblr fa-2x"></i></h4>
<h4>Tumblr</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.github %}
<a href="{% url 'remove_social' request.user.username 'github' %}">
<p><i class="fa fa-check-square-o"></i> Verified!</p>
</a>
<h4><i class="fa fa-github fa-2x"></i></h4>
<h4>Github</h4>
{% else %}
<a href="{% provider_login_url 'github' process='connect' %}">
<h4><i class="fa fa-github fa-2x"></i></h4>
<h4>Github</h4>
</a>
{% endif %}
</div>
</div>
<br />
</div>
</div>
</div>
{% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | Student | {{ request.user.student.get_full_name_or_uname }} | Update {% endblock %}
{% block title %} SRCT Roomlist &bull; My Settings {% endblock %}
{% block css %}
<link href="/static/css/chosen.min.css" rel="stylesheet" media="screen">
......@@ -23,165 +23,25 @@
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12 text-center">
<h1><strong>SRCT</strong>ROOMLIST</a></strong> {{ request.user.student.get_full_name_or_uname }}'s Settings</h1>
<h1><strong>My Settings</strong></h1>
</div>
</div>
</div>
{% load socialaccount %}
{% get_social_accounts request.user as accounts %}
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center"><strong>Social Media Settings</strong></h1>
</div>
<div class="panel-body">
<p class="text-center">Verify your social media accounts to link them to other students.</p>
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.facebook %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-facebook fa-2x"></i></h4>
<h4>Facebook</h4>
{% else %}
<br />
<a href="{% provider_login_url 'facebook' process='connect' %}">
<h4><i class="fa fa-facebook fa-2x"></i></h4>
<h4>Facebook</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.google %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-google fa-2x"></i></h4>
<h4>Google</h4>
{% else %}
<br />
<a href="{% provider_login_url 'google' process='connect' %}">
<h4><i class="fa fa-google fa-2x"></i></h4>
<h4>Google</h4>
</a>
{% endif %}
</div>
</div>
<br />
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.twitter %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-twitter fa-2x"></i></h4>
<h4>Twitter</h4>
{% else %}
<br />
<a href="{% provider_login_url 'twitter' process='connect' %}">
<h4><i class="fa fa-twitter fa-2x"></i></h4>
<h4>Twitter</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.instagram %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-instagram fa-2x"></i></h4>
<h4>Instagram</h4>
{% else %}
<br />
<a href="{% provider_login_url 'instagram' process='connect' %}">
<h4><i class="fa fa-instagram fa-2x"></i></h4>
<h4>Instagram</h4>
</a>
{% endif %}
</div>
</div>
<br />
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.tumblr %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-tumblr fa-2x"></i></h4>
<h4>Tumblr</h4>
{% else %}
<br />
<a href="{% provider_login_url 'tumblr' process='connect' %}">
<h4><i class="fa fa-tumblr fa-2x"></i></h4>
<h4>Tumblr</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.pinterest %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-pinterest-p fa-2x"></i></h4>
<h4>Pinterest</h4>
{% else %}
<br />
<a href="{% provider_login_url 'pinterest' process='connect' %}">
<h4><i class="fa fa-pinterest-p fa-2x"></i></h4>
<h4>Pinterest</h4>
</a>
{% endif %}
</div>
</div>
<br />
<div class="row text-center">
<div class="col-xs-6">
{% if accounts.spotify %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-spotify fa-2x"></i></h4>
<h4>Spotify</h4>
{% else %}
<br />
<a href="{% provider_login_url 'spotify' process='connect' %}">
<h4><i class="fa fa-spotify fa-2x"></i></h4>
<h4>Spotify</h4>
</a>
{% endif %}
</div>
<div class="col-xs-6">
{% if accounts.github %}
<p><i class="fa fa-check-square-o"></i> Verified!</p>
<h4><i class="fa fa-github fa-2x"></i></h4>
<h4>Github</h4>
{% else %}
<br />
<a href="{% provider_login_url 'github' process='connect' %}">
<h4><i class="fa fa-github fa-2x"></i></h4>
<h4>Github</h4>
</a>
{% endif %}
</div>
</div>
<br />
{% if accounts %}
<div class="row text-center">
<a href="{% url 'remove_social' request.user.username %}">
<button class="btn btn-xs btn-danger">Disconnect Accounts</button>
</a>
</div>
{% endif %}
</div>
</div>
</div>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center"><strong>Profile Settings</strong></h1>
</div>
<div class="panel-body">
<p>
If you have a <a href="https://en.gravatar.com/">Gravatar profile</a> associated
with your <a href="https://masonlive.gmu.edu/">Masonlive email</a> address, your
profile picture on Roomlist will use Gravatar.
</p>
<p>
If you connect your Facebook account, we will use your Facebook profile picture.
<p class="small">
<i class="fa fa-fw fa-info-circle"></i>
Unfortunately we do not support uploading images for your profile picture.
Connect your Facebook account, or add your
<a href="http://masonlive.gmu.edu/">@masonlive.gmu.edu</a>
email address to <a href="https://en.gravatar.com/">Gravatar</a>.
</p>
<hr />
{% if my_form.non_field_errors %}
......@@ -297,6 +157,10 @@
<p class="text-danger"><i class="fa fa-exclamation-triangle fa-fw"></i> {{ error }}</p>
{% endfor %}
{% endif %}
{% if request.user.student.is_staff %}
<p class="help-block">Contact us if you are no longer a Resident Advisor or Director at
<a href="mailto:roomlist@lists.srct.gmu.edu">roomlist@lists.srct.gmu.edu</a>.</p>
{% endif %}
<div class="form-group">
<div class="col-md-4">
<label for="{{ my_form.on_campus.id_for_label }}">
......@@ -362,10 +226,13 @@