Automated merge with ssh://openslides.org/openslides

This commit is contained in:
Emanuel Schuetze 2011-09-12 08:06:44 +02:00
commit 1dc631d82d
17 changed files with 480 additions and 295 deletions

View File

@ -28,10 +28,13 @@ def _bootstrap():
ui = hgui.ui()
repository = localrepository(ui, join(conts, '..'))
#repository = localrepository(ui, conts)
ctx = repository['tip']
revision = '%(num)s:%(id)s' % {
'num': ctx.rev(), 'id': shorthex(ctx.node())
}
ctx = repository['.']
if ctx.tags() and ctx.tags() != ['tip']:
revision = ' '.join(ctx.tags())
else:
revision = '%(num)s:%(id)s' % {
'num': ctx.rev(), 'id': shorthex(ctx.node())
}
except TypeError:
revision = 'unknown'
except RepoError:

View File

@ -30,9 +30,9 @@
<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.undesided }}<br>
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalid }}<br>
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 5em;">
<img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> {{ p.votescast }}
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalidf }}<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' %}"> {{ p.votescastf }}
</div>
{% endfor %}
<br>
@ -46,7 +46,7 @@
{% endwith %}
</div>
</div>
<h1>{% trans "Application No." %} {{ item.application.number }}</h1>
<b>{{ item.title }}</b>
<p>

View File

@ -21,7 +21,7 @@
<p>
<div class="text">{{ item.assignment.description|linebreaks }}</div>
</p>
{% if item.assignment.status != "fin" %}
<h3>{% trans "Candidates" %}</h3>
<ol>
@ -34,7 +34,7 @@
{% endfor %}
</ol>
{% endif %}
{% with polls|first as firstpoll %}
{% if polls.count > 0 and firstpoll.published %}
@ -72,7 +72,7 @@
{% else %}&empty;{% endif %}
</td>
{% endfor %}
</tr>
</tr>
{% empty %}
<tr>
<td {% if item.assignment.profile.exist %}colspan="2"{% endif %}><i>{% trans "No ballots available." %}</i></td>
@ -82,7 +82,7 @@
<td>{%trans 'Invalid votes' %}</td>
{% for p in polls %}
{% if p.published %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalid }}</td>
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalidf }}</td>
{% endif %}
{% endfor %}
</tr>
@ -90,13 +90,13 @@
<td><b>{%trans 'Votes cast' %}</b></td>
{% for p in polls %}
{% if p.published %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescast }}</b></td>
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescastf }}</b></td>
{% endif %}
{% endfor %}
</tr>
</table>
{% endif %}
{% endwith %}
<br>
{% endblock %}

View File

@ -17,7 +17,7 @@
<h3>{{ poll.application.title }}</h3>
<p>{%trans "Results of" %} {{ ballot }}. {%trans "Vote" %}</p>
<i>-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}</i>
<form action="" method="post">{% csrf_token %}
<table class="table" style="width: auto;">
<tr>
@ -57,6 +57,6 @@
<span class="icon cancel">{%trans 'Cancel' %}</span>
</button>
</a>
</form>
{% endblock %}

View File

@ -74,9 +74,9 @@
<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.undesided }}<br>
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ poll.votesinvalid }}<br>
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 5em;">
<img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> {{ poll.votescast }}
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ poll.votesinvalidf }}<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.votescastf }}
</div>
{% endfor %}
{% if perms.application.can_manage_application %}

View File

@ -145,7 +145,7 @@ def edit(request, application_id=None):
except Profile.DoesNotExist:
pass
if len(supporters_added) > 0:
log_added = _(", ".join(supporters_added))
log_added = ", ".join(supporters_added)
application.writelog(_("Supporter: +%s") % log_added, request.user)
# log removed supporters
supporters_removed = []

View File

@ -7,6 +7,7 @@
{% blocktrans count counter=options|length %}candidate{% plural %}candidates{% endblocktrans %}
</p>
<p><b>{% trans "Short description" %}:</b> {{ poll.description }}</p>
<i>-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}</i>
<form action="" method="post">{% csrf_token %}
<table class="table" style="width:auto;">
<tr>
@ -41,7 +42,7 @@
</tr>
</table>
<p>
<a href='{% url print_assignment_poll poll.id %}'>
<button type="button">
@ -49,7 +50,7 @@
</button>
</a>
</p>
<p>
<button type="submit">
<span class="icon ok">{%trans 'Save' %}</span>

View File

