Update motion templates to new template design. Added some missing model and view functions.

This commit is contained in:
Emanuel Schuetze 2013-03-09 14:29:40 +01:00
parent 71b1bede6f
commit ee0e599a6c
7 changed files with 492 additions and 137 deletions

View File

@ -19,6 +19,7 @@ from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.db.models import Max from django.db.models import Max
from django.dispatch import receiver from django.dispatch import receiver
from django.utils import formats
from django.utils.translation import pgettext from django.utils.translation import pgettext
from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _ from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _
@ -101,7 +102,7 @@ class Motion(SlideMixin, models.Model):
and and
the config 'motion_create_new_version' is set to the config 'motion_create_new_version' is set to
'ALLWASY_CREATE_NEW_VERSION'. 'ALWAYS_CREATE_NEW_VERSION'.
""" """
if not self.state: if not self.state:
self.reset_state() self.reset_state()
@ -296,10 +297,20 @@ class Motion(SlideMixin, models.Model):
except IndexError: except IndexError:
return self.new_version 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): def is_submitter(self, person):
"""Return True, if person is a submitter of this motion. Else: False.""" """Return True, if person is a submitter of this motion. Else: False."""
self.submitter.filter(person=person).exists() 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): def is_supporter(self, person):
"""Return True, if person is a supporter of this motion. Else: False.""" """Return True, if person is a supporter of this motion. Else: False."""
return self.supporter.filter(person=person).exists() return self.supporter.filter(person=person).exists()
@ -379,13 +390,18 @@ class Motion(SlideMixin, models.Model):
'support': (self.state.allow_support and 'support': (self.state.allow_support and
config['motion_min_supporters'] > 0 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'), 'change_state': person.has_perm('motion.can_manage_motion'),
} }
actions['delete'] = actions['edit'] # TODO: Only if the motion has no number actions['delete'] = actions['edit'] # TODO: Only if the motion has no number
actions['unsupport'] = actions['support']
actions['reset_state'] = actions['change_state'] actions['reset_state'] = actions['change_state']
return actions return actions
@ -394,7 +410,7 @@ class Motion(SlideMixin, models.Model):
Message should be in english and translatable. 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) MotionLog.objects.create(motion=self, message=message, person=person)
@ -546,11 +562,11 @@ class MotionLog(models.Model):
def __unicode__(self): def __unicode__(self):
"""Return a string, representing the log message.""" """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: if self.person is None:
return "%s %s" % (self.time, _(self.message)) return "%s %s" % (time, _(self.message))
else: 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): class MotionVote(BaseVote):

View File

@ -4,26 +4,141 @@
{% load i18n %} {% load i18n %}
{% load staticfiles %} {% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Motion" %} "{{ motion.title }}"{% endblock %} {% block title %}{{ block.super }} {% trans "Motion" %} {{ motion.number }}{% endblock %}
{% block content %} {% block content %}
<p>Titel: {{ motion.title }} </p> <h1>
<p>Text: {{ motion.text }}</p> {{ motion.title }}
<p>Reason: {{ motion.reason }}</p> <br>
<p>Submitter: {% for submitter in motion.submitter.all %}{{ submitter.person }} {% endfor %}</p> <small>
<p>Supporter: {% for supporter in motion.supporter.all %}{{ supporter.person }} {% endfor %}</p> {% if motion.number != None %}
<p>Active Version: {{ motion.active_version }}</p> {% trans "Motion" %} {{ motion.number }},
<p>State: {{ motion.state }}</p> {% else %}
<h4>possible stats:</h4> <i>[{% trans "no number" %}]</i>,
<ul> {% endif %}
{% for state in motion.state.next_states.all %} {% trans "Version" %} {{ motion.version.version_number }}
<li><a href="{% url 'motion_set_state' motion.pk state.pk %}">{{ state }}</a></li> </small>
{% endfor %} <small class="pull-right">
<li><a href="{% url 'motion_reset_state' motion.pk %}">Reset State</a></li> <div class="btn-toolbar">
</ul> <a href="{% url 'motion_list' %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
<a href="{% url 'motion_detail_pdf' motion.id %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Print this motion as PDF' %}"><i class="icon-print"></i> PDF</a>
<!-- activate projector -->
{% if perms.projector.can_manage_projector %}
<a href="{% url 'projector_activate_slide' motion.sid %}" class="activate_link btn {% if motion.active %}btn-primary{% endif %} btn-mini" rel="tooltip" data-original-title="{% trans 'Show motion' %}">
<i class="icon-facetime-video {% if motion.active %}icon-white{% endif %}"></i>
</a>
{% endif %}
<div class="btn-group">
<a data-toggle="dropdown" href="#" class="btn btn-mini dropdown-toggle">
{% trans 'More actions' %}
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-right">
<!-- edit -->
{% if allowed_actions.edit %}
<li><a href="{% model_url motion 'edit' %}"><i class="icon-pencil"></i> {% trans 'Edit motion' %}</a></li>
{% endif %}
<!-- delete -->
{% if allowed_actions.delete %}
<li><a href="{% model_url motion 'delete' %}"><i class="icon-remove"></i> {% trans 'Delete motion' %}</a></li>
{% endif %}
<!-- create agenda item -->
{% if perms.agenda.can_manage_agenda %}
<li>
<a href="{% url 'motion_create_agenda' motion.id %}"><i class="icon-plus"></i> {% trans 'New agenda item' %}</a>
</li>
{% endif %}
</ul>
</div>
</div>
</small>
</h1>
<div class="row-fluid">
<div class="span8">
{% if motion.active_version.id != motion.version.id %}
<span class="label label-warning"><i class="icon-warning-sign icon-white"></i>
{% if motion.version == motion.public_version %}
{% trans "This is not the newest version." %}</span> <a href="{% url 'motion_version_detail' motion.id motion.last_version.id %}">{% trans "Go to version" %} {{ motion.last_version.version_number }}.</a>
{% else %}
{% trans "This is not the authorized version." %}</span> <a href="{% url 'motion_view' motion.id %}">{% trans "Go to version" %} {{ motion.public_version.aid }}.</a>
{% endif %}
{% endif %}
<h4>Versions</h4> <!-- Text -->
<h4>{% trans "Motion text" %}:</h4>
{{ motion.version.text|linebreaks }}
<br>
<!-- Reason -->
<h4>{% trans "Reason" %}:</h4>
{% if motion.version.reason %}
{{ motion.version.reason|linebreaks }}
{% else %}
{% endif %}
<br>
<!-- Version history -->
{% for version in motion.versions.all %}
{% if forloop.first %}
<h4>{% trans "Version history" %}:</h4>
<table class="table table-striped table-bordered">
<tr>
<th></th>
<th>{% trans "Version" %}</th>
<th>{% trans "Time" %}</th>
<th>{% trans "Title" %}</th>
<th>{% trans "Text" %}</th>
<th>{% trans "Reason" %}</th>
</tr>
{% endif %}
<tr>
<td class="nobr">
{% if version == motion.active_version %}
<span class="badge badge-success" title="{% trans 'This version is authorized' %}"><i class="icon-ok icon-white"></i></span>
{% else %}
{% if perms.motion.can_manage_motion %}
<a class="btn btn-mini" href="{% url 'motion_version_permit' motion.id version.id %}" title="{% trans 'Permit this version' %}"><i class="icon-ok"></i></a>
{% endif %}
{% if not version.rejected and version.id > motion.active_version.id and perms.motion.can_manage_motion %}
<a class="btn btn-mini" href="{% url 'motion_version_reject' version.id %}" title="{% trans 'Reject this version' %}"><i class="icon-ban-circle"></i></a>
{% endif %}
{% endif %}
{% if version.rejected %}
<span class="badge badge-important" title="{% trans 'This version is rejected' %}"><i class="icon-ban-circle icon-white"></i></span>
{% endif %}
</td>
<td><a href="{% model_url version %}">{{ version.version_number }}</a></td>
<td><i>{{ version.creation_time }}</i></td>
<td>
{% ifchanged %}
<b>{{ version.title }}</b>
{% else %}
<i>[{% trans "unchanged" %}]</i>
{% endifchanged %}
</td>
<td>
{% ifchanged %}
{{ version.text|linebreaks }}
{% else %}
<i>[{% trans "unchanged" %}]</i>
{% endifchanged %}
</td>
<td>
{% ifchanged %}
{{ version.reason|linebreaks }}
{% else %}
<i>[{% trans "unchanged" %}]</i>
{% endifchanged %}
</td>
</tr>
{% if forloop.last %}
</table>
{% endif %}
{% endfor %}
<!-- TODO: For testing -->
<ol> <ol>
{% for motion_version in motion.versions.all %} {% for motion_version in motion.versions.all %}
<li> <li>
@ -41,60 +156,152 @@
</li> </li>
{% endfor %} {% endfor %}
</ol> </ol>
<!-- End TODO -->
<h4>{% trans "Vote results" %}:</h4> <!-- Log -->
{% with motion.polls.all as polls %} {% if perms.motion.can_manage_motion %}
<ul class="results"> <button type="button" class="btn" data-toggle="collapse" data-target="#log">
{% trans "Show log" %}
</button>
<div id="log" class="collapse out">
<ul class="unstyled">
{% for message in motion.log_messages.all %}
<li><small>{{ message }}</small></li>
{% endfor %}
</ul>
</div>
{% endif %}
</div> <!--/span-->
<!-- Box with meta information -->
<div class="span4">
<div class="well">
<!-- Submitter -->
<h5>{% trans "Submitter" %}:</h5>
{% for submitter in motion.submitter.all %}
{{ submitter.person }}{% if not forloop.last %}, {% endif %}
{% endfor %}
<!-- Supporters -->
{% if min_supporters > 0 %}
<h5>{% trans "Supporters" %}: *</h5>
{% if not motion.supporters %}
-
{% else %}
<ol>
{% for supporter in motion.supporter.all %}
<li>{{ supporter }}</li>
{% endfor %}
</ol>
{% endif %}
{% endif %}
<!-- Status -->
<h5>{% trans "Status" %}:</h5>
{% if motion.state_id != "pub" %}
{# TODO: trans motion.state #}
<span class="label label-info">{{ motion.state }}</span>
<br>
{% endif %}
{% for note in motion.notes %}
{{ note }}
{% if not forloop.last %}<br>{% endif %}
{% endfor %}
<!-- Vote results -->
<h5>{% trans "Vote results" %}:</h5>
{% with motion.polls.all as polls %}
<ol>
{% for poll in polls %} {% for poll in polls %}
{% if perms.motion.can_manage_motion or poll.has_votes %} {% if perms.motion.can_manage_motion or poll.has_votes %}
<li> <li>{% trans "Vote" %}
{% if perms.motion.can_manage_motion %}
<strong>{{ forloop.counter }}. {% trans "Vote" %} </strong>
<a class="icon edit" href="{% model_url poll 'edit' %}" title="{% trans 'Edit Vote' %}">
<span></span>
</a>
<a class="icon delete" href="{% model_url poll 'delete' %}" title="{% trans 'Delete Vote' %}">
<span></span>
</a>
{% elif poll.has_votes %}
<strong>{{ forloop.counter }}. {% trans "Vote" %}:</strong>
{% endif %}
<br>
{% if poll.has_votes %}
{% with poll.get_options.0 as option %}
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ option.Yes }}<br>
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ option.No }}<br>
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ option.Abstain }}<br>
<img src="{% static 'images/icons/voting-invalid.png' %}" title="{% trans 'Invalid' %}"> {{ poll.print_votesinvalid }}<br>
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 10em;">
<img src="{% static 'images/icons/voting-total.png' %}" title="{% trans 'Votes cast' %}"> {{ poll.print_votescast }}
</div>
{% endwith %}
{% else %}
{% if perms.motion.can_manage_motion %} {% if perms.motion.can_manage_motion %}
<a href="{% model_url poll %}"> <a class="btn btn-mini" href="{% url 'motion_poll_edit' motion.id poll.id %}" title="{% trans 'Edit Vote' %}"><i class="icon-edit"></i></a>
<span class="button"><span class="icon statistics">{% trans 'Enter result' %}</span></span> <a class="btn btn-mini" href="{% url 'motion_poll_delete' motion.id poll.id %}" title="{% trans 'Delete Vote' %}"><i class="icon-remove"></i></a>
</a> {% endif %}
{% endif %} <br>
{% endif %} {% if poll.has_votes %}
</li> {% with poll.get_options.0 as option %}
<img src="{% static 'img/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ option.Yes }}<br>
<img src="{% static 'img/voting-no.png' %}" title="{% trans 'No' %}"> {{ option.No }}<br>
<img src="{% static 'img/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ option.Abstain }}<br>
<img src="{% static 'img/voting-invalid.png' %}" title="{% trans 'Invalid' %}"> {{ poll.print_votesinvalid }}<br>
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 10em;">
<img src="{% static 'img/voting-total.png' %}" title="{% trans 'Votes cast' %}"> {{ poll.print_votescast }}
</div>
{% endwith %}
{% else %}
{% if perms.motion.can_manage_motion %}
<span class="label label-info">{% trans 'No results' %}</span>
{% endif %}
{% endif %}
</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ol>
{% if allowed_actions.create_poll %} {% if allowed_actions.create_poll %}
<a href="{% url 'motion_poll_create' motion.pk %}"> <a href="{% url 'motion_poll_create' motion.id %}" class="btn btn-mini">
<span class="button"><span class="icon statistics">{% trans 'New vote' %}</span></span> <i class="icon-assignment"></i> {% trans 'New vote' %}
</a>
{% endif %}
{% endwith %}
<!-- Creation Time -->
<h5>{% trans "Creation Time" %}:</h5>
{# TODO: use creation time of _first_ version #}
{{ motion.version.creation_time }}
<!-- Widthdraw button -->
{% if allowed_actions.wit and user in motion.submitters %}
<br><br>
<a href="{% url 'motion_set_state' motion.id 'wit' %}" class="btn">
<span class="icon revert">{% trans 'Withdraw motion' %}</span>
</a> </a>
{% endif %} {% endif %}
{% endwith %}
<!-- Support/Unsupport button -->
{% if perms.motion.can_support_motion and min_supporters > 0 %}
{% if allowed_actions.unsupport %}
<br><br>
<a href="{% url 'motion_unsupport' motion.id %}" class="btn">
{% trans 'Unsupport' %}
</a>
{% endif %}
{% if allowed_actions.support %}
<br><br>
<a href="{% url 'motion_support' motion.id %}" class="btn">
{% trans 'Support' %}
</a>
{% endif %}
{% endif %}
<!-- Footnote: requried supporters -->
{% if min_supporters > 0 %}
<br><br>
<small>* {% trans "minimum required supporters" %}: {{ min_supporters }}</small>
{% endif %}
</div> <!--/well-->
{% if perms.motion.can_manage_motion %}
<!-- Manage motion box -->
<div class="well">
<h4>{% trans "Manage motion" %}</h4>
<div class="btn-group">
{% for state in motion.state.next_states.all %}
<a href="{% url 'motion_set_state' motion.pk state.pk %}" class="btn btn-small">{{ state }}</a>
{% endfor %}
</div>
<p></p>
<hr>
<h5>{% trans "For administration only:" %}</h5>
<a href="{% url 'motion_reset_state' motion.id %}" class="btn btn-danger">
<i class="icon-exclamation-sign icon-white"></i> {% trans 'Reset state' %}
</a>
</div> <!--/well-->
{% endif %}
</div> <!--/span-->
</div> <!--/row-->
<h4>log</h4>
<ul>
{% for message in motion.log_messages.all %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endblock %} {% endblock %}

View File

@ -2,25 +2,35 @@
{% load tags %} {% load tags %}
{% load i18n %} {% load i18n %}
{% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Motion Form" %}{% endblock %} {% block title %}
{{ block.super }}
{% if motion %}
{% trans "Edit motion" %}
{% else %}
{% trans "New motion" %}
{% endif %}
{% endblock %}
{% block content %} {% block content %}
<h1>{% trans "Motions Forms" %}</h1> <h1>
{% if motion %}
{% trans "Edit motion" %}
{% else %}
{% trans "New motion" %}
{% endif %}
<small class="pull-right">
<a href="{% url 'motion_list' %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
</small>
</h1>
<form action="" method="post">{% csrf_token %} <form action="" method="post">{% csrf_token %}
{{ form.as_p }} {% include "form.html" %}
<button class="button" type="submit"> <p>
<span class="icon ok">{% trans 'Save' %}</span> {% include "formbuttons_saveapply.html" %}
</button> <a href='{% url 'motion_list' %}' class="btn">
<button class="button" type="submit" name="apply"> {% trans 'Cancel' %}
<span class="icon apply">{% trans 'Apply' %}</span>
</button>
<a href="{% url 'motion_list' %}">
<button class="button" type="button" onclick="window.location='{% url 'motion_list' %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
</a> </a>
</p>
<small>* {% trans "required" %}</small> <small>* {% trans "required" %}</small>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -2,15 +2,104 @@
{% load tags %} {% load tags %}
{% load i18n %} {% load i18n %}
{% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Motions" %}{% endblock %} {% block title %}{{ block.super }} {% trans "Motions" %}{% endblock %}
{% block content %} {% block content %}
<h1>{% trans "Motions" %}</h1> <h1>
<ol> {% trans "Motions" %}
<small class="pull-right">
{% if perms.motion.can_create_motion %}
<a href="{% url 'motion_new' %}" class="btn btn-mini btn-primary" rel="tooltip" data-original-title="{% trans 'New motion' %}"><i class="icon-plus icon-white"></i> {% trans "New" %}</a>
{% endif %}
{% if perms.motion.can_manage_motion %}
{# <a href="{% url 'motion_import' %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Import motions' %}"><i class="icon-import"></i> {% trans 'Import' %}</a>#}
{% endif %}
<a href="{% url 'motion_list_pdf' %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Print all motions as PDF' %}"><i class="icon-print"></i> PDF</a>
</small>
</h1>
<form action="{{ request.url }}" name="filter" method="get" class="form-inline">
{% if min_supporters > 0 %}
<label class="checkbox">
<input type="checkbox" name="needsup" onchange="document.forms['filter'].submit()"
{% if 'on' in request.GET.needsup %}checked{% endif %}> {% trans "Need supporters" %} &nbsp;
</label>
{% endif %}
<label class="checkbox">
<input type="checkbox" name="number" onchange="document.forms['filter'].submit()"
{% if 'on' in request.GET.number %}checked{% endif %}> {% trans "Without number" %} &nbsp;
</label>
<label class="checkbox">
<input type="checkbox" name="status" onchange="document.forms['filter'].submit()"
{% if 'on' in request.GET.status %}checked{% endif %}> {% trans "Status" %}:
</label>
<select class="default-input" name="statusvalue" onchange="{% if 'on' in request.GET.status %}document.forms['filter'].submit(){% endif %}">
<option value="pub" {% if 'pub' in request.GET.statusvalue %}selected{% endif %}>{% trans "Not yet authorized" %}</option>
<option value="per" {% if 'on' in request.GET.status and 'per' in request.GET.statusvalue %}selected{% endif %}>{% trans "Authorized" %}</option>
<option value="acc" {% if 'on' in request.GET.status and 'acc' in request.GET.statusvalue %}selected{% endif %}>{% trans "Accepted" %}</option>
<option value="rej" {% if 'on' in request.GET.status and 'rej' in request.GET.statusvalue %}selected{% endif %}>{% trans "Rejected" %}</option>
<option value="wit" {% if 'on' in request.GET.status and 'wit' in request.GET.statusvalue %}selected{% endif %}>{% trans "Withdrawen (by submitter)" %}</option>
<option value="rev" {% if 'rev' in request.GET.statusvalue %}selected{% endif %}>{% trans "Needs Review" %}</option>
</select>
</form>
<small><i>{{ motion_list|length }}
{% blocktrans count counter=motion_list|length context "number of motions"%}motion{% plural %}motions{% endblocktrans %}
</i></small>
<table class="table table-striped table-bordered">
<tr>
<th><a href="?sort=number{% if 'number' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "#" %}</a></th>
<th><a href="?sort=title{% if 'title' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Motion title" %}</a></th>
{% if min_supporters > 0 %}
<th class="optional"><a href="?sort=supporter{% if 'supporter' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Number of supporters" %}</a></th>
{% endif %}
<th><a href="?sort=status{% if 'status' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Status" %}</a></th>
<th class="optional"><a href="?sort=submitter{% if 'submitter' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Submitter" %}</a></th>
<th class="optional"><a href="?sort=time{% if 'time' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Creation Time" %}<a></th>
<th class="mini_width">{% trans "Actions" %}</th>
</tr>
{% for motion in motion_list %} {% for motion in motion_list %}
<li><a href="{% model_url motion %}">{{ motion }}</a></li> <tr class="{% if motion.active %}activeline{% endif %}">
<td>{{ motion.number }}</td>
<td><a href="{% model_url motion %}">{{ motion.title }}</a></td>
{% if min_supporters > 0 %}
<td class="optional">{# motion.count_supporters #}</td>
{% endif %}
<td><span class="label label-info">{{ motion.state }}</span></td>
<td class="optional">
{% for submitter in motion.submitter.all %}
{{ submitter.person }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
{# TODO: user creation_time of _first_ version #}
<td class="optional">{{ motion.version.creation_time }}</td>
<td>
<span style="width: 1px; white-space: nowrap;">
{% if perms.projector.can_manage_projector %}
<a href="{% url 'projector_activate_slide' motion.sid %}" class="activate_link btn {% if motion.active %}btn-primary{% endif %} btn-mini" title="{% trans 'Show' %}">
<i class="icon-facetime-video {% if motion.active %}icon-white{% endif %}"></i>
</a>
{% endif %}
{% if perms.motion.can_manage_motion %}
<a href="{% model_url motion 'edit' %}" title="{% trans 'Edit' %}" class="btn btn-mini">
<i class="icon-pencil"></i>
</a>
{% if "delete" in useractions %}
<a href="{% model_url motion 'delete' %}" title="{% trans 'Delete' %}" class="btn btn-mini">
<i class="icon-remove"></i>
</a>
{% endif %}
{% endif %}
<a href="{% url 'motion_detail_pdf' motion.id %}" class="btn btn-mini" title="{% trans 'Print motion as PDF' %}">
<i class="icon-print"></i> PDF
</a>
</span>
</td>
</tr>
{% empty %}
<tr>
<td colspan="7"><i>{% trans "No motions available." %}</i></td>
</tr>
{% endfor %} {% endfor %}
</ol> </table>
{% endblock %} {% endblock %}

View File

@ -1,48 +1,78 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n %} {% load i18n %}
{% load staticfiles %}
{% load tags %} {% block title %}
{{ block.super }} - {% trans "Motion" %} {{ motion.number }}, {{ ballot }}. {% trans "Vote" %}
{% endblock %}
{% block content %} {% block content %}
<h1>{{ motion }}</h1> <h1>
<i class="helptext">{% trans "Special values" %}: -1 = {% trans 'majority' %}; -2 = {% trans 'undocumented' %}</i> {{ motion }}
<form action="" method="post" class="small-form">{% csrf_token %} <br>
{{ pre_form }} <small>
<span id="poll_id" style="display:none">{{ object.pk }}</span> {% trans "Motion" %} {{ motion.number }}, {{ ballot }}. {% trans "Vote" %}
<table class="table" style="width: auto;"> </small>
<tr> <small class="pull-right">
<th>{% trans "Option" %}</th> <div class="btn-toolbar">
<th>{% trans "Votes" %}</th> <a href="{% url 'motion_detail' motion.id %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to motion" %}</a>
</tr> <!-- activate projector -->
{% for value in forms.0 %} {% if perms.projector.can_manage_projector %}
<tr> <a href="{% url 'projector_activate_slide' motion.sid %}" class="activate_link btn {% if motion.active %}btn-primary{% endif %} btn-mini" rel="tooltip" data-original-title="{% trans 'Show motion' %}">
<td>{{ value.label }}</td> <i class="icon-facetime-video {% if motion.active %}icon-white{% endif %}"></i>
<td>{{ value.errors }}{{ value }}</td>
</tr>
{% endfor %}
<tr class="total">
<td>{% trans "Invalid votes" %}</td>
<td>{{ pollform.votesinvalid.errors }}{{ pollform.votesinvalid }}</td>
</tr>
<tr class="total">
<td>{% trans "Votes cast" %}</td>
<td>{{ pollform.votescast.errors }}{{ pollform.votescast }}</td>
</tr>
</table>
{{ post_form }}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<button class="button" type="submit" name="apply">
<span class="icon apply">{% trans 'Apply' %}</span>
</button>
<a href="{% model_url motion %}">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</a> </a>
</p> {% endif %}
</form> </div>
</small>
</h1>
<p>
{% trans "Special values" %}: <span class="badge badge-success">-1</span> = {% trans 'majority' %} | <span class="badge">-2</span> = {% trans 'undocumented' %}
</p>
<form action="" method="post" class="small-form">{% csrf_token %}
{{ pre_form }}
<span id="poll_id" style="display:none">{{ object.pk }}</span>
<table class="table table-striped table-bordered" style="width: auto;">
<tr>
<th>{% trans "Option" %}</th>
<th>{% trans "Votes" %}</th>
</tr>
{% for value in forms.0 %}
<tr>
<td>{{ value.label }}</td>
<td>{{ value.errors }}{{ value }}</td>
</tr>
{% endfor %}
<tr class="total">
<td>{% trans "Invalid votes" %}</td>
<td>{{ pollform.votesinvalid.errors }}{{ pollform.votesinvalid }}</td>
</tr>
<tr class="total">
<td>{% trans "Votes cast" %}</td>
<td>{{ pollform.votescast.errors }}{{ pollform.votescast }}</td>
</tr>
</table>
{{ post_form }}
<!-- ballot paper button -->
<p>
{# TODO: create ballot paper instead of motion_detail_pdf ! #}
<a href="{% url 'motion_detail_pdf' motion.id %}" class="btn">
<i class="icon-print"></i> {% trans 'Ballot paper as PDF' %}
</a>
</p>
<!-- Control buttons -->
<div class="control-group">
<button type="submit" class="btn btn-primary">
{% trans 'Save' %}
</button>
<button type="submit" name="apply" class="btn">
{% trans 'Apply' %}
</button>
<a href="{% url 'motion_detail' motion.id %}" class="btn">
{% trans 'Cancel' %}
</a>
</div>
</form>
{% endblock %} {% endblock %}

View File

@ -74,6 +74,8 @@ class MotionDetailView(GetVersionMixin, DetailView):
""" """
context = super(MotionDetailView, self).get_context_data(**kwargs) context = super(MotionDetailView, self).get_context_data(**kwargs)
context['allowed_actions'] = self.object.get_allowed_actions(self.request.user) context['allowed_actions'] = self.object.get_allowed_actions(self.request.user)
context['min_supporters'] = int(config['motion_min_supporters'])
context['user'] = self.request.user
return context return context
motion_detail = MotionDetailView.as_view() motion_detail = MotionDetailView.as_view()
@ -227,7 +229,7 @@ class VersionRejectView(GetVersionMixin, SingleObjectMixin, QuestionMixin, Redir
version_reject = VersionRejectView.as_view() version_reject = VersionRejectView.as_view()
class SupportView(SingleObjectMixin, QuestionMixin, RedirectView): class SupportView(SingleObjectMixin, RedirectView):
"""View to support or unsupport a motion. """View to support or unsupport a motion.
If self.support is True, the view will append a request.user to the supporter list. If self.support is True, the view will append a request.user to the supporter list.
@ -246,7 +248,6 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
def check_permission(self, request): def check_permission(self, request):
"""Return True if the user can support or unsupport the motion. Else: False.""" """Return True if the user can support or unsupport the motion. Else: False."""
allowed_actions = self.object.get_allowed_actions(request.user) allowed_actions = self.object.get_allowed_actions(request.user)
if self.support and not allowed_actions['support']: if self.support and not allowed_actions['support']:
messages.error(request, _('You can not support this motion.')) messages.error(request, _('You can not support this motion.'))
@ -257,15 +258,8 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
else: else:
return True return True
def get_question(self): def pre_redirect(self, request, *args, **kwargs):
"""Return the question string.""" """Append or remove the request.user from the motion and return success message.
if self.support:
return _('Do you really want to support this motion?')
else:
return _('Do you really want to unsupport this motion?')
def case_yes(self):
"""Append or remove the request.user from the motion.
First the method checks the permissions, and writes a log message after First the method checks the permissions, and writes a log message after
appending or removing the user. appending or removing the user.
@ -278,6 +272,7 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
else: else:
self.object.unsupport(person=user) self.object.unsupport(person=user)
self.object.write_log(ugettext_noop("Supporter: -%s") % user, user) self.object.write_log(ugettext_noop("Supporter: -%s") % user, user)
messages.success(request, self.get_success_message())
def get_success_message(self): def get_success_message(self):
"""Return the success message.""" """Return the success message."""
@ -373,6 +368,10 @@ class PollDeleteView(PollMixin, DeleteView):
super(PollDeleteView, self).case_yes() super(PollDeleteView, self).case_yes()
self.object.write_log(ugettext_noop('Poll deleted'), self.request.user) self.object.write_log(ugettext_noop('Poll deleted'), self.request.user)
def get_redirect_url(self, **kwargs):
"""Return the URL to the DetailView of the motion."""
return reverse('motion_detail', args=[self.object.motion.pk])
poll_delete = PollDeleteView.as_view() poll_delete = PollDeleteView.as_view()

View File

@ -80,6 +80,10 @@ a:hover {
padding: 8px 5px 4px 5px; padding: 8px 5px 4px 5px;
} }
/* Log */
#log {
padding-left: 14px;
}
/** Utils **/ /** Utils **/
tr.offline td, li.offline { tr.offline td, li.offline {