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.
This commit is contained in:
Emanuel Schütze 2017-03-22 14:00:03 +01:00
parent 6b253ef4b7
commit 2571d83195
8 changed files with 26 additions and 16 deletions

View File

@ -819,11 +819,15 @@ angular.module('OpenSlidesApp.core', [
id: value.id, id: value.id,
}; };
} else if ( } else if (
value.name != 'agenda/item-list' && // TODO:
value.name != 'core/clock' && // Find generic solution for whitelist in getFormOrStateForCurrentSlide
value.name != 'core/countdown' && // see https://github.com/OpenSlides/OpenSlides/issues/3130
value.name != 'core/projector-message' && value.name === 'topics/topic' ||
value.name != 'agenda/current-list-of-speakers' ) { value.name === 'motions/motion' ||
value.name === 'motions/motion-block' ||
value.name === 'assignments/assignment' ||
value.name === 'mediafiles/mediafile' ||
value.name === 'users/user') {
return_dict = { return_dict = {
form: EditForm.fromCollectionString(value.name), form: EditForm.fromCollectionString(value.name),
id: value.id, id: value.id,

View File

@ -771,6 +771,12 @@ angular.module('OpenSlidesApp.core.site', [
encoding: $scope.encoding, encoding: $scope.encoding,
header: false, // we do not want to have dicts in result header: false, // we do not want to have dicts in result
complete: function (csv) { 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 csv.data = csv.data.splice(1); // do not interpret the header as data
$scope.$apply(function () { $scope.$apply(function () {
if (csv.meta.delimiter) { if (csv.meta.delimiter) {

View File

@ -39,7 +39,7 @@ class MotionsAppConfig(AppConfig):
router.register(self.get_model('Workflow').get_collection_string(), WorkflowViewSet) router.register(self.get_model('Workflow').get_collection_string(), WorkflowViewSet)
router.register(self.get_model('MotionChangeRecommendation').get_collection_string(), router.register(self.get_model('MotionChangeRecommendation').get_collection_string(),
MotionChangeRecommendationViewSet) MotionChangeRecommendationViewSet)
router.register('motions/motionpoll', MotionPollViewSet) router.register(self.get_model('MotionPoll').get_collection_string(), MotionPollViewSet)
def get_startup_elements(self): def get_startup_elements(self):
""" """

View File

@ -69,7 +69,7 @@ angular.module('OpenSlidesApp.motions', [
'MajorityMethods', 'MajorityMethods',
function (DS, gettextCatalog, Config, MajorityMethods) { function (DS, gettextCatalog, Config, MajorityMethods) {
return DS.defineResource({ return DS.defineResource({
name: 'motions/motionpoll', name: 'motions/motion-poll',
relations: { relations: {
belongsTo: { belongsTo: {
'motions/motion': { 'motions/motion': {
@ -629,7 +629,7 @@ angular.module('OpenSlidesApp.motions', [
localKeys: 'supporters_id', localKeys: 'supporters_id',
} }
], ],
'motions/motionpoll': { 'motions/motion-poll': {
localField: 'polls', localField: 'polls',
foreignKey: 'motion_id', foreignKey: 'motion_id',
} }

View File

@ -588,7 +588,7 @@ angular.module('OpenSlidesApp.motions.site', [
key: 'votesvalid', key: 'votesvalid',
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Valid ballots'), label: gettextCatalog.getString('Valid votes'),
type: 'number' type: 'number'
} }
}, },
@ -596,7 +596,7 @@ angular.module('OpenSlidesApp.motions.site', [
key: 'votesinvalid', key: 'votesinvalid',
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Invalid ballots'), label: gettextCatalog.getString('Invalid votes'),
type: 'number' type: 'number'
} }
}, },
@ -604,7 +604,7 @@ angular.module('OpenSlidesApp.motions.site', [
key: 'votescast', key: 'votescast',
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Casted ballots'), label: gettextCatalog.getString('Votes cast'),
type: 'number' type: 'number'
} }
}]; }];
@ -1224,7 +1224,7 @@ angular.module('OpenSlidesApp.motions.site', [
// open poll update dialog // open poll update dialog
$scope.openPollDialog = function (poll, voteNumber) { $scope.openPollDialog = function (poll, voteNumber) {
ngDialog.open({ ngDialog.open({
template: 'static/templates/motions/motionpoll-form.html', template: 'static/templates/motions/motion-poll-form.html',
controller: 'MotionPollUpdateCtrl', controller: 'MotionPollUpdateCtrl',
className: 'ngdialog-theme-default', className: 'ngdialog-theme-default',
closeByEscape: false, closeByEscape: false,

View File

@ -362,7 +362,7 @@
<td class="icon"> <td class="icon">
<i class="fa fa-check fa-lg"></i> <i class="fa fa-check fa-lg"></i>
<td ng-init="votesValid = poll.getVote(poll.votesvalid, 'votesvalid')"> <td ng-init="votesValid = poll.getVote(poll.votesvalid, 'votesvalid')">
<span class="result_label"><translate>Valid ballots</translate>:</span> <span class="result_label"><translate>Valid votes</translate>:</span>
<span class="result_value"> <span class="result_value">
{{ votesValid.value }} {{ votesValid.percentStr }} {{ votesValid.value }} {{ votesValid.percentStr }}
</span> </span>
@ -371,7 +371,7 @@
<td class="icon"> <td class="icon">
<i class="fa fa-ban fa-lg"></i> <i class="fa fa-ban fa-lg"></i>
<td ng-init="votesInvalid = poll.getVote(poll.votesinvalid, 'votesinvalid')"> <td ng-init="votesInvalid = poll.getVote(poll.votesinvalid, 'votesinvalid')">
<span class="result_label"><translate>Invalid ballots</translate>:</span> <span class="result_label"><translate>Invalid votes</translate>:</span>
<span class="result_value"> <span class="result_value">
{{ votesInvalid.value }} {{ votesInvalid.percentStr }} {{ votesInvalid.value }} {{ votesInvalid.percentStr }}
</span> </span>
@ -380,7 +380,7 @@
<td class="icon"> <td class="icon">
<strong style="font-size: 16px">&sum;</strong> <strong style="font-size: 16px">&sum;</strong>
<td ng-init="votesCast = poll.getVote(poll.votescast, 'votescast')"> <td ng-init="votesCast = poll.getVote(poll.votescast, 'votescast')">
<span class="result_label"><translate>Casted ballots</translate>:</span> <span class="result_label"><translate>Votes cast</translate>:</span>
<span class="result_value"> <span class="result_value">
{{ votesCast.value }} {{ votesCast.percentStr }} {{ votesCast.value }} {{ votesCast.percentStr }}
</span> </span>

View File

@ -399,8 +399,8 @@ class MotionPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet):
""" """
Customized view endpoint to delete a motion poll. Customized view endpoint to delete a motion poll.
""" """
result = super().destroy(*args, **kwargs)
poll = self.get_object() poll = self.get_object()
result = super().destroy(*args, **kwargs)
poll.motion.write_log([ugettext_noop('Vote deleted')], self.request.user) poll.motion.write_log([ugettext_noop('Vote deleted')], self.request.user)
return result return result