@ -125,22 +125,24 @@
<tr>
<th>{% trans "Candidates" %}</th>
{% for poll in assignment.poll_set.all %}
{% if poll.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %}
<th style="vertical-align: top; white-space:nowrap;">{% if perms.assignment.can_manage_assignment %}<a href="{% url assignment_poll_view poll.id %}">{% endif %}
{{ forloop.counter }}. {% trans 'ballot' %}
{% if perms.assignment.can_manage_assignment %}
</a>
{% if poll.published %}
<a href={% url assignment_poll_notpublish poll.id %}><img
src="/static/images/icons/user-online.png"
src="/static/images/icons/user-online.png"
title="{% trans 'Unpublish results' %}"></a>
{% else %}
<a href={% url assignment_poll_publish poll.id %}><img
src="/static/images/icons/user-offline.png"
src="/static/images/icons/user-offline.png"
title="{% trans 'Publish results' %}"></a>
{% endif %}
<a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a>
{% endif %}
</th>
{% endif %}
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<th>
@ -184,7 +186,7 @@
{% else %}&empty;{% endif %}
</td>
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
@ -192,18 +194,22 @@
<tr>
<td>{%trans 'Invalid votes' %}</td>
{% for p in polls %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalid }}</td>
{% if p.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalidf }}</td>
{% endif %}
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
<tr class="total">
<td><b>{%trans 'Votes cast' %}</b></td>
{% for p in polls %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescast }}</b></td>
{% if p.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescastf }}</b></td>
{% endif %}
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>

View File

@ -69,14 +69,15 @@ def view(request, assignment_id=None):
for candidate in assignment.candidates:
tmplist = [[candidate, assignment.is_elected(candidate)], []]
for poll in assignment.poll_set.all():
if candidate in poll.options_values:
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
if poll.optiondecision:
tmplist[1].append([option.yes, option.no, option.undesided])
if (poll.published and not request.user.has_perm('assignment.can_manage_assignment')) or request.user.has_perm('assignment.can_manage_assignment'):
if candidate in poll.options_values:
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
if poll.optiondecision:
tmplist[1].append([option.yes, option.no, option.undesided])
else:
tmplist[1].append(option.yes)
else:
tmplist[1].append(option.yes)
else:
tmplist[1].append("-")
tmplist[1].append("-")
votes.append(tmplist)
polls = []
@ -238,7 +239,6 @@ def poll_view(request, poll_id):
def set_published(request, poll_id, published=True):
try:
poll = Poll.objects.get(pk=poll_id)
print poll.published
poll.set_published(published)
if poll.published:
messages.success(request, _("Poll successfully set to published.") )
@ -246,7 +246,7 @@ def set_published(request, poll_id, published=True):
messages.success(request, _("Poll successfully set to unpublished.") )
except Poll.DoesNotExist:
messages.error(request, _('Poll ID %d does not exist.') % int(poll_id))
return redirect(reverse('assignment_view', args=[poll.id]))
return redirect(reverse('assignment_view', args=[poll.assignment.id]))
@permission_required('assignment.can_manage_assignment')
def delete_poll(request, poll_id):

File diff suppressed because it is too large Load Diff

View File

