Commit 51b1684d authored by Briana N Abraham's avatar Briana N Abraham
Browse files

Merge branch 'master' of git.gmu.edu:srct/roomlist

parents cfe72877 edb532dd
# standard library imports
from __future__ import absolute_import, print_function
from datetime import datetime, timedelta
# core django imports
from django.shortcuts import resolve_url
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.contrib import admin
# imports from your apps
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
......@@ -30,10 +32,10 @@ def pfinfo(uname):
url = base_url + "basic/all/" + str(uname)
try:
metadata = requests.get(url)
print "Retrieving information from the peoplefinder api."
print("Retrieving information from the peoplefinder api.")
metadata.raise_for_status()
except requests.exceptions.RequestException as e:
print "Cannot resolve to peoplefinder api:", e
print("Cannot resolve to peoplefinder api:", e)
else:
pfjson = metadata.json()
try:
......@@ -53,36 +55,36 @@ def pfinfo(uname):
return final_tuple
# if the name is not in peoplefinder, return empty first and last name
except IndexError:
print "Name not found in peoplefinder."
print("Name not found in peoplefinder.")
name = [u'', u'']
major = u''
final_tuple = (name, major)
return final_tuple
# if there's no major, just return that as an empty string
except KeyError:
print "Major not found in peoplefinder."
print("Major not found in peoplefinder.")
final_tuple = (name, u'')
return final_tuple
except Exception as e:
print "Unknown peoplefinder error:", e
print("Unknown peoplefinder error:", e)
def create_user(tree):
print "Parsing CAS information."
print("Parsing CAS information.")
try:
username = tree[0][0].text
user, user_created = User.objects.get_or_create(username=username)
info_tuple = pfinfo(username)
if user_created:
print "Created user object %s." % username
print("Created user object %s." % username)
# set and save the user's email
email_str = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
user.email = email_str
user.save()
print "Added user's email, %s." % email_str
print("Added user's email, %s." % email_str)
info_name = info_tuple[0]
# a list of empty strings is False
......@@ -90,39 +92,39 @@ def create_user(tree):
user.first_name = info_name[0]
user.last_name = info_name[1]
user.save()
print "Added user's name, %s %s." % (info_name[0], info_name[1])
print("Added user's name, %s %s." % (info_name[0], info_name[1]))
else:
print "Unable to add user's name."
print("Unable to add user's name.")
print "User object creation process completed."
print("User object creation process completed.")
else:
print "User object already exists."
print("User object already exists.")
try:
Student.objects.get(user=user)
print "Student object already exists."
print("Student object already exists.")
except ObjectDoesNotExist:
new_student = Student.objects.create(user=user)
new_student.save()
print "Created student object."
print("Created student object.")
major_name = info_tuple[1]
try:
major_obj = Major.objects.get(name__contains=major_name)
new_student.major = major_obj
new_student.save()
print "Added student's major, %s." % major_name
print("Added student's major, %s." % major_name)
# ironically, 'Computer Science' returns a MultipleObjectsReturned exception
# also Major.DoesNotExist Error, but the handling for both is the same...
except:
print "Unable to add student's major."
print("Unable to add student's major.")
print "Student object creation process completed."
print("Student object creation process completed.")
print "CAS callback successful."
print("CAS callback successful.")
# if all else fails...
except Exception as e:
print "CAS callback unsuccessful:", e
print("CAS callback unsuccessful:", e)
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django import forms
# third party imports
......
# standard library imports
from __future__ import absolute_import, print_function
import re
import random
import string
......@@ -15,7 +16,7 @@ try:
page.raise_for_status()
except requests.exceptions.RequestException as e:
print e
print(e)
else:
programs = BeautifulSoup(page.content)
......
# standard library imports
from __future__ import absolute_import, print_function
import hashlib
from datetime import date
# core django imports
......
# standard library imports
from __future__ import absolute_import, print_function
# third party imports
from haystack import indexes
# imports from your apps
......
......@@ -23,7 +23,7 @@
<div class="row">
<div class="col-md-8 col-md-offset-2">
<p class="text-center">We're not trying to recreate Facebook here. On this final step, you can choose point people to a variety of your social media accounts from your user page.</p>
<p class="text-center">We're not trying to recreate Facebook here. On this final step, you can point people to a variety of your social media accounts from your user page.</p>
<p class="text-center">You'll be asked to sign in, but that's just to verify the account actually belongs to you. With the exception of your choice to use your Facebook profile picture as your profile picture here, we don't see or use any information on these third-party sites.</p>
</div>
</div>
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.test import TestCase
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.conf.urls import patterns, include, url
from django.views.decorators.cache import cache_page
# imports from your apps
from .views import DetailStudent, UpdateStudent, DetailStudentSettings,\
DetailCurrentStudent, DetailCurrentStudentSettings, ListMajors,\
DetailMajor, WelcomeName, WelcomePrivacy, WelcomeMajor, WelcomeSocial,\
CreateConfirmation, DeleteConfirmation
from .views import (DetailStudent, UpdateStudent, DetailStudentSettings,
DetailCurrentStudent, DetailCurrentStudentSettings, ListMajors,
DetailMajor, WelcomeName, WelcomePrivacy, WelcomeMajor,
WelcomeSocial, CreateConfirmation, DeleteConfirmation)
urlpatterns = patterns('',
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.shortcuts import get_object_or_404
from django.http import HttpResponseForbidden
from django.views.generic import CreateView, ListView, DetailView, UpdateView, FormView, DeleteView
from django.views.generic import (CreateView, ListView, DetailView, UpdateView,
FormView, DeleteView)
from django.core.urlresolvers import reverse
from django.contrib import messages
from django.utils.safestring import mark_safe
......@@ -69,17 +72,16 @@ def custom_cas_login(request, *args, **kwargs):
def on_the_same_floor(student, confirmer):
if student == confirmer:
print "Student is confirmer"
# Student is confirmer
return False
student_floor = student.get_floor()
confirmer_floor = confirmer.get_floor()
print student_floor, confirmer_floor
# room hasn't been set yet
if (student_floor is None) or (confirmer_floor is None):
print "One student is None"
# one Student is None
return False
elif not(student_floor == confirmer_floor):
print "not the same floor"
# not the same floor
return False
else:
return True
......@@ -110,8 +112,8 @@ class DetailStudent(LoginRequiredMixin, DetailView):
my_flag = Confirmation.objects.get(confirmer=requesting_student,
student=self.get_object())
except Exception as e:
print "Students are not supposed to be able to make more than one flag per student."
print e
print("Students are not supposed to be able to make more than one flag per student.")
print(e)
def onFloor():
floor_status = False
......@@ -189,8 +191,6 @@ class UpdateStudent(LoginRequiredMixin, FormView):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
return HttpResponseForbidden()
else:
......@@ -220,9 +220,6 @@ class UpdateStudent(LoginRequiredMixin, FormView):
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
print form.data['room']
print form.data['major']
me.user.first_name = form.data['first_name']
me.user.last_name = form.data['last_name']
me.gender = form.data.getlist('gender')
......@@ -252,8 +249,6 @@ class WelcomeName(LoginRequiredMixin, FormView):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
return HttpResponseForbidden()
else:
......@@ -303,8 +298,6 @@ class WelcomePrivacy(LoginRequiredMixin, UpdateView):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
return HttpResponseForbidden()
else:
......@@ -336,8 +329,6 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
return HttpResponseForbidden()
else:
......@@ -370,8 +361,6 @@ class WelcomeSocial(LoginRequiredMixin, DetailView):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
return HttpResponseForbidden()
else:
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.test import TestCase
# Create your tests here.
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.http import HttpResponse
# third party imports
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.contrib import admin
# imports from your apps
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.db import models
from django.core.urlresolvers import reverse
......
......@@ -46,7 +46,6 @@ Adams
315
316
Harrison
104
106
107
108
......@@ -66,9 +65,7 @@ Harrison
209
210
211
212
213
214
215
301
302
......@@ -83,7 +80,6 @@ Harrison
311
312
313
314
315
Jackson
101
......@@ -145,7 +141,6 @@ Jefferson
112
113
114
115
201
202
203
......@@ -211,6 +206,7 @@ Kennedy
302
303
305
306
307
308
309
......@@ -277,7 +273,6 @@ Madison
112
113
114
115
201
202
203
......@@ -288,6 +283,7 @@ Madison
208
209
210
211
212
214
215
......@@ -320,6 +316,7 @@ Monroe
112
113
114
115
201
202
203
......@@ -341,6 +338,7 @@ Monroe
305
306
307
308
309
310
311
......@@ -463,6 +461,7 @@ Wilson
210
211
212
213
214
215
301
......@@ -493,6 +492,8 @@ Washington
111
112
113
114
115
201
202
203
......@@ -529,30 +530,35 @@ Amherst
1006
1007
1008
1010
1011
1012
1013
1014
1015
1016
2002
2003
2004
2005
2006
2007
2008
2010
2011
2012
2013
2014
2015
2016
3002
3003
3004
3005
3006
3007
3008
3010
3011
3012
3013
......@@ -560,6 +566,7 @@ Amherst
3015
3016
Brunswick
1002
1003
1004
1005
......@@ -568,10 +575,12 @@ Brunswick
1008
1009
1010
1011
1013
1014
1015
1016
2002
2003
2004
2005
......@@ -580,10 +589,12 @@ Brunswick
2008
2009
2010
2011
2013
2014
2015
2016
3002
3003
3004
3005
......@@ -592,6 +603,7 @@ Brunswick
3008
3009
3010
3011
3013
3014
3015
......@@ -603,30 +615,35 @@ Carroll
1006
1007
1008
1010
1011
1012
1013
1014
1015
1016
2002
2003
2004
2005
2006
2007
2008
2010
2011
2012
2013
2014
2015
2016
3002
3003
3004
3005
3006
3007
3008
3010
3011
3012
3013
......@@ -634,6 +651,7 @@ Carroll
3015
3016
Dickenson
1002
1003
1004
1005
......@@ -642,10 +660,12 @@ Dickenson
1008
1009
1010
1011
1013
1014
1015
1016
2002
2003
2004
2005
......@@ -654,10 +674,12 @@ Dickenson
2008
2009
2010
2011
2013
2014
2015
2016
3002
3003
3004
3005
......@@ -666,41 +688,48 @@ Dickenson
3008
3009
3010
3011
3013
3014
3015
3016
Essex
1002
1003
1004
1005
1006
1007
1108
1010
1011
1012
1013
1014
1015
1016
2002
2003
2004
2005
2006
2007
2008
2010
2011
2012
2013
2014
2015
2016
3002
3003
3004
3005
3006
3007
3008
3010
3011
3012
3013
......@@ -708,24 +737,28 @@ Essex
3015
3016
Franklin
1002
1003
1004
1005
1006
1007
1008
1010
1011
1012
1013
1014
1015
1016
2002
2003
2004
2005
2006
2007
2008
2010
2011
2012
2013
......@@ -733,15 +766,253 @@ Franklin
2015
2016
Grayson
1002
1003
1004
1005
1006
1007
1008
1010
1011
1012
1013
1014
1015
1016
2002
2003
2004