From 2571d83195ea6ac8bccbc745d017b273a052a4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Wed, 22 Mar 2017 14:00:03 +0100 Subject: [PATCH] Use a whitelist for getFormOrStateForCurrentSlide (fixes #3112, fixed #3038). - Provided csv header fields as meta data while csv import (#3038). - Consolidate (already translated) strings for motion poll. - Fixed typos for MotionPoll model. --- openslides/core/static/js/core/base.js | 14 +++++++++----- openslides/core/static/js/core/site.js | 6 ++++++ openslides/motions/apps.py | 2 +- openslides/motions/static/js/motions/base.js | 4 ++-- openslides/motions/static/js/motions/site.js | 8 ++++---- .../static/templates/motions/motion-detail.html | 6 +++--- ...{motionpoll-form.html => motion-poll-form.html} | 0 openslides/motions/views.py | 2 +- 8 files changed, 26 insertions(+), 16 deletions(-) rename openslides/motions/static/templates/motions/{motionpoll-form.html => motion-poll-form.html} (100%) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 748ebdc49..fcc8ac647 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -819,11 +819,15 @@ angular.module('OpenSlidesApp.core', [ id: value.id, }; } else if ( - value.name != 'agenda/item-list' && - value.name != 'core/clock' && - value.name != 'core/countdown' && - value.name != 'core/projector-message' && - value.name != 'agenda/current-list-of-speakers' ) { + // TODO: + // Find generic solution for whitelist in getFormOrStateForCurrentSlide + // see https://github.com/OpenSlides/OpenSlides/issues/3130 + value.name === 'topics/topic' || + value.name === 'motions/motion' || + value.name === 'motions/motion-block' || + value.name === 'assignments/assignment' || + value.name === 'mediafiles/mediafile' || + value.name === 'users/user') { return_dict = { form: EditForm.fromCollectionString(value.name), id: value.id, diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index a42f46d07..7a91035b7 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -771,6 +771,12 @@ angular.module('OpenSlidesApp.core.site', [ encoding: $scope.encoding, header: false, // we do not want to have dicts in result complete: function (csv) { + if (csv.data.length) { + csv.meta.fields = csv.data[0]; + } + else { + csv.meta.fields = []; + } csv.data = csv.data.splice(1); // do not interpret the header as data $scope.$apply(function () { if (csv.meta.delimiter) { diff --git a/openslides/motions/apps.py b/openslides/motions/apps.py index 5a037e16b..45f904875 100644 --- a/openslides/motions/apps.py +++ b/openslides/motions/apps.py @@ -39,7 +39,7 @@ class MotionsAppConfig(AppConfig): router.register(self.get_model('Workflow').get_collection_string(), WorkflowViewSet) router.register(self.get_model('MotionChangeRecommendation').get_collection_string(), MotionChangeRecommendationViewSet) - router.register('motions/motionpoll', MotionPollViewSet) + router.register(self.get_model('MotionPoll').get_collection_string(), MotionPollViewSet) def get_startup_elements(self): """ diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 0d82c2dcf..b0e4af7cc 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -69,7 +69,7 @@ angular.module('OpenSlidesApp.motions', [ 'MajorityMethods', function (DS, gettextCatalog, Config, MajorityMethods) { return DS.defineResource({ - name: 'motions/motionpoll', + name: 'motions/motion-poll', relations: { belongsTo: { 'motions/motion': { @@ -629,7 +629,7 @@ angular.module('OpenSlidesApp.motions', [ localKeys: 'supporters_id', } ], - 'motions/motionpoll': { + 'motions/motion-poll': { localField: 'polls', foreignKey: 'motion_id', } diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 1d2d84084..0f238559f 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -588,7 +588,7 @@ angular.module('OpenSlidesApp.motions.site', [ key: 'votesvalid', type: 'input', templateOptions: { - label: gettextCatalog.getString('Valid ballots'), + label: gettextCatalog.getString('Valid votes'), type: 'number' } }, @@ -596,7 +596,7 @@ angular.module('OpenSlidesApp.motions.site', [ key: 'votesinvalid', type: 'input', templateOptions: { - label: gettextCatalog.getString('Invalid ballots'), + label: gettextCatalog.getString('Invalid votes'), type: 'number' } }, @@ -604,7 +604,7 @@ angular.module('OpenSlidesApp.motions.site', [ key: 'votescast', type: 'input', templateOptions: { - label: gettextCatalog.getString('Casted ballots'), + label: gettextCatalog.getString('Votes cast'), type: 'number' } }]; @@ -1224,7 +1224,7 @@ angular.module('OpenSlidesApp.motions.site', [ // open poll update dialog $scope.openPollDialog = function (poll, voteNumber) { ngDialog.open({ - template: 'static/templates/motions/motionpoll-form.html', + template: 'static/templates/motions/motion-poll-form.html', controller: 'MotionPollUpdateCtrl', className: 'ngdialog-theme-default', closeByEscape: false, diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index fd4aa9744..e11f64738 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -362,7 +362,7 @@ - Valid ballots: + Valid votes: {{ votesValid.value }} {{ votesValid.percentStr }} @@ -371,7 +371,7 @@ - Invalid ballots: + Invalid votes: {{ votesInvalid.value }} {{ votesInvalid.percentStr }} @@ -380,7 +380,7 @@ - Casted ballots: + Votes cast: {{ votesCast.value }} {{ votesCast.percentStr }} diff --git a/openslides/motions/static/templates/motions/motionpoll-form.html b/openslides/motions/static/templates/motions/motion-poll-form.html similarity index 100% rename from openslides/motions/static/templates/motions/motionpoll-form.html rename to openslides/motions/static/templates/motions/motion-poll-form.html diff --git a/openslides/motions/views.py b/openslides/motions/views.py index 10d805405..e747d7e2f 100644 --- a/openslides/motions/views.py +++ b/openslides/motions/views.py @@ -399,8 +399,8 @@ class MotionPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet): """ Customized view endpoint to delete a motion poll. """ - result = super().destroy(*args, **kwargs) poll = self.get_object() + result = super().destroy(*args, **kwargs) poll.motion.write_log([ugettext_noop('Vote deleted')], self.request.user) return result