40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
from django.core.validators import MinValueValidator, MaxValueValidator
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
|
|
class Ticket(models.Model):
|
|
# Your Ticket model definition goes here
|
|
title = models.CharField("Titre", max_length=100)
|
|
topic = models.CharField(max_length=100)
|
|
body = models.CharField("Description", max_length=8192)
|
|
user = models.ForeignKey(
|
|
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
|
image = models.ImageField(upload_to="uploads/")
|
|
time_created = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
class Review(models.Model):
|
|
ticket = models.ForeignKey(to=Ticket, on_delete=models.CASCADE)
|
|
rating = models.PositiveSmallIntegerField(
|
|
# validates that rating must be between 0 and 5
|
|
validators=[MinValueValidator(0), MaxValueValidator(5)])
|
|
headline = models.CharField(max_length=128)
|
|
body = models.CharField(max_length=8192, blank=True)
|
|
user = models.ForeignKey(
|
|
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
|
time_created = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
class UserFollows(models.Model):
|
|
# Your UserFollows model definition goes here
|
|
user = models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
# ensures we don't get multiple UserFollows instances
|
|
# for unique user-user_followed pairs
|
|
pass
|
|
#unique_together = ('user', 'followed_user', )
|
|
|