Merge pull request #1301 from normanjaeckel/MotionTitle

Changed motion title behavior.
This commit is contained in:
Norman Jäckel 2014-05-19 22:49:23 +02:00
commit f9729fdae3
4 changed files with 18 additions and 13 deletions

View File

@ -88,7 +88,11 @@ class Motion(SlideMixin, AbsoluteUrlMixin, models.Model):
"""
Return a human readable name of this motion.
"""
return self.get_active_version().title
if self.identifier:
string = '%s | %s' % (self.identifier, self.title)
else:
string = self.title
return string
# TODO: Use transaction
def save(self, use_version=None, *args, **kwargs):
@ -457,14 +461,12 @@ class Motion(SlideMixin, AbsoluteUrlMixin, models.Model):
"""
Return a title for the agenda.
"""
return self.title
return unicode(self)
def get_agenda_title_supplement(self):
"""
Returns the supplement to the title for the agenda item.
"""
if self.identifier:
return '(%s %s)' % (_('Motion'), self.identifier)
return '(%s)' % _('Motion')
def get_allowed_actions(self, person):

View File

@ -36,10 +36,10 @@ def motion_to_pdf(pdf, motion):
"""
Create a PDF for one motion.
"""
identifier = ""
identifier = ''
if motion.identifier:
identifier = " %s" % motion.identifier
pdf.append(Paragraph(_("Motion") + "%s: %s" % (identifier, motion.title), stylesheet['Heading1']))
identifier = ' %s' % motion.identifier
pdf.append(Paragraph('%s%s: %s' % (_('Motion'), identifier, motion.title), stylesheet['Heading1']))
motion_data = []
@ -256,10 +256,10 @@ def all_motion_cover(pdf, motions):
pdf.append(Paragraph(_("No motions available."), stylesheet['Heading3']))
else:
for motion in motions:
identifier = ""
identifier = ''
if motion.identifier:
identifier = "%s " % motion.identifier
pdf.append(Paragraph("%s   %s" % (identifier, motion.title), stylesheet['Heading3']))
identifier = ' %s' % motion.identifier
pdf.append(Paragraph('%s%s: %s' % (_('Motion'), identifier, motion.title), stylesheet['Heading3']))
def motion_poll_to_pdf(pdf, poll):

View File

@ -22,7 +22,6 @@
<i class="icon-search"></i>
</a>
<a href="{{ motion|absolute_url }}">
{{ motion.identifier|add:' | '|default:'' }}
{{ motion }}
</a>
</li>

View File

@ -138,10 +138,14 @@ class ModelTest(TestCase):
self.assertEqual(motion.versions.count(), 2)
def test_unicode_with_no_active_version(self):
motion = Motion.objects.create(title='foo', text='bar', identifier='')
motion = Motion.objects.create(
title='test_title_Koowoh1ISheemeey1air',
text='test_text_zieFohph0doChi1Uiyoh',
identifier='test_identifier_VohT1hu9uhiSh6ooVBFS')
motion.active_version = None
motion.save(update_fields=['active_version'])
self.assertEqual(str(motion), 'foo') # motion.__unicode__() raised an AttributeError
# motion.__unicode__() raised an AttributeError
self.assertEqual(str(motion), 'test_identifier_VohT1hu9uhiSh6ooVBFS | test_title_Koowoh1ISheemeey1air')
class ConfigTest(TestCase):