@ -4,32 +4,33 @@
{% block content %}
<h1>{% trans "Participants" %}</h1>
<p><form action="{{request.url}}" name="filter" method="get">
<p><form action="{{request.url}}" name="filter" method="post">
{% csrf_token %}
{%trans "Filter" %}:
<select class="default-input" name="gender" onchange="document.forms['filter'].submit()">
<option value="---">-- {%trans "Gender" %}--</option>
<option value="male" {% if 'male' in request.GET.gender %}selected{% endif %}>{%trans "Male" %}</option>
<option value="female" {% if 'female' in request.GET.gender %}selected{% endif %}>{%trans "Female" %}</option>
<option value="none" {% if 'none' in request.GET.gender %}selected{% endif %}>{%trans "Not specified" %}</option>
<option value="male" {% if 'male' in sortfilter.gender %}selected{% endif %}>{%trans "Male" %}</option>
<option value="female" {% if 'female' in sortfilter.gender %}selected{% endif %}>{%trans "Female" %}</option>
<option value="none" {% if 'none' in sortfilter.gender %}selected{% endif %}>{%trans "Not specified" %}</option>
</select>
<select class="default-input" name="group" onchange="document.forms['filter'].submit()">
<option value="---">-- {%trans "Group" %}--</option>
{% for group in groups %}
<option value="{{ group }}" {% if group in request.GET.group %}selected{% endif %}>
<option value="{{ group }}" {% if group in sortfilter.group %}selected{% endif %}>
{{ group }}</option>
{% endfor %}
</select>
<select class="default-input" name="type" onchange="document.forms['filter'].submit()">
<option value="---">-- {%trans "Type" %}--</option>
<option value="delegate" {% if 'delegate' in request.GET.type %}selected{% endif %}>{%trans "Delegate" %}</option>
<option value="observer" {% if 'observer' in request.GET.type %}selected{% endif %}>{%trans "Observer" %}</option>
<option value="staff" {% if 'staff' in request.GET.type %}selected{% endif %}>{%trans "Staff" %}</option>
<option value="guest" {% if 'guest' in request.GET.type %}selected{% endif %}>{%trans "Guest" %}</option>
<option value="delegate" {% if 'delegate' in sortfilter.type %}selected{% endif %}>{%trans "Delegate" %}</option>
<option value="observer" {% if 'observer' in sortfilter.type %}selected{% endif %}>{%trans "Observer" %}</option>
<option value="staff" {% if 'staff' in sortfilter.type %}selected{% endif %}>{%trans "Staff" %}</option>
<option value="guest" {% if 'guest' in sortfilter.type %}selected{% endif %}>{%trans "Guest" %}</option>
</select>
<select class="default-input" name="committee" onchange="document.forms['filter'].submit()">
<option value="---">-- {%trans "Committee" %}--</option>
{% for committee in committees %}
<option value="{{ committee }}" {% if committee in request.GET.committee %}selected{% endif %}>
<option value="{{ committee }}" {% if committee in sortfilter.committee %}selected{% endif %}>
{{ committee }}</option>
{% endfor %}
</select>
@ -38,15 +39,15 @@
{{ users|length }} {% trans "Participant" %}
<table>
<tr>
<th><a href="?sort=first_name{% if 'first_name' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "First Name" %}</a></th>
<th><a href="?sort=last_name{% if 'last_name' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Last Name" %}</a></th>
<th><a href="?sort=group{% if 'group' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Group" %}</a></th>
<th><a href="?sort=type{% if 'type' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Type" %}</a></th>
<th><a href="?sort=committee{% if 'committee' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Committee" %}</a></th>
<th><a href="?sort=first_name&reverse={% if 'first_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "First Name" %}</a></th>
<th><a href="?sort=last_name&reverse={% if 'last_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Last Name" %}</a></th>
<th><a href="?sort=group&reverse={% if 'group' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Group" %}</a></th>
<th><a href="?sort=type&reverse={% if 'type' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Type" %}</a></th>
<th><a href="?sort=committee&reverse={% if 'committee' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Committee" %}</a></th>
{% if perms.participant.can_manage_participant %}
<th><a href="?sort=username{% if 'username' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Username" %}</a></th>
<th><a href="?sort=email{% if 'email' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Email" %}</a></th>
<th><a href="?sort=last_login{% if 'last_login' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Last Login" %}</a></th>
<th><a href="?sort=username&reverse={% if 'username' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Username" %}</a></th>
<th><a href="?sort=email&reverse={% if 'email' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Email" %}</a></th>
<th><a href="?sort=last_login&reverse={% if 'last_login' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Last Login" %}</a></th>
<th>{%trans "Actions" %}</th>
{% endif %}
</tr>

View File

