diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 88f6c665e..b5b6a1303 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -19,6 +19,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.db.models import Max from django.dispatch import receiver +from django.utils import formats from django.utils.translation import pgettext from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _ @@ -101,7 +102,7 @@ class Motion(SlideMixin, models.Model): and the config 'motion_create_new_version' is set to - 'ALLWASY_CREATE_NEW_VERSION'. + 'ALWAYS_CREATE_NEW_VERSION'. """ if not self.state: self.reset_state() @@ -296,10 +297,20 @@ class Motion(SlideMixin, models.Model): except IndexError: return self.new_version + @property + def submitters(self): + return sorted([object.person for object in self.submitter.all()], + key=lambda person: person.sort_name) + def is_submitter(self, person): """Return True, if person is a submitter of this motion. Else: False.""" self.submitter.filter(person=person).exists() + @property + def supporters(self): + return sorted([object.person for object in self.supporter.all()], + key=lambda person: person.sort_name) + def is_supporter(self, person): """Return True, if person is a supporter of this motion. Else: False.""" return self.supporter.filter(person=person).exists() @@ -379,13 +390,18 @@ class Motion(SlideMixin, models.Model): 'support': (self.state.allow_support and config['motion_min_supporters'] > 0 and - not self.is_submitter(person)), + not self.is_submitter(person) and + not self.is_supporter(person)), + + 'unsupport': (self.state.allow_support and + config['motion_min_supporters'] > 0 and + not self.is_submitter(person) and + self.is_supporter(person)), 'change_state': person.has_perm('motion.can_manage_motion'), } actions['delete'] = actions['edit'] # TODO: Only if the motion has no number - actions['unsupport'] = actions['support'] actions['reset_state'] = actions['change_state'] return actions @@ -394,7 +410,7 @@ class Motion(SlideMixin, models.Model): Message should be in english and translatable. - e.G: motion.write_log(ugettext_noob('Message Text')) + e.g.: motion.write_log(ugettext_noob('Message Text')) """ MotionLog.objects.create(motion=self, message=message, person=person) @@ -546,11 +562,11 @@ class MotionLog(models.Model): def __unicode__(self): """Return a string, representing the log message.""" - # TODO: write time in the local time format. + time = formats.date_format(self.time, 'DATETIME_FORMAT') if self.person is None: - return "%s %s" % (self.time, _(self.message)) + return "%s %s" % (time, _(self.message)) else: - return "%s %s by %s" % (self.time, _(self.message), self.person) + return "%s %s by %s" % (time, _(self.message), self.person) class MotionVote(BaseVote): diff --git a/openslides/motion/templates/motion/motion_detail.html b/openslides/motion/templates/motion/motion_detail.html index ccf616aab..a82796a36 100644 --- a/openslides/motion/templates/motion/motion_detail.html +++ b/openslides/motion/templates/motion/motion_detail.html @@ -4,26 +4,141 @@ {% load i18n %} {% load staticfiles %} -{% block title %}{{ block.super }} – {% trans "Motion" %} "{{ motion.title }}"{% endblock %} +{% block title %}{{ block.super }} – {% trans "Motion" %} {{ motion.number }}{% endblock %} {% block content %} -
Titel: {{ motion.title }}
-Text: {{ motion.text }}
-Reason: {{ motion.reason }}
-Submitter: {% for submitter in motion.submitter.all %}{{ submitter.person }} {% endfor %}
-Supporter: {% for supporter in motion.supporter.all %}{{ supporter.person }} {% endfor %}
-Active Version: {{ motion.active_version }}
-State: {{ motion.state }}
-+ | {% trans "Version" %} | +{% trans "Time" %} | +{% trans "Title" %} | +{% trans "Text" %} | +{% trans "Reason" %} | +
---|---|---|---|---|---|
+ {% if version == motion.active_version %} + + {% else %} + {% if perms.motion.can_manage_motion %} + + {% endif %} + {% if not version.rejected and version.id > motion.active_version.id and perms.motion.can_manage_motion %} + + {% endif %} + {% endif %} + {% if version.rejected %} + + {% endif %} + | +{{ version.version_number }} | +{{ version.creation_time }} | ++ {% ifchanged %} + {{ version.title }} + {% else %} + [{% trans "unchanged" %}] + {% endifchanged %} + | ++ {% ifchanged %} + {{ version.text|linebreaks }} + {% else %} + [{% trans "unchanged" %}] + {% endifchanged %} + | ++ {% ifchanged %} + {{ version.reason|linebreaks }} + {% else %} + [{% trans "unchanged" %}] + {% endifchanged %} + | +
{% trans "#" %} | +{% trans "Motion title" %} | + {% if min_supporters > 0 %} +{% trans "Number of supporters" %} | + {% endif %} +{% trans "Status" %} | +{% trans "Submitter" %} | +{% trans "Creation Time" %} | +{% trans "Actions" %} | +
---|---|---|---|---|---|---|
{{ motion.number }} | +{{ motion.title }} | + {% if min_supporters > 0 %} +{# motion.count_supporters #} | + {% endif %} +{{ motion.state }} | ++ {% for submitter in motion.submitter.all %} + {{ submitter.person }}{% if not forloop.last %}, {% endif %} + {% endfor %} + | + {# TODO: user creation_time of _first_ version #} +{{ motion.version.creation_time }} | ++ + {% if perms.projector.can_manage_projector %} + + + + {% endif %} + {% if perms.motion.can_manage_motion %} + + + + {% if "delete" in useractions %} + + + + {% endif %} + {% endif %} + + PDF + + + | +
{% trans "No motions available." %} | +