OpenSlides/openslides/mediafiles/projector.py
2017-09-05 22:46:13 +02:00

30 lines
861 B
Python

from typing import Generator, Type
from ..core.exceptions import ProjectorException
from ..utils.projector import ProjectorElement
from .models import Mediafile
class MediafileSlide(ProjectorElement):
"""
Slide definitions for Mediafile model.
"""
name = 'mediafiles/mediafile'
def check_data(self):
if not Mediafile.objects.filter(pk=self.config_entry.get('id')).exists():
raise ProjectorException('File does not exist.')
def get_requirements(self, config_entry):
try:
mediafile = Mediafile.objects.get(pk=config_entry.get('id'))
except Mediafile.DoesNotExist:
# Mediafile does not exist. Just do nothing.
pass
else:
yield mediafile
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
yield MediafileSlide