<s> from django . conf import settings <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . db import models <EOL> from jsonfield import JSONField <EOL> from openslides . mediafiles . models import Mediafile <EOL> from openslides . utils . models import RESTModelMixin <EOL> from openslides . utils . projector import ProjectorElement <EOL> from . access_permissions import ( <EOL> ChatMessageAccessPermissions , <EOL> ConfigAccessPermissions , <EOL> CustomSlideAccessPermissions , <EOL> ProjectorAccessPermissions , <EOL> TagAccessPermissions , <EOL> ) <EOL> from . exceptions import ProjectorException <EOL> class Projector ( RESTModelMixin , models . Model ) : <EOL> """<STR_LIT>""" <EOL> access_permissions = ProjectorAccessPermissions ( ) <EOL> config = JSONField ( ) <EOL> scale = models . IntegerField ( default = <NUM_LIT:0> ) <EOL> scroll = models . IntegerField ( default = <NUM_LIT:0> ) <EOL> class Meta : <EOL> """<STR_LIT>""" <EOL> default_permissions = ( ) <EOL> permissions = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> @ property <EOL> def elements ( self ) : <EOL> """<STR_LIT>""" <EOL> elements = { } <EOL> for element in ProjectorElement . get_all ( ) : <EOL> elements [ element . name ] = element <EOL> result = { } <EOL> for key , value in self . config . items ( ) : <EOL> result [ key ] = value . copy ( ) <EOL> result [ key ] [ '<STR_LIT>' ] = key <EOL> element = elements . get ( value [ '<STR_LIT:name>' ] ) <EOL> if element is None : <EOL> result [ key ] [ '<STR_LIT:error>' ] = '<STR_LIT>' <EOL> else : <EOL> try : <EOL> result [ key ] . update ( element . check_and_update_data ( <EOL> projector_object = self , <EOL> config_entry = value ) ) <EOL> except ProjectorException as e : <EOL> result [ key ] [ '<STR_LIT:error>' ] = str ( e ) <EOL> return result <EOL> @ classmethod <EOL> def get_all_requirements ( cls ) : <EOL> """<STR_LIT>""" <EOL> elements = { } <EOL> for element in ProjectorElement . get_all ( ) : <EOL> elements [ element . name ] = element <EOL> for projector in cls . objects . all ( ) : <EOL> for key , value in projector . config . items ( ) : <EOL> element = elements . get ( value [ '<STR_LIT:name>' ] ) <EOL> if element is not None : <EOL> for requirement in element . get_requirements ( value ) : <EOL> yield requirement <EOL> class CustomSlide ( RESTModelMixin , models . Model ) : <EOL> """<STR_LIT>""" <EOL> access_permissions = CustomSlideAccessPermissions ( ) <EOL> title = models . CharField ( <EOL> max_length = <NUM_LIT> ) <EOL> text = models . TextField ( <EOL> blank = True ) <EOL> weight = models . IntegerField ( <EOL> default = <NUM_LIT:0> ) <EOL> attachments = models . ManyToManyField ( <EOL> Mediafile , <EOL> blank = True ) <EOL> class Meta : <EOL> default_permissions = ( ) <EOL> ordering = ( '<STR_LIT>' , '<STR_LIT:title>' , ) <EOL> def __str__ ( self ) : <EOL> return self . title <EOL> @ property <EOL> def agenda_item ( self ) : <EOL> """<STR_LIT>""" <EOL> from openslides . agenda . models import Item <EOL> content_type = ContentType . objects . get_for_model ( self ) <EOL> return Item . objects . get ( object_id = self . pk , content_type = content_type ) <EOL> @ property <EOL> def agenda_item_id ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . agenda_item . pk <EOL> def get_agenda_title ( self ) : <EOL> return self . title <EOL> def get_agenda_list_view_title ( self ) : <EOL> return self . title <EOL> def get_search_index_string ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT:U+0020>" . join ( ( <EOL> self . title , <EOL> self . text ) ) <EOL> class Tag ( RESTModelMixin , models . Model ) : <EOL> """<STR_LIT>""" <EOL> access_permissions = TagAccessPermissions ( ) <EOL> name = models . CharField ( <EOL> max_length = <NUM_LIT:255> , <EOL> unique = True ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> default_permissions = ( ) <EOL> permissions = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class ConfigStore ( RESTModelMixin , models . Model ) : <EOL> """<STR_LIT>""" <EOL> access_permissions = ConfigAccessPermissions ( ) <EOL> key = models . CharField ( max_length = <NUM_LIT:255> , unique = True , db_index = True ) <EOL> """<STR_LIT>""" <EOL> value = JSONField ( ) <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> default_permissions = ( ) <EOL> permissions = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> @ classmethod <EOL> def get_collection_string ( cls ) : <EOL> return '<STR_LIT>' <EOL> def get_rest_pk ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . key <EOL> class ChatMessage ( RESTModelMixin , models . Model ) : <EOL> """<STR_LIT>""" <EOL> access_permissions = ChatMessageAccessPermissions ( ) <EOL> message = models . TextField ( ) <EOL> timestamp = models . DateTimeField ( auto_now_add = True ) <EOL> user = models . ForeignKey ( <EOL> settings . AUTH_USER_MODEL , <EOL> on_delete = models . CASCADE ) <EOL> class Meta : <EOL> default_permissions = ( ) <EOL> permissions = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' . format ( self . timestamp ) </s>
