25 lines
908 B
Python
25 lines
908 B
Python
from django.conf import settings
|
|
from django.db import models
|
|
|
|
|
|
class DailyCheckIn(models.Model):
|
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="checkins")
|
|
date = models.DateField()
|
|
streak = models.PositiveIntegerField(default=1)
|
|
reward = models.JSONField(default=dict)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
constraints = [
|
|
models.UniqueConstraint(fields=("user", "date"), name="unique_user_daily_checkin")
|
|
]
|
|
|
|
|
|
class Notification(models.Model):
|
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="notifications")
|
|
category = models.CharField(max_length=40)
|
|
title = models.CharField(max_length=120)
|
|
body = models.TextField()
|
|
is_read = models.BooleanField(default=False)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|