Commit 9d946dc1 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

python3 unicode and division support

parent b7ef4e1f
# 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
......@@ -38,7 +38,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:
......@@ -59,19 +59,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, division
import hashlib
from datetime import date
# core django imports
......@@ -213,7 +213,7 @@ class Student(TimeStampedModel):
days = (now - created).days
# must be int-- floor function
third_years = (days / (30 * 4)) + 1
third_years = (days // (30 * 4)) + 1
return (self.times_changed_room / third_years)
......
# standard library imports
from __future__ import absolute_import, print_function
from __future__ import absolute_import, print_function, unicode_literals
# core django imports
from django.views.generic import DetailView, ListView
# third party imports
......@@ -38,7 +38,7 @@ class DetailBuilding(LoginRequiredMixin, 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()
building = Building.objects.get(name=building_name)
return building
......@@ -57,7 +57,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]
building = Building.objects.get(name=building_name)
......@@ -83,7 +83,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