Automated merge with ssh://oshahn.de/openslides
This commit is contained in:
commit
d32fe2902d
@ -125,6 +125,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Candidates" %}</th>
|
<th>{% trans "Candidates" %}</th>
|
||||||
{% for poll in assignment.poll_set.all %}
|
{% 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 %}
|
<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' %}
|
{{ forloop.counter }}. {% trans 'ballot' %}
|
||||||
{% if perms.assignment.can_manage_assignment %}
|
{% if perms.assignment.can_manage_assignment %}
|
||||||
@ -141,6 +142,7 @@
|
|||||||
<a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a>
|
<a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
|
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
|
||||||
<th>
|
<th>
|
||||||
@ -192,7 +194,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{%trans 'Invalid votes' %}</td>
|
<td>{%trans 'Invalid votes' %}</td>
|
||||||
{% for p in polls %}
|
{% for p in polls %}
|
||||||
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalidf }}</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.votesinvalid }}</td>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if assignment.profile.exists 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>
|
<td></td>
|
||||||
@ -201,7 +205,9 @@
|
|||||||
<tr class="total">
|
<tr class="total">
|
||||||
<td><b>{%trans 'Votes cast' %}</b></td>
|
<td><b>{%trans 'Votes cast' %}</b></td>
|
||||||
{% for p in polls %}
|
{% for p in polls %}
|
||||||
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescastf }}</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.votescast }}</b></td>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if assignment.profile.exists 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>
|
<td></td>
|
||||||
|
@ -69,6 +69,7 @@ def view(request, assignment_id=None):
|
|||||||
for candidate in assignment.candidates:
|
for candidate in assignment.candidates:
|
||||||
tmplist = [[candidate, assignment.is_elected(candidate)], []]
|
tmplist = [[candidate, assignment.is_elected(candidate)], []]
|
||||||
for poll in assignment.poll_set.all():
|
for poll in assignment.poll_set.all():
|
||||||
|
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:
|
if candidate in poll.options_values:
|
||||||
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
|
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
|
||||||
if poll.optiondecision:
|
if poll.optiondecision:
|
||||||
@ -238,7 +239,6 @@ def poll_view(request, poll_id):
|
|||||||
def set_published(request, poll_id, published=True):
|
def set_published(request, poll_id, published=True):
|
||||||
try:
|
try:
|
||||||
poll = Poll.objects.get(pk=poll_id)
|
poll = Poll.objects.get(pk=poll_id)
|
||||||
print poll.published
|
|
||||||
poll.set_published(published)
|
poll.set_published(published)
|
||||||
if poll.published:
|
if poll.published:
|
||||||
messages.success(request, _("Poll successfully set to 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.") )
|
messages.success(request, _("Poll successfully set to unpublished.") )
|
||||||
except Poll.DoesNotExist:
|
except Poll.DoesNotExist:
|
||||||
messages.error(request, _('Poll ID %d does not exist.') % int(poll_id))
|
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')
|
@permission_required('assignment.can_manage_assignment')
|
||||||
def delete_poll(request, poll_id):
|
def delete_poll(request, poll_id):
|
||||||
|
@ -36,7 +36,7 @@ from openslides.agenda.models import Item
|
|||||||
from openslides.agenda.api import children_list
|
from openslides.agenda.api import children_list
|
||||||
from openslides.application.models import Application
|
from openslides.application.models import Application
|
||||||
from openslides.assignment.models import Assignment
|
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.participant.models import Profile
|
||||||
from openslides.system.api import config_get
|
from openslides.system.api import config_get
|
||||||
from openslides.settings import SITE_ROOT
|
from openslides.settings import SITE_ROOT
|
||||||
@ -488,6 +488,23 @@ def print_application_poll(request, poll_id=None):
|
|||||||
doc.build(story)
|
doc.build(story)
|
||||||
return response
|
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("-")
|
||||||
|
votes.append(tmplist)
|
||||||
|
return votes
|
||||||
|
|
||||||
def get_assignment(assignment, story):
|
def get_assignment(assignment, story):
|
||||||
# title
|
# title
|
||||||
story.append(Paragraph(_("Election")+": %s" % assignment.name, stylesheet['Heading1']))
|
story.append(Paragraph(_("Election")+": %s" % assignment.name, stylesheet['Heading1']))
|
||||||
@ -507,10 +524,46 @@ def get_assignment(assignment, story):
|
|||||||
for x in range(0,2*assignment.posts):
|
for x in range(0,2*assignment.posts):
|
||||||
cell2b.append(Paragraph("<seq id='counter'/>. __________________________________________",stylesheet['Signaturefield']))
|
cell2b.append(Paragraph("<seq id='counter'/>. __________________________________________",stylesheet['Signaturefield']))
|
||||||
cell2b.append(Spacer(0,0.2*cm))
|
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[1][1]) > 1:
|
||||||
|
cell3a.append(Paragraph("%s %s" % (len(results[1][1]), _("ballots")), stylesheet['Normal']))
|
||||||
|
if len(results[1][1]) > 0:
|
||||||
|
data_votes = []
|
||||||
|
# add table head row
|
||||||
|
headrow = []
|
||||||
|
headrow.append(_("Candidates"))
|
||||||
|
for i in range (0,len(results[1][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]:
|
||||||
|
row.append(str(votes))
|
||||||
|
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
|
# table
|
||||||
data = []
|
data = []
|
||||||
data.append([cell1a,cell1b])
|
data.append([cell1a,cell1b])
|
||||||
|
if not table_votes:
|
||||||
data.append([cell2a,cell2b])
|
data.append([cell2a,cell2b])
|
||||||
|
if table_votes:
|
||||||
|
data.append([cell3a,table_votes])
|
||||||
|
data.append([Spacer(0,0.2*cm),''])
|
||||||
t=Table(data)
|
t=Table(data)
|
||||||
t._argW[0]=4.5*cm
|
t._argW[0]=4.5*cm
|
||||||
t._argW[1]=11*cm
|
t._argW[1]=11*cm
|
||||||
|
Loading…
Reference in New Issue
Block a user