reverend
5f304b91f3
commit 0d62e72d72922a84e41c9f2cc21977b794784d1c Merge: 79fee6385f2a81
Author: reverend <reverend@reverend2048.de> Date: Tue Sep 22 21:55:18 2020 +0200 Merge branch 'develop' into refactor/models commit 79fee631d7ac28509067ecdd74078f1a2f6e0be2 Author: reverend <reverend@reverend2048.de> Date: Tue Sep 22 21:54:32 2020 +0200 Updating references for related name commit 8e07e79df2de2601f2e2eadfdd37eb7c719c51b0 Author: reverend <reverend@reverend2048.de> Date: Tue Sep 22 21:53:31 2020 +0200 Generating of related names fix commit 5fd804f37a805ae4707e13c3d941bdde3660afea Merge: 8cc1d3e3b526c9
Author: reverend <reverend@reverend2048.de> Date: Tue Sep 22 21:01:48 2020 +0200 Merge branch 'develop' into refactor/models commit 8cc1d3e690211dba6451e86569f00078b23e0621 Author: reverend <reverend@reverend2048.de> Date: Tue Sep 22 20:21:08 2020 +0200 Tests commit 7c0591e5397f892b1f6fb80725a693c21f90468a Author: reverend <reverend@reverend2048.de> Date: Fri Sep 18 23:53:39 2020 +0200 Testing PlaceAsset commit 2e7b49ad1a15173565c81e7eb8bb3f35b9f622a6 Author: reverend <reverend@reverend2048.de> Date: Fri Sep 18 22:25:08 2020 +0200 Restructuring models commit eb7d03b08b326f9115e70d0fd9ed5d0fc229a362 Author: reverend <reverend@reverend2048.de> Date: Fri Sep 18 22:01:54 2020 +0200 Abstract class Expireable commit 2b51e741bb5734c5a578beeadef7819fe58b2223 Author: reverend <reverend@reverend2048.de> Date: Fri Sep 18 21:54:07 2020 +0200 Abstract Model for PlaceAsset (i.e. Photoalbums)
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
(Data)models which describe the structure of data to be saved into
|
|
database.
|
|
'''
|
|
|
|
import uuid
|
|
|
|
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
|
|
from lostplaces.models.abstract_models import Expireable
|
|
|
|
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(Expireable):
|
|
"""
|
|
Vouchers are authorization to created_when = models.DateTimeField(auto_now_add=True)
|
|
expires_when = models.DateTimeField()kens to allow the registration of new users.
|
|
A voucher has a code, a creation and a deletion date, which are all
|
|
positional. Creation date is being set automatically during voucher
|
|
creation.
|
|
"""
|
|
|
|
code = models.CharField(unique=True, max_length=30)
|
|
|
|
def __str__(self):
|
|
return "Voucher " + str(self.code)
|
|
|