50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from django.db import models
|
|
from django.urls import reverse
|
|
from django.contrib.auth.models import Group
|
|
from django.conf import settings
|
|
|
|
from users.models import SchoolProfile
|
|
|
|
class Category(models.Model):
|
|
"""Une catégorie de contenu."""
|
|
name = models.CharField(
|
|
max_length=255,
|
|
verbose_name="Nom de la catégorie"
|
|
)
|
|
description = models.TextField(
|
|
verbose_name="Descriton de la catégorie",
|
|
default=""
|
|
)
|
|
image = models.ImageField(
|
|
verbose_name="Illustration de la catégorie",
|
|
null=True,
|
|
)
|
|
def get_absolute_url(self):
|
|
return reverse('content:category-list', kwargs={'pk':self.pk})
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class Content(models.Model):
|
|
"""Un contenu du site (vidéo)."""
|
|
name = models.CharField(
|
|
max_length=255,
|
|
verbose_name="Nom du contenu"
|
|
)
|
|
school_owner = models.ForeignKey(
|
|
SchoolProfile,
|
|
on_delete=models.CASCADE,
|
|
)
|
|
category = models.ForeignKey(
|
|
Category,
|
|
on_delete=models.SET_NULL,
|
|
verbose_name="Catégorie",
|
|
null=True
|
|
)
|
|
file = models.FileField(
|
|
verbose_name="Fichier"
|
|
)
|
|
|
|
def __str__(self):
|
|
return self.name
|