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
argparse==1.2.1 argparse==1.2.1
beautifulsoup4==4.4.1 beautifulsoup4==4.3.2
Django==1.9.12 Django>1.11, <1.12
django-allauth==0.28.0 django-allauth==0.30.0
django-analytical==1.0.0 django-analytical==2.0.0
django-autoslug==1.9.3 django-autoslug==1.9.3
django-braces==1.8.1 django-braces==1.8.0
django-cas-client==1.2.0 django-cas-client==1.3.0
django-crispy-forms==1.5.2 django-crispy-forms==1.6.1
django-filter==0.12.0 django-filter==0.12.0
django-gravatar2==1.3.0 django-gravatar2==1.1.4
django-haystack==2.4.1 django-haystack==2.5.1
django-localflavor==1.2 django-localflavor==1.0
django-model-utils==2.4 django-model-utils==2.2
django-multiselectfield==0.1.3 django-multiselectfield==0.1.6
django-randomslugfield==0.3.0 django-randomslugfield==0.3.0
django-ratelimit==0.6.0 django-ratelimit==0.6.0
django-redis-cache==1.6.4 django-redis-cache==1.6.4
...@@ -26,10 +26,11 @@ oauthlib==2.0.0 ...@@ -26,10 +26,11 @@ oauthlib==2.0.0
pep8==1.6.2 pep8==1.6.2
pyflakes==1.0.0 pyflakes==1.0.0
python-openid==2.2.5 python-openid==2.2.5
redis==2.10.5 pytz==2017.2
requests==2.11.1 redis==2.10.3
requests-oauthlib==0.7.0 requests==2.5.1
six==1.10.0 requests-oauthlib==0.4.2
six==1.8.0
wsgiref==0.1.2 wsgiref==0.1.2
wheel==0.26.0 wheel==0.26.0
Whoosh==2.7.0 Whoosh==2.7.0
...@@ -4,9 +4,13 @@ from __future__ import absolute_import, print_function ...@@ -4,9 +4,13 @@ from __future__ import absolute_import, print_function
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.contrib import messages from django.contrib import messages
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.views.generic import FormView
from django.forms import Form
# third party imports # third party imports
from allauth.account.adapter import get_adapter as get_account_adapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter 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 allauth.exceptions import ImmediateHttpResponse
from braces.views import LoginRequiredMixin from braces.views import LoginRequiredMixin
...@@ -69,24 +73,79 @@ class AccountAdapter(DefaultSocialAccountAdapter): ...@@ -69,24 +73,79 @@ class AccountAdapter(DefaultSocialAccountAdapter):
raise ImmediateHttpResponse(update_redirect) raise ImmediateHttpResponse(update_redirect)
class RemoveSocialConfirmationView(LoginRequiredMixin, ConnectionsView): class RemoveSocialConfirmationView(LoginRequiredMixin, FormView):
"""To customize where users are sent when removing their social media connections. """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 We have written our own template to handle this feature that is much prettier than
the one provided by allauth.""" 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' login_url = 'login'
def get(self, request, *args, **kwargs): 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! # 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', return HttpResponseRedirect(reverse('update_student',
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)
def form_valid(self, form): def get_context_data(self, **kwargs):
return super(RemoveSocialConfirmationView, self).form_valid(form) 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): def get_success_url(self):
return reverse('update_student', return reverse('update_student',
......
...@@ -160,6 +160,18 @@ class Student(TimeStampedModel): ...@@ -160,6 +160,18 @@ class Student(TimeStampedModel):
(OTHER, 'other'), (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 # selectmultiple in forms
gender = MultiSelectField(max_length=100, choices=GENDER_CHOICES, blank=True) gender = MultiSelectField(max_length=100, choices=GENDER_CHOICES, blank=True)
show_gender = models.BooleanField(default=False) show_gender = models.BooleanField(default=False)
...@@ -284,6 +296,12 @@ class Student(TimeStampedModel): ...@@ -284,6 +296,12 @@ class Student(TimeStampedModel):
else: else:
return self.user.get_full_name() 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 # how recently has the student joined roomlist? changes some messages displayed
def is_noob(self): def is_noob(self):
now = timezone.now() now = timezone.now()
......
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Student | {{ student.get_full_name_or_uname }} | Delete {% endblock %} {% block title %} SRCT RoomList &bull; Delete My Account {% endblock %}
{% block message_queue %} {% block message_queue %}
{% endblock %} {% endblock %}
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h1><strong>SRCT</strong>ROOMLIST</h1> <h1><strong>Delete My Account</strong></h1>
<p class="lead">Delete <strong>{{ student.get_full_name_or_uname }}</strong></p>
</div> </div>
</div> </div>
</div> </div>
......
{% extends 'layouts/base.html' %} {% 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 %} {% block content %}
{% load cache %} {% load cache %}
{% cache 15 major_students request.user.username major %} {% cache 15 major_students request.user.username major %}
...@@ -7,8 +9,7 @@ ...@@ -7,8 +9,7 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h1><strong>SRCT</strong>ROOMLIST</h1> <h1><strong>{{ major.name }}</strong></h1>
<p class="lead"><strong>{{ major.name }}</strong></p>
</div> </div>
</div> </div>
</div> </div>
......
{% extends 'layouts/base.html' %} {% 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 %} {% block content %}
{% load socialaccount %} {% load socialaccount %}
{% load gravatar %} {% load gravatar %}
...@@ -14,10 +16,16 @@ ...@@ -14,10 +16,16 @@
</div> </div>
<div class="col-md-6 text-center"> <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 %} {% if shares %}
<p class="lead"><strong> <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. {{ student.get_first_name_or_uname }} doesn't live on campus.
{% elif student.room == None %} {% elif student.room == None %}
{{ student.get_first_name_or_uname }} hasn't set their room yet. {{ student.get_first_name_or_uname }} hasn't set their room yet.
...@@ -117,56 +125,61 @@ ...@@ -117,56 +125,61 @@
</td> </td>
<td class="col-md-8"> <td class="col-md-8">
{% if accounts.facebook and shares %} {% if accounts.facebook and shares %}
<h4><a href="https://facebook.com/{{ accounts.facebook.0.uid }}" target="_blank"> <h4>
Facebook account</a></h4> <a href="https://facebook.com/{{ accounts.facebook.0.uid }}" target="_blank">
Facebook account</a>
</h4>
{% else %} <h4>&mdash;</h4> {% endif %} {% else %} <h4>&mdash;</h4> {% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<h4><i class="fa fa-twitter fa-lg"></i></h4> <h4><i class="fa fa-twitter fa-lg"></i></h4>
</td> </td>
<td> <td>
{% if accounts.twitter and shares %} {% if accounts.twitter and shares %}
<h4><a href="https://twitter.com/{{ accounts.twitter.0.extra_data.screen_name }}" target="_blank"> <h4>
<a href="https://twitter.com/{{ accounts.twitter.0.extra_data.screen_name }}" target="_blank">
@{{ accounts.twitter.0.extra_data.screen_name }}</a></h4> @{{ accounts.twitter.0.extra_data.screen_name }}</a></h4>
{% else %} <h4>&mdash;</h4> {% endif %} {% else %} <h4>&mdash;</h4> {% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<h4><i class="fa fa-google fa-lg"></i></h4> <h4><i class="fa fa-google fa-lg"></i></h4>
</td> </td>
<td> <td>
{% if accounts.google and shares %} {% if accounts.google and shares %}
<h4><a href="https://plus.google.com/{{ accounts.google.0.uid }}" target="_blank"> <h4>
Google+ account</a></h4> <a href="https://plus.google.com/{{ accounts.google.0.uid }}" target="_blank">
Google+ account</a>
</h4>
{% else %} <h4>&mdash;</h4> {% endif %} {% else %} <h4>&mdash;</h4> {% endif %}
</td> </td>
</tr> </tr>
{% if accounts.instagram and shares %} {% if accounts.instagram and shares %}
<tr> <tr>
<td> <td>
<h4><i class="fa fa-instagram fa-lg"></i></h4> <h4><i class="fa fa-instagram fa-lg"></i></h4>
</td> </td>
<td> <td>
<h4><a href="https://instagram.com/{{ accounts.instagram.0.extra_data.username }}" <h4>
target="_blank">@{{ accounts.instagram.0.extra_data.username }}</a></h4> <a href="https://instagram.com/{{ accounts.instagram.0.extra_data.username }}"
target="_blank">@{{ accounts.instagram.0.extra_data.username }}</a>
</h4>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if accounts.tumblr and shares %} {% if accounts.tumblr and shares %}
<tr> <tr>
<td> <td>
<h4><i class="fa fa-tumblr fa-lg"></i></h4> <h4><i class="fa fa-tumblr fa-lg"></i></h4>
</td> </td>
<td> <td>
<h4><a href="https://{{ accounts.tumblr.0.extra_data.name }}.tumblr.com" <h4>
target="_blank">@{{ accounts.tumblr.0.extra_data.name }}</a></h4> <a href="https://{{ accounts.tumblr.0.extra_data.name }}.tumblr.com"
target="_blank">@{{ accounts.tumblr.0.extra_data.name }}</a>
</h4>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
......
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | Majors {% endblock title %} {% block title %} SRCT Roomlist &bull; Majors {% endblock title %}
{% block og_metadata %} {% block og_metadata %}
<meta property="og:title" content="SRCT Roomlist Majors"/> <meta property="og:title" content="SRCT Roomlist Majors"/>
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h1><strong>SRCT</strong>ROOMLIST</h1> <h1><strong>Majors</strong></h1>
<p class="lead"><strong>Majors</strong></p>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -8,9 +8,8 @@ SRCT Roomlist &bull; Search Students ...@@ -8,9 +8,8 @@ SRCT Roomlist &bull; Search Students
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-md-12 text-center">
<h1 class="text-center"><strong>SRCT</strong>&#8203;ROOMLIST</h1> <h1><strong>Search Students</strong></h1>
<p class="lead text-center"><strong>Search</strong></p>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -10,56 +10,23 @@ ...@@ -10,56 +10,23 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h1><strong>SRCT</strong>&#8203;ROOMLIST</h1> <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 text-center">Remove My Social Media Accounts</p> <p class="lead">Remove My {{ branding }} Account</p>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-8 col-md-offset-2"> <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 %} <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="submit" value="Remove" class="btn btn-danger"/>
<input type="cancel" value="Never Mind" class="btn btn-default" onclick="history.back()"/> <input type="cancel" value="Never Mind" class="btn btn-default" onclick="history.back()"/>
</div>
</fieldset>
</form> </form>
</div> </div>
</div>
</div>
</div> </div>
<hr/ >
<div class="row"> <div class="row">
<div class="col-md-8 col-md-offset-2 text-center"> <div class="col-md-8 col-md-offset-2 text-center">
<div class="alert alert-danger" role="alert"> <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' %} {% 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 %} {% block css %}
<link href="/static/css/chosen.min.css" rel="stylesheet" media="screen"> <link href="/static/css/chosen.min.css" rel="stylesheet" media="screen">
...@@ -23,165 +23,25 @@ ...@@ -23,165 +23,25 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <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> </div>
</div> </div>
{% load socialaccount %}
{% get_social_accounts request.user as accounts %}
<div class="row"> <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>