Commit 81ed1d79 authored by Daniel W Bond's avatar Daniel W Bond

merged in the python 3 unicode literals and division changes

parents 7fb57669 9d946dc1
# standard library imports
from __future__ import absolute_import, print_function
from __future__ import absolute_import, print_function, unicode_literals
# core django imports
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
......@@ -37,7 +37,7 @@ def pfinfo(uname):
except requests.exceptions.RequestException as e:
print("Cannot resolve to peoplefinder api:", e)
print("Returning empty user info tuple.")
return ([u'', u''], u'')
return (['', ''], '')
else:
pfjson = metadata.json()
try:
......@@ -58,19 +58,19 @@ def pfinfo(uname):
# if the name is not in peoplefinder, return empty first and last name
except IndexError:
print("Name not found in peoplefinder.")
name = [u'', u'']
major = u''
name = ['', '']
major = ''
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.")
final_tuple = (name, u'')
final_tuple = (name, '')
return final_tuple
except Exception as e:
print("Unknown peoplefinder error:", e)
print("Returning empty user info tuple.")
return ([u'', u''], u'')
return (['', ''], '')
def create_user(tree):
......
# standard library imports
from __future__ import absolute_import, print_function
from __future__ import absolute_import, print_function, unicode_literals
from collections import OrderedDict
# core django imports
from django.views.generic import DetailView, ListView
......@@ -63,7 +63,7 @@ class DetailBuilding(DetailView):
def get_object(self):
url_parts = self.request.get_full_path().split('/')
# [u'', u'housing', u'building',]
# ['', 'housing', 'building',]
building_name = url_parts[2].replace('-', ' ').title()
try:
building = Building.objects.get(name=building_name)
......@@ -87,7 +87,7 @@ class DetailFloor(LoginRequiredMixin, DetailView):
def get_object(self):
url_parts = self.request.get_full_path().split('/')
# [u'', u'housing', u'building', u'floor', ]
# ['', 'housing', 'building', 'floor', ]
building_name = url_parts[2].replace('-', ' ').title()
floor_number = url_parts[3]
try:
......@@ -121,7 +121,7 @@ class DetailRoom(LoginRequiredMixin, DetailView):
def get_object(self):
url_parts = self.request.get_full_path().split('/')
# [u'', u'housing', u'building', u'floor', u'room', ]
# ['', 'housing', 'building', 'floor', 'room', ]
building_name = url_parts[2].replace('-', ' ').title()
floor_number = url_parts[3]
room_number = url_parts[4].upper()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment