Commit 02c26f85 authored by David Haynes's avatar David Haynes
Browse files

Modify print functions for models to be python3 compatabile

- unicode() --> str()
parent 8b1a8f77
...@@ -8,11 +8,11 @@ from django.utils import timezone ...@@ -8,11 +8,11 @@ from django.utils import timezone
from django.core.cache import cache from django.core.cache import cache
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.encoding import python_2_unicode_compatible
# Other Imports # Other Imports
from hashids import Hashids # http://hashids.org/python/
import string import string
# http://hashids.org/python/
from hashids import Hashids
# generate the salt and initialize Hashids # generate the salt and initialize Hashids
hashids = Hashids(salt="srct.gmu.edu", alphabet=(string.ascii_lowercase + string.digits)) hashids = Hashids(salt="srct.gmu.edu", alphabet=(string.ascii_lowercase + string.digits))
...@@ -21,37 +21,38 @@ hashids = Hashids(salt="srct.gmu.edu", alphabet=(string.ascii_lowercase + string ...@@ -21,37 +21,38 @@ hashids = Hashids(salt="srct.gmu.edu", alphabet=(string.ascii_lowercase + string
This is simply a wrapper model for the user object which, if an object This is simply a wrapper model for the user object which, if an object
exists, indicates that that user is registered. exists, indicates that that user is registered.
""" """
@python_2_unicode_compatible
class RegisteredUser(models.Model): class RegisteredUser(models.Model):
# Is this User Blocked? # Is this User Blocked?
blocked = models.BooleanField(default=False) blocked = models.BooleanField(default = False)
# Let's associate a User to this RegisteredUser # Let's associate a User to this RegisteredUser
user = models.OneToOneField(User) user = models.OneToOneField(User)
# What is your name? # What is your name?
full_name = models.CharField( full_name = models.CharField(
blank=False, blank = False,
max_length=100, max_length = 100,
) )
# What organization are you associated with? # What organization are you associated with?
organization = models.CharField( organization = models.CharField(
blank=False, blank = False,
max_length=100, max_length = 100,
) )
# Why do you want to use Go? # Why do you want to use Go?
description = models.TextField(blank=True) description = models.TextField(blank = True)
# Have you filled out the registration form? # Have you filled out the registration form?
registered = models.BooleanField(default=False) registered = models.BooleanField(default = False)
# Are you approved to use Go? # Are you approved to use Go?
approved = models.BooleanField(default=False) approved = models.BooleanField(default = False)
# print(RegisteredUser) # print(RegisteredUser)
def __unicode__(self): def __str__(self):
return '<Registered User: %s - Approval Status: %s>' % (self.user, self.approved) return '<Registered User: %s - Approval Status: %s>' % (self.user, self.approved)
...@@ -68,6 +69,7 @@ def handle_regUser_creation(sender, instance, created, **kwargs): ...@@ -68,6 +69,7 @@ def handle_regUser_creation(sender, instance, created, **kwargs):
owner, target url, short identifier, click counter, and expiration owner, target url, short identifier, click counter, and expiration
date. date.
""" """
@python_2_unicode_compatible
class URL(models.Model): class URL(models.Model):
# Who is the owner of this Go link # Who is the owner of this Go link
...@@ -91,7 +93,7 @@ class URL(models.Model): ...@@ -91,7 +93,7 @@ class URL(models.Model):
expires = models.DateTimeField(blank=True, null=True) expires = models.DateTimeField(blank=True, null=True)
# print(URL) # print(URL)
def __unicode__(self): def __str__(self):
return '<%s : %s>' % (self.owner.user, self.target) return '<%s : %s>' % (self.owner.user, self.target)
# metadata for URL's # metadata for URL's
...@@ -113,6 +115,6 @@ class URL(models.Model): ...@@ -113,6 +115,6 @@ class URL(models.Model):
URL.objects.get(short__iexact=short) URL.objects.get(short__iexact=short)
tries += 1 tries += 1
cache.incr("hashids_counter") cache.incr("hashids_counter")
except URL.DoesNotExist: except URL.DoesNotExist as ex:
return short return short
return None return None
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