@ -11,6 +11,9 @@
"""
import csv
from urllib import urlencode
from urlparse import parse_qs
from django.http import HttpResponse
from django.shortcuts import redirect
from django.template import RequestContext
@ -33,24 +36,41 @@ from django.db.models import Avg, Max, Min, Count
@permission_required('participant.can_see_participant')
@template('participant/overview.html')
def get_overview(request):
query = User.objects
if 'gender' in request.GET and '---' not in request.GET['gender']:
query = query.filter(profile__gender__iexact=request.GET['gender'])
if 'group' in request.GET and '---' not in request.GET['group']:
query = query.filter(profile__group__iexact=request.GET['group'])
if 'type' in request.GET and '---' not in request.GET['type']:
query = query.filter(profile__type__iexact=request.GET['type'])
if 'committee' in request.GET and '---' not in request.GET['committee']:
query = query.filter(profile__committee__iexact=request.GET['committee'])
def decodedict(dict):
newdict = {}
for key in dict:
newdict[key] = [dict[key][0].encode('utf-8')]
return newdict
try:
sort = request.GET['sort']
if sort in ['first_name', 'last_name','username','last_login','email']:
query = query.order_by(sort)
elif sort in ['group', 'type', 'committee']:
query = query.order_by('profile__%s' % sort)
sortfilter = parse_qs(request.COOKIES['participant_sortfilter'])
except KeyError:
pass
if 'reverse' in request.GET:
sortfilter = {}
for value in [u'gender', u'group', u'type', u'committee', u'sort', u'reverse']:
if value in request.REQUEST:
if request.REQUEST[value] == '---':
try:
del sortfilter[value]
except KeyError:
pass
else:
sortfilter[value] = [request.REQUEST[value]]
query = User.objects
if 'gender' in sortfilter:
query = query.filter(profile__gender__iexact=sortfilter['gender'][0])
if 'group' in sortfilter:
query = query.filter(profile__group__iexact=sortfilter['group'][0])
if 'type' in sortfilter:
query = query.filter(profile__type__iexact=sortfilter['type'][0])
if 'committee' in sortfilter:
query = query.filter(profile__committee__iexact=sortfilter['committee'][0])
if 'sort' in sortfilter:
if sortfilter['sort'][0] in ['first_name', 'last_name','username','last_login','email']:
query = query.order_by(sortfilter['sort'][0])
elif sortfilter['sort'][0] in ['group', 'type', 'committee']:
query = query.order_by('profile__%s' % sortfilter['sort'][0])
if 'reverse' in sortfilter:
query = query.reverse()
userlist = query.all()
@ -67,6 +87,8 @@ def get_overview(request):
'users': users,
'groups': groups,
'committees': committees,
'cookie': ['participant_sortfilter', urlencode(decodedict(sortfilter), doseq=True)],
'sortfilter': sortfilter,
}
@permission_required('participant.can_manage_participant')

View File

@ -20,8 +20,8 @@ class PollForm(ModelForm):
error_css_class = 'error'
required_css_class = 'required'
votescast = IntegerField(required=False,widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast"))
invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
votescast = IntegerField(required=False, min_value=-2, widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast"))
invalid = IntegerField(required=False, min_value=-2, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
class Meta:
model = Poll
@ -42,6 +42,6 @@ class OptionResultForm(Form):
error_css_class = 'error'
required_css_class = 'required'
yes = IntegerField(min_value=-1, widget=TextInput(attrs={'class': 'small-input'}), label=_("Yes"))
no = IntegerField(min_value=-1, required=False, widget=TextInput(attrs={'class': 'small-input'}), label=_("No"))
undesided = IntegerField(min_value=-1, required=False, widget=TextInput(attrs={'class': 'small-input'}), label=_("Abstention"))
yes = IntegerField(min_value=-2, widget=TextInput(attrs={'class': 'small-input'}), label=_("Yes"))
no = IntegerField(min_value=-2, required=False, widget=TextInput(attrs={'class': 'small-input'}), label=_("No"))
undesided = IntegerField(min_value=-2, required=False, widget=TextInput(attrs={'class': 'small-input'}), label=_("Abstention"))

View File

@ -40,6 +40,22 @@ class Poll(models.Model):
optionc.save()
return optionc
@property
def votescastf(self):
if self.votescast == -2:
return _('undocumented')
elif self.votescast:
return self.votescast
return '0'
@property
def votesinvalidf(self):
if self.votesinvalid == -2:
return _('undocumented')
elif self.votesinvalid:
return self.votesinvalid
return '0'
def has_vote(self):
for option in self.options:
if option.voteyes or option.voteno or option.voteundesided:
@ -71,7 +87,7 @@ class Poll(models.Model):
if self.assignment:
return Poll.objects.filter(assignment=self.assignment).count()
return None
@property
def ballot(self):
if self.application:
@ -125,6 +141,8 @@ class Option(models.Model):
def yes(self):
if self.voteyes == -1:
return _('majority')
if self.voteyes == -2:
return _('undocumented')
if self.voteyes:
return self.voteyes
return '0'
@ -133,6 +151,8 @@ class Option(models.Model):
def no(self):
if self.voteno == -1:
return _('majority')
if self.voteno == -2:
return _('undocumented')
if self.voteno:
return self.voteno
return '0'
@ -141,6 +161,8 @@ class Option(models.Model):
def undesided(self):
if self.voteundesided == -1:
return _('majority')
if self.voteundesided == -2:
return _('undocumented')
if self.voteundesided:
return self.voteundesided
return '0'
@ -156,10 +178,6 @@ class Option(models.Model):
return None
def __unicode__(self):
if self.text != "" and self.text is not None:
return self.text
if self.user is not None:
return unicode(self.user)
if self.application is not None:
return unicode(self.application)
if self.value:
return unicode(self.value)
return _("No options")

View File

@ -36,7 +36,7 @@ from openslides.agenda.models import Item
from openslides.agenda.api import children_list
from openslides.application.models import Application
from openslides.assignment.models import Assignment
from openslides.poll.models import Poll
from openslides.poll.models import Poll, Option
from openslides.participant.models import Profile
from openslides.system.api import config_get
from openslides.settings import SITE_ROOT
@ -104,14 +104,14 @@ stylesheet.add(ParagraphStyle(name = 'Heading4',
stylesheet.add(ParagraphStyle(name = 'Item',
parent = stylesheet['Normal'],
fontSize = 14,
leading = 12,
leading = 14,
leftIndent = 0,
spaceAfter = 15)
)
stylesheet.add(ParagraphStyle(name = 'Subitem',
parent = stylesheet['Normal'],
fontSize = 10,
leading = 4,
leading = 10,
leftIndent = 20,
spaceAfter = 15)
)
@ -237,8 +237,11 @@ def print_agenda(request):
# print all items"
if item.parents:
space = ""
counter = 0
for p in item.parents:
space += "&nbsp;&nbsp;&nbsp;"
if counter != 0:
space += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
counter += 1
story.append(Paragraph(space+item.title, stylesheet['Subitem']))
else:
story.append(Paragraph(item.title, stylesheet['Item']))
@ -488,6 +491,25 @@ def print_application_poll(request, poll_id=None):
doc.build(story)
return response
def get_assignment_votes(assignment):
votes = []
for candidate in assignment.candidates:
tmplist = [[candidate, assignment.is_elected(candidate)], []]
for poll in assignment.poll_set.all():
if poll.published:
if candidate in poll.options_values:
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
if poll.optiondecision:
tmplist[1].append([option.yes, option.no, option.undesided])
else:
tmplist[1].append(option.yes)
else:
tmplist[1].append("-")
elif len(tmplist[1]) == 0:
return votes
votes.append(tmplist)
return votes
def get_assignment(assignment, story):
# title
story.append(Paragraph(_("Election")+": %s" % assignment.name, stylesheet['Heading1']))
@ -507,10 +529,74 @@ def get_assignment(assignment, story):
for x in range(0,2*assignment.posts):
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; __________________________________________",stylesheet['Signaturefield']))
cell2b.append(Spacer(0,0.2*cm))
# vote results
table_votes = []
results = get_assignment_votes(assignment)
cell3a = []
cell3a.append(Paragraph("%s:" % (_("Vote results")), stylesheet['Heading4']))
if len(results) > 0:
if len(results[0]) >= 1:
cell3a.append(Paragraph("%s %s" % (len(results[0][1]), _("ballots")), stylesheet['Normal']))
if len(results[0][1]) > 0:
data_votes = []
# add table head row
headrow = []
headrow.append(_("Candidates"))
for i in range (0,len(results[0][1])):
headrow.append("%s." %(str(i+1)))
data_votes.append(headrow)
# add result rows
for candidate in results:
row = []
row.append(str(candidate[0][0]))
for votes in candidate[1]:
if type(votes) == type(list()):
tmp = "list"
tmp = _("Yes")+": "+str(votes[0])+"\n"
tmp += _("No")+": "+str(votes[1])+"\n"
tmp += _("Abstention")+": "+str(votes[2])
row.append(tmp)
else:
row.append(str(votes))
data_votes.append(row)
polls = []
for poll in assignment.poll_set.filter(assignment=assignment):
polls.append(poll)
# votes invalid
row = []
row.append(_("Invalid votes"))
for p in polls:
if p.published:
row.append(p.votesinvalid)
data_votes.append(row)
# votes cast
row = []
row.append(_("Votes cast"))
for p in polls:
if p.published:
row.append(p.votescast)
data_votes.append(row)
table_votes=Table(data_votes)
table_votes.setStyle( TableStyle([
('GRID', (0,0), (-1,-1), 0.5, colors.grey),
('VALIGN',(0,0),(-1,-1), 'TOP'),
('LINEABOVE',(0,0),(-1,0),2,colors.black),
('LINEABOVE',(0,1),(-1,1),1,colors.black),
('LINEBELOW',(0,-1),(-1,-1),2,colors.black),
('ROWBACKGROUNDS', (0, 1), (-1, -1), (colors.white, (.9, .9, .9))),
]))
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
if table_votes:
data.append([cell3a,table_votes])
else:
data.append([cell2a,cell2b])
data.append([Spacer(0,0.2*cm),''])
t=Table(data)
t._argW[0]=4.5*cm
t._argW[1]=11*cm

View File

@ -49,7 +49,10 @@ def template(template_name):
output = func(request, *args, **kw)
if not isinstance(output, dict):
return output
return render_to_response(template_name, output, context_instance=RequestContext(request))
response = render_to_response(template_name, output, context_instance=RequestContext(request))
if 'cookie' in output:
response.set_cookie(output['cookie'][0], output['cookie'][1])
return response
return wrapper
return renderer