Minor code restructuring

This commit is contained in:
reverend 2020-09-13 15:49:15 +02:00
parent 75bcc91037
commit af14cce3f8

View File

@ -20,6 +20,30 @@ from taggit.managers import TaggableManager
# Create your models here.
class Explorer(models.Model):
"""
Profile that is linked to the a User.
Every user has a profile.
"""
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
related_name='explorer'
)
def __str__(self):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Explorer.objects.create(user=instance)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.explorer.save()
class Taggable(models.Model):
'''
This abstract model represtens an object that is taggalble
@ -69,31 +93,6 @@ class Submittable(models.Model):
related_name='%(class)s'
)
class Explorer(models.Model):
"""
Profile that is linked to the a User.
Every user has a profile.
"""
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
related_name='explorer'
)
def __str__(self):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Explorer.objects.create(user=instance)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.explorer.save()
class Voucher(models.Model):
"""
Vouchers are authorization tokens to allow the registration of new users.