Fixed projector.
This commit is contained in:
parent
4d14a1297d
commit
8c48d67df0
@ -18,7 +18,7 @@ script:
|
|||||||
- "isort --check-only --recursive openslides tests"
|
- "isort --check-only --recursive openslides tests"
|
||||||
|
|
||||||
- "DJANGO_SETTINGS_MODULE='tests.settings' coverage run ./manage.py test tests.unit"
|
- "DJANGO_SETTINGS_MODULE='tests.settings' coverage run ./manage.py test tests.unit"
|
||||||
- "coverage report --fail-under=42"
|
- "coverage report --fail-under=43"
|
||||||
|
|
||||||
- "DJANGO_SETTINGS_MODULE='tests.settings' coverage run ./manage.py test tests.integration"
|
- "DJANGO_SETTINGS_MODULE='tests.settings' coverage run ./manage.py test tests.integration"
|
||||||
- "coverage report --fail-under=50"
|
- "coverage report --fail-under=50"
|
||||||
|
@ -23,15 +23,10 @@ class ItemListSlide(ProjectorElement):
|
|||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
pk = self.config_entry.get('id')
|
||||||
if pk is None:
|
if pk is not None:
|
||||||
# Root list slide.
|
|
||||||
context = {'tree': self.config_entry.get('tree', False)}
|
|
||||||
else:
|
|
||||||
# Children slide.
|
# Children slide.
|
||||||
if not Item.objects.filter(pk=pk).exists():
|
if not Item.objects.filter(pk=pk).exists():
|
||||||
raise ProjectorException(_('Item does not exist.'))
|
raise ProjectorException(_('Item does not exist.'))
|
||||||
context = {'id': pk, 'tree': self.config_entry.get('tree', False)}
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id', 'tree')
|
pk = config_entry.get('id', 'tree')
|
||||||
@ -65,7 +60,6 @@ class ItemDetailSlide(ProjectorElement):
|
|||||||
raise ProjectorException(_('Id must not be None.'))
|
raise ProjectorException(_('Id must not be None.'))
|
||||||
if not Item.objects.filter(pk=pk).exists():
|
if not Item.objects.filter(pk=pk).exists():
|
||||||
raise ProjectorException(_('Item does not exist.'))
|
raise ProjectorException(_('Item does not exist.'))
|
||||||
return {'id': pk, 'list_of_speakers': self.config_entry.get('list_of_speakers', False)}
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
@ -392,12 +392,12 @@ angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda'])
|
|||||||
// Attention! Each object that is used here has to be dealt on server side.
|
// Attention! Each object that is used here has to be dealt on server side.
|
||||||
// Add it to the coresponding get_requirements method of the ProjectorElement
|
// Add it to the coresponding get_requirements method of the ProjectorElement
|
||||||
// class.
|
// class.
|
||||||
var id = $scope.element.context.id;
|
var id = $scope.element.id;
|
||||||
Agenda.find(id);
|
Agenda.find(id);
|
||||||
User.findAll();
|
User.findAll();
|
||||||
Agenda.bindOne(id, $scope, 'item');
|
Agenda.bindOne(id, $scope, 'item');
|
||||||
// get flag for list-of-speakers-slide (true/false)
|
// get flag for list-of-speakers-slide (true/false)
|
||||||
$scope.is_list_of_speakers = $scope.element.context.list_of_speakers;
|
$scope.is_list_of_speakers = $scope.element.list_of_speakers;
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -18,15 +18,10 @@ class AssignmentSlide(ProjectorElement):
|
|||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
pk = self.config_entry.get('id')
|
||||||
if pk is None:
|
if pk is not None:
|
||||||
# List slide.
|
|
||||||
context = None
|
|
||||||
else:
|
|
||||||
# Detail slide.
|
# Detail slide.
|
||||||
if not Assignment.objects.filter(pk=pk).exists():
|
if not Assignment.objects.filter(pk=pk).exists():
|
||||||
raise ProjectorException(_('Assignment does not exist.'))
|
raise ProjectorException(_('Assignment does not exist.'))
|
||||||
context = {'id': pk}
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
@ -131,7 +131,7 @@ angular.module('OpenSlidesApp.assignments.projector', ['OpenSlidesApp.assignment
|
|||||||
// Attention! Each object that is used here has to be dealt on server side.
|
// Attention! Each object that is used here has to be dealt on server side.
|
||||||
// Add it to the coresponding get_requirements method of the ProjectorElement
|
// Add it to the coresponding get_requirements method of the ProjectorElement
|
||||||
// class.
|
// class.
|
||||||
var id = $scope.element.context.id;
|
var id = $scope.element.id;
|
||||||
Assignment.find(id);
|
Assignment.find(id);
|
||||||
Assignment.bindOne(id, $scope, 'assignment');
|
Assignment.bindOne(id, $scope, 'assignment');
|
||||||
});
|
});
|
||||||
|
@ -68,7 +68,8 @@ class Projector(RESTModelMixin, models.Model):
|
|||||||
# Parse result
|
# Parse result
|
||||||
result = {}
|
result = {}
|
||||||
for key, value in self.config.items():
|
for key, value in self.config.items():
|
||||||
result[key] = value
|
# Use a copy here not to change the origin value in the config field.
|
||||||
|
result[key] = value.copy()
|
||||||
element = elements.get(value['name'])
|
element = elements.get(value['name'])
|
||||||
if element is None:
|
if element is None:
|
||||||
result[key]['error'] = _('Projector element does not exist.')
|
result[key]['error'] = _('Projector element does not exist.')
|
||||||
|
@ -16,10 +16,8 @@ class CustomSlideSlide(ProjectorElement):
|
|||||||
name = 'core/customslide'
|
name = 'core/customslide'
|
||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
if not CustomSlide.objects.filter(pk=self.config_entry.get('id')).exists():
|
||||||
if not CustomSlide.objects.filter(pk=pk).exists():
|
|
||||||
raise ProjectorException(_('Custom slide does not exist.'))
|
raise ProjectorException(_('Custom slide does not exist.'))
|
||||||
return {'id': pk}
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
@ -9,30 +9,28 @@ class JSONSerializerField(Field):
|
|||||||
"""
|
"""
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
"""
|
"""
|
||||||
Checks that data is a list of dictionaries. Every dictionary must have
|
Checks that data is a dictionary. The key is a hex UUID and the
|
||||||
a key 'name'.
|
value is a dictionary with must have a key 'name'.
|
||||||
"""
|
"""
|
||||||
if type(data) is not list:
|
if type(data) is not dict:
|
||||||
raise ValidationError('Data must be a list of dictionaries.')
|
raise ValidationError('Data must be a dictionary.')
|
||||||
for element in data:
|
for element in data.values():
|
||||||
if type(element) is not dict:
|
if type(element) is not dict:
|
||||||
raise ValidationError('Data must be a list of dictionaries.')
|
raise ValidationError('Data must be a dictionary.')
|
||||||
elif element.get('name') is None:
|
elif element.get('name') is None:
|
||||||
raise ValidationError("Every dictionary must have a key 'name'.")
|
raise ValidationError("Every dictionary must have a key 'name'.")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def to_representation(self, value):
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
class ProjectorSerializer(ModelSerializer):
|
class ProjectorSerializer(ModelSerializer):
|
||||||
"""
|
"""
|
||||||
Serializer for core.models.Projector objects.
|
Serializer for core.models.Projector objects.
|
||||||
"""
|
"""
|
||||||
|
config = JSONSerializerField(write_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Projector
|
model = Projector
|
||||||
fields = ('id', 'elements', )
|
fields = ('id', 'config', 'elements', )
|
||||||
|
|
||||||
|
|
||||||
class CustomSlideSerializer(ModelSerializer):
|
class CustomSlideSerializer(ModelSerializer):
|
||||||
|
@ -765,7 +765,7 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core'])
|
|||||||
// Attention! Each object that is used here has to be dealt on server side.
|
// Attention! Each object that is used here has to be dealt on server side.
|
||||||
// Add it to the coresponding get_requirements method of the ProjectorElement
|
// Add it to the coresponding get_requirements method of the ProjectorElement
|
||||||
// class.
|
// class.
|
||||||
var id = $scope.element.context.id;
|
var id = $scope.element.id;
|
||||||
Customslide.find(id);
|
Customslide.find(id);
|
||||||
Customslide.bindOne(id, $scope, 'customslide');
|
Customslide.bindOne(id, $scope, 'customslide');
|
||||||
})
|
})
|
||||||
|
@ -18,15 +18,10 @@ class MotionSlide(ProjectorElement):
|
|||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
pk = self.config_entry.get('id')
|
||||||
if pk is None:
|
if pk is not None:
|
||||||
# List slide.
|
|
||||||
context = None
|
|
||||||
else:
|
|
||||||
# Detail slide.
|
# Detail slide.
|
||||||
if not Motion.objects.filter(pk=pk).exists():
|
if not Motion.objects.filter(pk=pk).exists():
|
||||||
raise ProjectorException(_('Motion does not exist.'))
|
raise ProjectorException(_('Motion does not exist.'))
|
||||||
context = {'id': pk}
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
@ -348,7 +348,7 @@ angular.module('OpenSlidesApp.motions.projector', ['OpenSlidesApp.motions'])
|
|||||||
// Attention! Each object that is used here has to be dealt on server side.
|
// Attention! Each object that is used here has to be dealt on server side.
|
||||||
// Add it to the coresponding get_requirements method of the ProjectorElement
|
// Add it to the coresponding get_requirements method of the ProjectorElement
|
||||||
// class.
|
// class.
|
||||||
var id = $scope.element.context.id;
|
var id = $scope.element.id;
|
||||||
Motion.find(id);
|
Motion.find(id);
|
||||||
Motion.bindOne(id, $scope, 'motion');
|
Motion.bindOne(id, $scope, 'motion');
|
||||||
});
|
});
|
||||||
|
@ -14,10 +14,8 @@ class UserSlide(ProjectorElement):
|
|||||||
name = 'users/user'
|
name = 'users/user'
|
||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
if not User.objects.filter(pk=self.config_entry.get('id')).exists():
|
||||||
if not User.objects.filter(pk=pk).exists():
|
|
||||||
raise ProjectorException(_('User does not exist.'))
|
raise ProjectorException(_('User does not exist.'))
|
||||||
return {'id': pk}
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
@ -547,7 +547,7 @@ angular.module('OpenSlidesApp.users.projector', ['OpenSlidesApp.users'])
|
|||||||
// Attention! Each object that is used here has to be dealt on server side.
|
// Attention! Each object that is used here has to be dealt on server side.
|
||||||
// Add it to the coresponding get_requirements method of the ProjectorElement
|
// Add it to the coresponding get_requirements method of the ProjectorElement
|
||||||
// class.
|
// class.
|
||||||
var id = $scope.element.context.id;
|
var id = $scope.element.id;
|
||||||
User.find(id);
|
User.find(id);
|
||||||
User.bindOne(id, $scope, 'user');
|
User.bindOne(id, $scope, 'user');
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ class ProjectorAPI(TestCase):
|
|||||||
'aae4a07b26534cfb9af4232f361dce73':
|
'aae4a07b26534cfb9af4232f361dce73':
|
||||||
{'id': customslide.id,
|
{'id': customslide.id,
|
||||||
'name': 'core/customslide',
|
'name': 'core/customslide',
|
||||||
'context': {'id': customslide.id}}}})
|
'context': None}}})
|
||||||
|
|
||||||
def test_invalid_slide_on_default_projector(self):
|
def test_invalid_slide_on_default_projector(self):
|
||||||
self.client.login(username='admin', password='admin')
|
self.client.login(username='admin', password='admin')
|
||||||
|
@ -86,8 +86,7 @@ class ProjectorAPI(TestCase):
|
|||||||
'test_key_mud1shoo8moh6eiXoong': 'test_value_shugieJier6agh1Ehie3'}]
|
'test_key_mud1shoo8moh6eiXoong': 'test_value_shugieJier6agh1Ehie3'}]
|
||||||
self.viewset.request = request
|
self.viewset.request = request
|
||||||
self.viewset.prune_elements(request=request, pk=MagicMock())
|
self.viewset.prune_elements(request=request, pk=MagicMock())
|
||||||
# TODO: Do not know how to test this.
|
self.assertEqual(len(mock_object.return_value.config), 2)
|
||||||
# self.assertEqual(len(mock_object.return_value.config), 2)
|
|
||||||
|
|
||||||
def test_update_elements(self, mock_object):
|
def test_update_elements(self, mock_object):
|
||||||
mock_object.return_value.config = {
|
mock_object.return_value.config = {
|
||||||
@ -170,8 +169,7 @@ class ProjectorAPI(TestCase):
|
|||||||
request = MagicMock()
|
request = MagicMock()
|
||||||
self.viewset.request = request
|
self.viewset.request = request
|
||||||
self.viewset.clear_elements(request=request, pk=MagicMock())
|
self.viewset.clear_elements(request=request, pk=MagicMock())
|
||||||
# TODO: Do not know how to test this.
|
self.assertEqual(len(mock_object.return_value.config), 0)
|
||||||
# self.assertEqual(len(mock_object.return_value.config), 0)
|
|
||||||
|
|
||||||
def test_clear_elements_with_stable(self, mock_object):
|
def test_clear_elements_with_stable(self, mock_object):
|
||||||
mock_object.return_value.config = {
|
mock_object.return_value.config = {
|
||||||
|
Loading…
Reference in New Issue
Block a user