2023-10-21 15:18:07 +02:00
|
|
|
from django.db import models
|
2023-11-10 10:05:53 +01:00
|
|
|
from django.contrib.auth.models import User
|
2023-10-21 15:18:07 +02:00
|
|
|
|
2023-11-10 10:05:53 +01:00
|
|
|
from django.db.models.signals import post_save
|
|
|
|
from django.dispatch import receiver
|
|
|
|
|
|
|
|
|
|
|
|
from sites.furaffinity.models import FA_Submission
|
|
|
|
|
|
|
|
class UserProfile(models.Model):
|
|
|
|
|
|
|
|
MATURE = [
|
|
|
|
("H", "Hide"),
|
|
|
|
("B", "Blur"),
|
|
|
|
("S", "Show"),
|
|
|
|
]
|
|
|
|
|
|
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True, unique=True)
|
|
|
|
show_mature = models.CharField(max_length=2, choices=MATURE, default=MATURE[0][0])
|
|
|
|
|
|
|
|
|
|
|
|
class SeenPost(models.Model):
|
|
|
|
user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
|
|
|
|
post = models.ForeignKey(FA_Submission, on_delete=models.CASCADE)
|
|
|
|
timestamp = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
|
|
|
|
#receiver(post_save, sender=User)
|
|
|
|
#def create_user_profile(sender, instance, created, **kwargs):
|
|
|
|
# if created:
|
|
|
|
# UserProfile.objects.create(user=instance)
|
|
|
|
|
|
|
|
#@receiver(post_save, sender=User)
|
|
|
|
#def save_user_profile(sender, instance, **kwargs):
|
|
|
|
# instance.user.save()
|
|
|
|
|
|
|
|
|