Commit e837676f authored by David Haynes's avatar David Haynes
Browse files

associate a registereduser with every user on creation (Closes #7)

- registered users now have a one to one relationship to their user
- nice comments added as well
parent 79441961
......@@ -3,15 +3,15 @@ from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
from django.core.cache import cache
from django.db.models.signals import post_save
from django.dispatch import receiver
# Other Imports
import string
from hashids import Hashids
hashids = Hashids(salt="", alphabet=(string.ascii_lowercase + string.digits))
class URL(models.Model):
This model represents a stored URL redirection rule. Each URL has an
......@@ -59,27 +59,38 @@ class RegisteredUser(models.Model):
that that user is registered.
user = models.OneToOneField(
# Let's associate a User to this RegisteredUser
user = models.OneToOneField(User)
# What is your name?
full_name = models.CharField(
# What organization are you associated with?
organization = models.CharField(
# Why do you want to use Go?
description = models.TextField(blank=True)
approved = models.BooleanField(default=False)
# Have you filled out the registration form?
registered = models.BooleanField(default=False)
# Are you approved to use Go?
approved = models.BooleanField(default=False)
# print(RegisteredUser)
def __unicode__(self):
return '<Registered User: %s - Approval Status: %s>' % (self.username, self.approved)
return '<Registered User: %s - Approval Status: %s>' % (self.user, self.approved)
# When a post_save is called on a User object (and it is newly created), this is
# called to create an associated RegisteredUser
@receiver(post_save, sender=User)
def handle_regUser_creation(sender, instance, created, **kwargs):
if created:
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