Minor code restructuring
This commit is contained in:
parent
75bcc91037
commit
af14cce3f8
@ -20,6 +20,30 @@ from taggit.managers import TaggableManager
|
|||||||
|
|
||||||
# Create your models here.
|
# 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):
|
class Taggable(models.Model):
|
||||||
'''
|
'''
|
||||||
This abstract model represtens an object that is taggalble
|
This abstract model represtens an object that is taggalble
|
||||||
@ -69,31 +93,6 @@ class Submittable(models.Model):
|
|||||||
related_name='%(class)s'
|
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):
|
class Voucher(models.Model):
|
||||||
"""
|
"""
|
||||||
Vouchers are authorization tokens to allow the registration of new users.
|
Vouchers are authorization tokens to allow the registration of new users.
|
||||||
|
Loading…
Reference in New Issue
Block a user