2016-09-17 22:26:23 +02:00
|
|
|
from ..core.exceptions import ProjectorException
|
|
|
|
from ..utils.projector import ProjectorElement
|
2015-06-25 20:36:46 +02:00
|
|
|
from .models import Mediafile
|
|
|
|
|
|
|
|
|
|
|
|
class MediafileSlide(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Slide definitions for Mediafile model.
|
|
|
|
"""
|
|
|
|
name = 'mediafiles/mediafile'
|
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2016-09-17 22:26:23 +02:00
|
|
|
if not Mediafile.objects.filter(pk=self.config_entry.get('id')).exists():
|
2015-11-21 00:00:31 +01:00
|
|
|
raise ProjectorException('File does not exist.')
|
2015-06-25 20:36:46 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2016-09-17 22:26:23 +02:00
|
|
|
try:
|
|
|
|
mediafile = Mediafile.objects.get(pk=config_entry.get('id'))
|
|
|
|
except Mediafile.DoesNotExist:
|
|
|
|
# Mediafile does not exist. Just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
yield mediafile
|