2018-01-14 12:19:11 +00:00
|
|
|
from django.db import models
|
2018-01-30 18:54:01 +00:00
|
|
|
from django.urls import reverse
|
2018-01-14 18:05:53 +00:00
|
|
|
from django.contrib.auth.models import Group
|
2018-01-14 12:19:11 +00:00
|
|
|
|
2018-01-14 18:05:53 +00:00
|
|
|
|
|
|
|
class Category(models.Model):
|
2018-01-22 13:03:25 +00:00
|
|
|
"""Une catégorie de contenu."""
|
2018-01-14 18:05:53 +00:00
|
|
|
name = models.CharField(
|
|
|
|
max_length=255,
|
2018-01-24 10:44:54 +00:00
|
|
|
verbose_name="Nom de la catégorie"
|
2018-01-14 18:05:53 +00:00
|
|
|
)
|
2018-01-30 18:54:01 +00:00
|
|
|
def get_absolute_url(self):
|
|
|
|
return reverse('content:category-list', kwargs={'category_id':self.id})
|
2018-01-14 18:05:53 +00:00
|
|
|
|
2018-01-30 21:56:30 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2018-01-14 18:05:53 +00:00
|
|
|
|
|
|
|
class Content(models.Model):
|
2018-01-22 13:03:25 +00:00
|
|
|
"""Un contenu du site (vidéo)."""
|
2018-01-14 18:05:53 +00:00
|
|
|
name = models.CharField(
|
|
|
|
max_length=255,
|
2018-01-24 10:33:05 +00:00
|
|
|
verbose_name="Nom du contenu"
|
2018-01-14 18:05:53 +00:00
|
|
|
)
|
|
|
|
group_owner = models.ForeignKey(
|
|
|
|
Group,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
)
|
|
|
|
content_url = models.URLField(
|
2018-01-24 10:33:05 +00:00
|
|
|
verbose_name='URL du contenu',
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
category = models.ForeignKey(
|
|
|
|
Category,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
verbose_name="Catégorie",
|
|
|
|
null=True
|
2018-01-14 18:05:53 +00:00
|
|
|
)
|
2018-01-30 21:56:30 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|