from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
	user = models.OneToOneField(User)
	is_tf = models.BooleanField(default=False)
	role = models.CharField(max_length=8, default="user")

# This bit of code is copy-pasted from a previous project.
# Not sure what it does ¯\_(ツ)_/¯
# Might be useful/required though
# User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])

# catch user creation
#def create_user_profile(sender, instance, created, **kwargs):
#    if created:
#        UserProfile.objects.create(user=instance)
#
#post_save.connect(create_user_profile, sender=User)
#

class Guild(models.Model):
	name = models.CharField(max_length=64)
	abbreviation = models.CharField(max_length=8)

	def __str__(self):
	    return u'{0}'.format(self.name)

class Event(models.Model):
	name = models.TextField()
	description = models.TextField()
	slug = models.SlugField()
	created_at = models.DateTimeField(auto_now_add=True)
	points = models.IntegerField()
	guild = models.ForeignKey('Guild', on_delete=models.CASCADE)

class Attendance(models.Model):
	created = models.DateTimeField(auto_now_add=True)
	modified = models.DateTimeField()
	event = models.ForeignKey('Event', on_delete=models.CASCADE)
	user = models.ForeignKey(User, on_delete=models.CASCADE)




@@ -70,83 +70,358 @@
 ser%0A
-%0Aclass UserProfile(models.Model):%0A%09user = models.OneToOneField(U
+from django.db.models.signals import post_save%0Afrom django.contrib.auth.models import AbstractBaseUser, PermissionsMixin%0Afrom django.contrib.auth.models import BaseUserManager%0A%0Aclass User(models.Model):%0A    email = models.EmailField(unique=True)%0A    real_name = models.CharField(max_length=50)%0A    is_tf = models.BooleanField(default=Fal
 se
-r
 )%0A
-%09is_tf
+    is_kv
  = m
@@ -454,17 +454,20 @@
 =False)%0A
-%09
+    
 role = m
@@ -930,18 +930,16 @@
 er=User)
-%0A#
 %0A%0Aclass 
@@ -951,33 +951,36 @@
 (models.Model):%0A
-%09
+    
 name = models.Ch
@@ -1002,17 +1002,20 @@
 gth=64)%0A
-%09
+    
 abbrevia
@@ -1138,17 +1138,20 @@
 Model):%0A
-%09
+    
 name = m
@@ -1168,17 +1168,20 @@
 Field()%0A
-%09
+    
 descript
@@ -1209,36 +1209,12 @@
 d()%0A
-%09slug = models.SlugField()%0A%09
+    
 crea
@@ -1262,17 +1262,20 @@
 d=True)%0A
-%09
+    
 points =
@@ -1297,17 +1297,65 @@
 Field()%0A
-%09
+    repeats = models.IntegerField(default=1)%0A    
 guild = 
@@ -1440,17 +1440,20 @@
 Model):%0A
-%09
+    
 created 
@@ -1494,17 +1494,20 @@
 d=True)%0A
-%09
+    
 modified
@@ -1532,17 +1532,20 @@
 Field()%0A
-%09
+    
 event = 
@@ -1597,17 +1597,20 @@
 ASCADE)%0A
-%09
+    
 user = m
@@ -1658,11 +1658,8 @@
 ASCADE)%0A
-%0A%0A%0A

update models