site_tps/content/models.py

42 lines
983 B
Python
Raw Normal View History

2018-01-14 12:19:11 +00:00
from django.db import models
from django.urls import reverse
from django.contrib.auth.models import Group
2018-01-14 12:19:11 +00:00
class Category(models.Model):
"""Une catégorie de contenu."""
name = models.CharField(
max_length=255,
2018-01-24 10:44:54 +00:00
verbose_name="Nom de la catégorie"
)
def get_absolute_url(self):
2018-01-30 22:07:08 +00:00
return reverse('content:category-list', kwargs={'pk':self.pk})
2018-01-30 21:56:30 +00:00
def __str__(self):
return self.name
class Content(models.Model):
"""Un contenu du site (vidéo)."""
name = models.CharField(
max_length=255,
2018-01-24 10:33:05 +00:00
verbose_name="Nom du contenu"
)
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-30 21:56:30 +00:00
def __str__(self):
return self.name