Unverified Commit 45e9d702 authored by David Haynes's avatar David Haynes
Browse files

PEP8 compliance for URL model

- Plus __str__ now prints like registereduser does
parent 8d88d8e1
# Future Imports
from __future__ import unicode_literals, absolute_import, print_function, division
# Python stdlib Imports
import string
# Django Imports
from django.db import models
from django.contrib.auth.models import User
......@@ -12,7 +15,6 @@ from django.utils.encoding import python_2_unicode_compatible
# Other Imports
from hashids import Hashids # http://hashids.org/python/
import string
# generate the salt and initialize Hashids
hashids = Hashids(salt="srct.gmu.edu", alphabet=(string.ascii_lowercase + string.digits))
......@@ -24,9 +26,6 @@ class RegisteredUser(models.Model):
exists, indicates that that user is registered.
"""
# Is this User Blocked?
blocked = models.BooleanField(default=False)
# Let's associate a User to this RegisteredUser
user = models.OneToOneField(User)
......@@ -51,7 +50,10 @@ class RegisteredUser(models.Model):
# Are you approved to use Go?
approved = models.BooleanField(default=False)
# print(RegisteredUser)
# Is this User Blocked?
blocked = models.BooleanField(default=False)
# str(RegisteredUser)
def __str__(self):
return '<Registered User: %s - Approval Status: %s>' % (self.user, self.approved)
......@@ -64,37 +66,37 @@ def handle_regUser_creation(sender, instance, created, **kwargs):
RegisteredUser.objects.create(user=instance)
"""
This model represents a stored URL redirection rule. Each URL has an
owner, target url, short identifier, click counter, and expiration
date.
"""
@python_2_unicode_compatible
class URL(models.Model):
"""
This model represents a stored URL redirection rule. Each URL has an
owner, target url, short identifier, click counter, and expiration
date.
"""
# Who is the owner of this Go link
owner = models.ForeignKey(RegisteredUser)
# When was this link created?
date_created = models.DateTimeField(default = timezone.now)
date_created = models.DateTimeField(default=timezone.now)
# What is the target URL for this Go link
target = models.URLField(max_length = 1000)
target = models.URLField(max_length=1000)
# What is the actual go link (short url) for this URL
short = models.SlugField(max_length = 20, primary_key = True)
short = models.SlugField(max_length=20, primary_key=True)
# how many people have visited this Go link
clicks = models.IntegerField(default = 0)
clicks = models.IntegerField(default=0)
# how many people have visited this Go link through the qr code
qrclicks = models.IntegerField(default = 0)
qrclicks = models.IntegerField(default=0)
# how many people have visited the go link through social media
socialclicks = models.IntegerField(default = 0)
socialclicks = models.IntegerField(default=0)
# does this Go link expire on a certain date
expires = models.DateTimeField(blank = True, null = True)
expires = models.DateTimeField(blank=True, null=True)
# print(URL)
def __str__(self):
return '<%s : %s>' % (self.owner.user, self.target)
return '<Owner: %s - Target URL: %s>' % (self.owner.user, self.target)
# metadata for URL's
class Meta:
......
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