Commit 55d8ef33 authored by fred's avatar fred

add context support for soundfiles

parent 869e7e35
......@@ -4,7 +4,7 @@ from django.contrib.auth.models import AbstractUser
from django.core import validators
from django.db import models
from emissions.models import Emission, Episode, NewsItem, NewsCategory
from emissions.models import Emission, Episode, NewsItem, NewsCategory, SoundFile
class User(AbstractUser):
emissions = models.ManyToManyField(Emission, null=True, blank=True)
......@@ -17,6 +17,8 @@ class User(AbstractUser):
return object in self.emissions.all()
if isinstance(object, Episode):
return object.emission in self.emissions.all()
if isinstance(object, SoundFile):
return object.episode.emission in self.emissions.all()
if isinstance(object, NewsItem):
return object.emission in self.emissions.all()
return False
......@@ -23,6 +23,8 @@ def context_url(object):
return reverse('emission-view', kwargs={'slug': object.emission.slug})
if isinstance(object, Episode):
return reverse('emission-view', kwargs={'slug': object.emission.slug})
if isinstance(object, SoundFile):
return reverse('emission-view', kwargs={'slug': object.episode.emission.slug})
return None
......@@ -32,6 +34,8 @@ def context_title(object):
return object.emission.title
if isinstance(object, Episode):
return object.emission.title
if isinstance(object, SoundFile):
return object.episode.emission.title
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment