Merge pull request #3697 from FinnStutzenstein/protectNumbering

Protect numbering of the agenda
This commit is contained in:
Emanuel Schütze 2018-04-13 14:21:06 +02:00 committed by GitHub
commit b95a76493d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 6 deletions

View File

@ -20,6 +20,7 @@ Agenda:
- Autoupdates for all children if the item type has changed [#3659]. - Autoupdates for all children if the item type has changed [#3659].
- Added config variable to hide internal items when projecting - Added config variable to hide internal items when projecting
subitems [#3701]. subitems [#3701].
- Added config value to enable numbering of items [#3697].
Motions: Motions:
- New export dialog [#3185]. - New export dialog [#3185].

View File

@ -9,6 +9,15 @@ def get_config_variables():
It has to be evaluated during app loading (see apps.py). It has to be evaluated during app loading (see apps.py).
""" """
yield ConfigVariable(
name='agenda_enable_numbering',
label='Enable numbering for agenda items',
input_type='boolean',
default_value=True,
weight=200,
group='Agenda',
subgroup='General')
yield ConfigVariable( yield ConfigVariable(
name='agenda_number_prefix', name='agenda_number_prefix',
default_value='', default_value='',

View File

@ -769,6 +769,7 @@ angular.module('OpenSlidesApp.agenda.site', [
.config([ .config([
'gettext', 'gettext',
function (gettext) { function (gettext) {
gettext('Enable numbering for agenda items');
gettext('Numbering prefix for agenda items'); gettext('Numbering prefix for agenda items');
gettext('This prefix will be set if you run the automatic agenda numbering.'); gettext('This prefix will be set if you run the automatic agenda numbering.');
gettext('Agenda'); gettext('Agenda');

View File

@ -78,11 +78,14 @@
<translate>Sort ...</translate> <translate>Sort ...</translate>
</a> </a>
<!-- auto numbering button --> <!-- auto numbering button -->
<span ng-if="config('agenda_enable_numbering')">
<button os-perms="agenda.can_manage" class="btn btn-default btn-sm" <button os-perms="agenda.can_manage" class="btn btn-default btn-sm"
ng-click="autoNumbering()"> ng-bootbox-confirm="{{ 'Are you sure you want to number all agenda items?' | translate }}"
ng-bootbox-confirm-action="autoNumbering()">
<i class="fa fa-sort-numeric-asc"></i> <i class="fa fa-sort-numeric-asc"></i>
<translate>Numbering</translate> <translate>Numbering</translate>
</button> </button>
</span>
<!-- Export drop down list (for manager) --> <!-- Export drop down list (for manager) -->
<div os-perms="motions.can_manage" class="pull-right" uib-dropdown> <div os-perms="motions.can_manage" class="pull-right" uib-dropdown>
<button type="button" class="btn btn-default btn-sm" id="dropdownExport" uib-dropdown-toggle> <button type="button" class="btn btn-default btn-sm" id="dropdownExport" uib-dropdown-toggle>

View File

@ -305,6 +305,9 @@ class ItemViewSet(ListModelMixin, RetrieveModelMixin, UpdateModelMixin, GenericV
Auto numbering of the agenda according to the config. Manually added Auto numbering of the agenda according to the config. Manually added
item numbers will be overwritten. item numbers will be overwritten.
""" """
if not config['agenda_enable_numbering']:
raise ValidationError({'detail': _('Numbering of agenda items is deactivated.')})
Item.objects.number_all(numeral_system=config['agenda_numeral_system']) Item.objects.number_all(numeral_system=config['agenda_numeral_system'])
return Response({'detail': _('The agenda has been numbered.')}) return Response({'detail': _('The agenda has been numbered.')})

View File

@ -13,7 +13,7 @@
<!-- checkbox --> <!-- checkbox -->
<div ng-if="type === 'checkbox'" class="config-checkbox"> <div ng-if="type === 'checkbox'" class="config-checkbox">
<i class="fa" id="{{ key }}" <i class="fa pointer" id="{{ key }}"
ng-click="$parent.value = !$parent.value; save(configOption, $parent.value)" ng-click="$parent.value = !$parent.value; save(configOption, $parent.value)"
ng-class="$parent.value ? 'fa-check-square-o' : 'fa-square-o'"></i> ng-class="$parent.value ? 'fa-check-square-o' : 'fa-square-o'"></i>
</div> </div>

View File

@ -393,6 +393,12 @@ class Numbering(TestCase):
self.assertEqual(Item.objects.get(pk=self.item_2_1.pk).item_number, '2.1') self.assertEqual(Item.objects.get(pk=self.item_2_1.pk).item_number, '2.1')
self.assertEqual(Item.objects.get(pk=self.item_3.pk).item_number, '3') self.assertEqual(Item.objects.get(pk=self.item_3.pk).item_number, '3')
def test_deactivated_numbering(self):
config['agenda_enable_numbering'] = False
response = self.client.post(reverse('item-numbering'))
self.assertEqual(response.status_code, 400)
def test_roman_numbering(self): def test_roman_numbering(self):
config['agenda_numeral_system'] = 'roman' config['agenda_numeral_system'] = 'roman'