Show agenda titles with correct numbering

This commit is contained in:
Emanuel Schuetze 2016-01-09 13:01:46 +01:00
parent 622dadd4ef
commit 54b1c8e350
12 changed files with 28 additions and 33 deletions

View File

@ -139,7 +139,11 @@ class ItemManager(models.Manager):
item_number = str(index + 1)
if number is not None:
item_number = '.'.join((number, item_number))
tree_element['item'].item_number = item_number
if config['agenda_number_prefix']:
item_number_tmp = "%s %s" % (config['agenda_number_prefix'], item_number)
else:
item_number_tmp = item_number
tree_element['item'].item_number = item_number_tmp
tree_element['item'].save()
walk_tree(tree_element['children'], item_number)
@ -261,11 +265,10 @@ class Item(RESTModelMixin, models.Model):
Return get_agenda_title() from the content_object.
"""
try:
title = self.content_object.get_agenda_title()
return self.content_object.get_agenda_title()
except AttributeError:
raise NotImplementedError('You have to provide a get_agenda_title '
'method on your related model.')
return '%s %s' % (self.item_no, title) if self.item_no else title
def is_hidden(self):
"""
@ -287,16 +290,6 @@ class Item(RESTModelMixin, models.Model):
# The list of speakers is empty.
return None
@property
def item_no(self):
item_no = None
if self.item_number:
if config['agenda_number_prefix']:
item_no = '%s %s' % (config['agenda_number_prefix'], self.item_number)
else:
item_no = str(self.item_number)
return item_no
class SpeakerManager(models.Manager):
"""

View File

@ -56,6 +56,7 @@ def setup_agenda_config(sender, **kwargs):
name='agenda_number_prefix',
default_value='',
label=ugettext_lazy('Numbering prefix for agenda items'),
help_text=ugettext_lazy('This prefix will be set if you run the automatic agenda numbering.'),
weight=240,
group=ugettext_lazy('Agenda'),
validators=(MaxLengthValidator(20),))

View File

@ -53,7 +53,10 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
title = this.title;
}
if (this.getContentResource().agendaSupplement) {
title = title + ' (' + gettextCatalog.getString(this.getContentResource().agendaSupplement) + ')';
title = gettextCatalog.getString(this.getContentResource().agendaSupplement) + ' ' + title;
}
if (this.item_number) {
title = this.item_number + ' ' + title;
}
return title;
},

View File

@ -133,9 +133,9 @@
<!-- agenda data columns -->
<td ng-if="!item.quickEdit" ng-mouseover="item.hover=true" ng-mouseleave="item.hover=false">
<span ng-if="item.type == 2" title="'Hidden item'|translate"><i class="fa fa-ban"></i></span>
<span ng-repeat="n in [].constructor(item.parentCount) track by $index">&ndash;</span>
<strong>
<a href="" ng-click="open(item)">
<span ng-repeat="n in [].constructor(item.parentCount) track by $index">&ndash;</span>
{{ item.getTitle() }}
</a>
</strong>

View File

@ -292,10 +292,13 @@ class AgendaPDF(PDFView):
yield from walk_tree(element['children'], ancestors + 1)
for item, ancestors in walk_tree(tree):
item_number = "{} ".format(item.item_number) if item.item_number else ''
if ancestors:
space = "&nbsp;" * 6 * ancestors
story.append(Paragraph(
"%s%s" % (space, escape(item.title)),
"%s%s%s" % (space, item_number, escape(item.title)),
stylesheet['Subitem']))
else:
story.append(Paragraph(escape(item.title), stylesheet['Item']))
story.append(Paragraph(
"%s%s" % (item_number, escape(item.title)),
stylesheet['Item']))

View File

@ -29,7 +29,10 @@
</a>
</div>
<h1>{{ assignment.title }}</h1>
<h2 translate>Election</h2>
<h2>
<translate>Election</translate> &ndash;
<translate>Agenda</translate>: {{ assignment.agenda_item.item_number }}
</h2>
</div>
</div>

View File

@ -18,7 +18,7 @@
<i class="fa fa-video-camera"></i>
</a>
</div>
<h1>{{ customslide.title }}</h1>
<h1>{{ customslide.agenda_item.getTitle() }}</h1>
<h2 translate>Agenda item</h2>
</div>
</div>

View File

@ -128,7 +128,7 @@ class Motion(RESTModelMixin, models.Model):
Return a human readable name of this motion.
"""
if self.identifier:
string = '%s | %s' % (self.identifier, self.title)
string = '%s: %s' % (self.identifier, self.title)
else:
string = self.title
return string

View File

@ -197,9 +197,9 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users'])
getAgendaTitle: function () {
var value = '';
if (this.identifier) {
value = this.identifier + ' | ';
value = ' ' + this.identifier;
}
return value + this.getTitle();
return value + ': ' + this.getTitle();
},
isAllowed: function (action) {
/*

View File

@ -33,6 +33,8 @@
<h2>
<translate>Motion</translate> {{ motion.identifier }}
<span ng-if="motion.versions.length > 1" >| Version {{ motion.active_version }}</span>
&ndash;
<translate>Agenda</translate>: {{ motion.agenda_item.item_number }}
</h2>
</div>
</div>

View File

@ -128,7 +128,7 @@ class ModelTest(TestCase):
motion.active_version = None
motion.save(update_fields=['active_version'])
# motion.__unicode__() raised an AttributeError
self.assertEqual(str(motion), 'test_identifier_VohT1hu9uhiSh6ooVBFS | test_title_Koowoh1ISheemeey1air')
self.assertEqual(str(motion), 'test_identifier_VohT1hu9uhiSh6ooVBFS: test_title_Koowoh1ISheemeey1air')
def test_is_amendment(self):
config['motions_amendments_enabled'] = True

View File

@ -14,16 +14,6 @@ class TestItemTitle(TestCase):
item.title,
'related_title')
@patch('openslides.agenda.models.Item.item_no', '5')
@patch('openslides.agenda.models.Item.content_object')
def test_title_with_item_no(self, content_object):
item = Item()
content_object.get_agenda_title.return_value = 'related_title'
self.assertEqual(
item.title,
'5 related_title')
@patch('openslides.agenda.models.Item.content_object')
def test_title_invalid_related(self, content_object):
item = Item()