2017-08-30 00:07:54 +02:00
|
|
|
from typing import Generator, Type
|
|
|
|
|
2015-09-16 00:55:27 +02:00
|
|
|
from ..core.exceptions import ProjectorException
|
2016-09-17 22:26:23 +02:00
|
|
|
from ..utils.projector import ProjectorElement
|
2015-02-18 01:45:39 +01:00
|
|
|
from .models import User
|
|
|
|
|
|
|
|
|
|
|
|
class UserSlide(ProjectorElement):
|
|
|
|
"""
|
2016-09-17 22:26:23 +02:00
|
|
|
Slide definitions for User model.
|
2015-02-18 01:45:39 +01:00
|
|
|
"""
|
|
|
|
name = 'users/user'
|
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2015-09-08 14:14:11 +02:00
|
|
|
if not User.objects.filter(pk=self.config_entry.get('id')).exists():
|
2015-11-21 00:00:31 +01:00
|
|
|
raise ProjectorException('User does not exist.')
|
2015-06-12 21:08:57 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2016-09-17 22:26:23 +02:00
|
|
|
try:
|
|
|
|
user = User.objects.get(pk=config_entry.get('id'))
|
|
|
|
except User.DoesNotExist:
|
|
|
|
# User does not exist. Just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
yield user
|
2017-08-30 00:07:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
|
|
|
|
yield UserSlide
|