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

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

parents cfe72877 edb532dd
# standard library imports # standard library imports
from __future__ import absolute_import, print_function
from datetime import datetime, timedelta from datetime import datetime, timedelta
# core django imports # core django imports
from django.shortcuts import resolve_url from django.shortcuts import resolve_url
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.contrib import admin from django.contrib import admin
# imports from your apps # imports from your apps
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
...@@ -30,10 +32,10 @@ def pfinfo(uname): ...@@ -30,10 +32,10 @@ def pfinfo(uname):
url = base_url + "basic/all/" + str(uname) url = base_url + "basic/all/" + str(uname)
try: try:
metadata = requests.get(url) metadata = requests.get(url)
print "Retrieving information from the peoplefinder api." print("Retrieving information from the peoplefinder api.")
metadata.raise_for_status() metadata.raise_for_status()
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print "Cannot resolve to peoplefinder api:", e print("Cannot resolve to peoplefinder api:", e)
else: else:
pfjson = metadata.json() pfjson = metadata.json()
try: try:
...@@ -53,36 +55,36 @@ def pfinfo(uname): ...@@ -53,36 +55,36 @@ def pfinfo(uname):
return final_tuple return final_tuple
# if the name is not in peoplefinder, return empty first and last name # if the name is not in peoplefinder, return empty first and last name
except IndexError: except IndexError:
print "Name not found in peoplefinder." print("Name not found in peoplefinder.")
name = [u'', u''] name = [u'', u'']
major = u'' major = u''
final_tuple = (name, major) final_tuple = (name, major)
return final_tuple return final_tuple
# if there's no major, just return that as an empty string # if there's no major, just return that as an empty string
except KeyError: except KeyError:
print "Major not found in peoplefinder." print("Major not found in peoplefinder.")
final_tuple = (name, u'') final_tuple = (name, u'')
return final_tuple return final_tuple
except Exception as e: except Exception as e:
print "Unknown peoplefinder error:", e print("Unknown peoplefinder error:", e)
def create_user(tree): def create_user(tree):
print "Parsing CAS information." print("Parsing CAS information.")
try: try:
username = tree[0][0].text username = tree[0][0].text
user, user_created = User.objects.get_or_create(username=username) user, user_created = User.objects.get_or_create(username=username)
info_tuple = pfinfo(username) info_tuple = pfinfo(username)
if user_created: if user_created:
print "Created user object %s." % username print("Created user object %s." % username)
# set and save the user's email # set and save the user's email
email_str = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN) email_str = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
user.email = email_str user.email = email_str
user.save() user.save()
print "Added user's email, %s." % email_str print("Added user's email, %s." % email_str)
info_name = info_tuple[0] info_name = info_tuple[0]
# a list of empty strings is False # a list of empty strings is False
...@@ -90,39 +92,39 @@ def create_user(tree): ...@@ -90,39 +92,39 @@ def create_user(tree):
user.first_name = info_name[0] user.first_name = info_name[0]
user.last_name = info_name[1] user.last_name = info_name[1]
user.save() 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: 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: else:
print "User object already exists." print("User object already exists.")
try: try:
Student.objects.get(user=user) Student.objects.get(user=user)
print "Student object already exists." print("Student object already exists.")
except ObjectDoesNotExist: except ObjectDoesNotExist:
new_student = Student.objects.create(user=user) new_student = Student.objects.create(user=user)
new_student.save() new_student.save()
print "Created student object." print("Created student object.")
major_name = info_tuple[1] major_name = info_tuple[1]
try: try:
major_obj = Major.objects.get(name__contains=major_name) major_obj = Major.objects.get(name__contains=major_name)
new_student.major = major_obj new_student.major = major_obj
new_student.save() 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 # ironically, 'Computer Science' returns a MultipleObjectsReturned exception
# also Major.DoesNotExist Error, but the handling for both is the same... # also Major.DoesNotExist Error, but the handling for both is the same...
except: 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... # if all else fails...
except Exception as e: 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 # core django imports
from django import forms from django import forms
# third party imports # third party imports
......
# standard library imports # standard library imports
from __future__ import absolute_import, print_function
import re import re
import random import random
import string import string
...@@ -15,7 +16,7 @@ try: ...@@ -15,7 +16,7 @@ try:
page.raise_for_status() page.raise_for_status()
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print e print(e)
else: else:
programs = BeautifulSoup(page.content) programs = BeautifulSoup(page.content)
......
# standard library imports # standard library imports
from __future__ import absolute_import, print_function
import hashlib import hashlib
from datetime import date from datetime import date
# core django imports # core django imports
......
# standard library imports
from __future__ import absolute_import, print_function
# third party imports # third party imports
from haystack import indexes from haystack import indexes
# imports from your apps # imports from your apps
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<div class="row"> <div class="row">
<div class="col-md-8 col-md-offset-2"> <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> <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>
</div> </div>
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.test import TestCase from django.test import TestCase
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from django.views.decorators.cache import cache_page from django.views.decorators.cache import cache_page
# imports from your apps # imports from your apps
from .views import DetailStudent, UpdateStudent, DetailStudentSettings,\ from .views import (DetailStudent, UpdateStudent, DetailStudentSettings,
DetailCurrentStudent, DetailCurrentStudentSettings, ListMajors,\ DetailCurrentStudent, DetailCurrentStudentSettings, ListMajors,
DetailMajor, WelcomeName, WelcomePrivacy, WelcomeMajor, WelcomeSocial,\ DetailMajor, WelcomeName, WelcomePrivacy, WelcomeMajor,
CreateConfirmation, DeleteConfirmation WelcomeSocial, CreateConfirmation, DeleteConfirmation)
urlpatterns = patterns('', urlpatterns = patterns('',
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.http import HttpResponseForbidden 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.core.urlresolvers import reverse
from django.contrib import messages from django.contrib import messages
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
...@@ -69,17 +72,16 @@ def custom_cas_login(request, *args, **kwargs): ...@@ -69,17 +72,16 @@ def custom_cas_login(request, *args, **kwargs):
def on_the_same_floor(student, confirmer): def on_the_same_floor(student, confirmer):
if student == confirmer: if student == confirmer:
print "Student is confirmer" # Student is confirmer
return False return False
student_floor = student.get_floor() student_floor = student.get_floor()
confirmer_floor = confirmer.get_floor() confirmer_floor = confirmer.get_floor()
print student_floor, confirmer_floor
# room hasn't been set yet # room hasn't been set yet
if (student_floor is None) or (confirmer_floor is None): if (student_floor is None) or (confirmer_floor is None):
print "One student is None" # one Student is None
return False return False
elif not(student_floor == confirmer_floor): elif not(student_floor == confirmer_floor):
print "not the same floor" # not the same floor
return False return False
else: else:
return True return True
...@@ -110,8 +112,8 @@ class DetailStudent(LoginRequiredMixin, DetailView): ...@@ -110,8 +112,8 @@ class DetailStudent(LoginRequiredMixin, DetailView):
my_flag = Confirmation.objects.get(confirmer=requesting_student, my_flag = Confirmation.objects.get(confirmer=requesting_student,
student=self.get_object()) student=self.get_object())
except Exception as e: except Exception as e:
print "Students are not supposed to be able to make more than one flag per student." print("Students are not supposed to be able to make more than one flag per student.")
print e print(e)
def onFloor(): def onFloor():
floor_status = False floor_status = False
...@@ -189,8 +191,6 @@ class UpdateStudent(LoginRequiredMixin, FormView): ...@@ -189,8 +191,6 @@ class UpdateStudent(LoginRequiredMixin, FormView):
current_url = self.request.get_full_path() current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3] url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
else: else:
...@@ -220,9 +220,6 @@ class UpdateStudent(LoginRequiredMixin, FormView): ...@@ -220,9 +220,6 @@ class UpdateStudent(LoginRequiredMixin, FormView):
def form_valid(self, form): def form_valid(self, form):
me = Student.objects.get(user=self.request.user) 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.first_name = form.data['first_name']
me.user.last_name = form.data['last_name'] me.user.last_name = form.data['last_name']
me.gender = form.data.getlist('gender') me.gender = form.data.getlist('gender')
...@@ -252,8 +249,6 @@ class WelcomeName(LoginRequiredMixin, FormView): ...@@ -252,8 +249,6 @@ class WelcomeName(LoginRequiredMixin, FormView):
current_url = self.request.get_full_path() current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3] url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
else: else:
...@@ -303,8 +298,6 @@ class WelcomePrivacy(LoginRequiredMixin, UpdateView): ...@@ -303,8 +298,6 @@ class WelcomePrivacy(LoginRequiredMixin, UpdateView):
current_url = self.request.get_full_path() current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3] url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
else: else:
...@@ -336,8 +329,6 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView): ...@@ -336,8 +329,6 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView):
current_url = self.request.get_full_path() current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3] url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
else: else:
...@@ -370,8 +361,6 @@ class WelcomeSocial(LoginRequiredMixin, DetailView): ...@@ -370,8 +361,6 @@ class WelcomeSocial(LoginRequiredMixin, DetailView):
current_url = self.request.get_full_path() current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3] url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
else: else:
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.test import TestCase from django.test import TestCase
# Create your tests here. # Create your tests here.
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.http import HttpResponse from django.http import HttpResponse
# third party imports # third party imports
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.contrib import admin from django.contrib import admin
# imports from your apps # imports from your apps
......
# standard library imports
from __future__ import absolute_import, print_function
# core django imports # core django imports
from django.db import models from django.db import models
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
......
...@@ -46,7 +46,6 @@ Adams ...@@ -46,7 +46,6 @@ Adams
315 315
316 316
Harrison Harrison
104
106 106
107 107
108 108
...@@ -66,9 +65,7 @@ Harrison ...@@ -66,9 +65,7 @@ Harrison
209 209
210 210
211 211
212
213 213
214
215 215
301 301
302 302
...@@ -83,7 +80,6 @@ Harrison ...@@ -83,7 +80,6 @@ Harrison
311 311
312 312
313 313
314
315 315
Jackson Jackson
101 101
...@@ -145,7 +141,6 @@ Jefferson ...@@ -145,7 +141,6 @@ Jefferson
112 112
113 113
114 114
115
201 201
202 202
203 203
...@@ -211,6 +206,7 @@ Kennedy ...@@ -211,6 +206,7 @@ Kennedy
302 302
303 303
305 305
306
307 307
308 308
309 309
...@@ -277,7 +273,6 @@ Madison ...@@ -277,7 +273,6 @@ Madison
112 112
113 113
114 114
115
201 201
202 202
203 203
...@@ -288,6 +283,7 @@ Madison ...@@ -288,6 +283,7 @@ Madison
208 208
209 209
210 210
211
212 212
214 214
215 215
...@@ -320,6 +316,7 @@ Monroe ...@@ -320,6 +316,7 @@ Monroe
112 112
113 113
114 114
115
201 201
202 202
203 203
...@@ -341,6 +338,7 @@ Monroe ...@@ -341,6 +338,7 @@ Monroe
305 305
306 306
307 307
308
309 309
310 310
311 311
...@@ -463,6 +461,7 @@ Wilson ...@@ -463,6 +461,7 @@ Wilson
210 210
211 211
212 212
213
214 214
215 215
301 301
...@@ -493,6 +492,8 @@ Washington ...@@ -493,6 +492,8 @@ Washington
111 111
112 112
113 113
114
115
201 201
202 202
203 203
...@@ -529,30 +530,35 @@ Amherst ...@@ -529,30 +530,35 @@ Amherst
1006 1006
1007 1007
1008 1008
1010
1011 1011
1012 1012
1013 1013
1014 1014
1015 1015
1016 1016