#105: Show Ballot number for applications. Some application PDF work. Set default config values.
This commit is contained in:
parent
9f70b2ff1c
commit
ee4d7da04a
|
@ -533,6 +533,7 @@ class ApplicationPoll(BasePoll, CountInvalid, CountVotesCast):
|
||||||
return reverse('application_poll_view', args=[self.id])
|
return reverse('application_poll_view', args=[self.id])
|
||||||
|
|
||||||
def get_ballot(self):
|
def get_ballot(self):
|
||||||
|
print "Ballot"
|
||||||
return self.application.applicationpoll_set.filter(id__lte=self.id).count()
|
return self.application.applicationpoll_set.filter(id__lte=self.id).count()
|
||||||
|
|
||||||
|
|
||||||
|
@ -546,5 +547,6 @@ def default_config(sender, key, **kwargs):
|
||||||
'application_min_supporters': 0,
|
'application_min_supporters': 0,
|
||||||
'application_preamble': 'Die Versammlung möge beschließen,',
|
'application_preamble': 'Die Versammlung möge beschließen,',
|
||||||
'application_pdf_ballot_papers_selection': '1',
|
'application_pdf_ballot_papers_selection': '1',
|
||||||
|
'application_pdf_ballot_papers_number': '0',
|
||||||
'application_pdf_title': _('Applications'),
|
'application_pdf_title': _('Applications'),
|
||||||
}.get(key)
|
}.get(key)
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{{ post_form }}
|
{{ post_form }}
|
||||||
|
<p></p>
|
||||||
<button class="button" type="submit">
|
<button class="button" type="submit">
|
||||||
<span class="icon ok">{%trans 'Save' %}</span>
|
<span class="icon ok">{%trans 'Save' %}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -385,52 +385,8 @@ def delete_poll(request, poll_id):
|
||||||
return redirect(reverse('application_view', args=[application.id]))
|
return redirect(reverse('application_view', args=[application.id]))
|
||||||
|
|
||||||
|
|
||||||
@permission_required('application.can_manage_application')
|
|
||||||
@template('application/poll_view.html')
|
|
||||||
def view_poll(request, poll_id):
|
|
||||||
"""
|
|
||||||
view a poll for this application.
|
|
||||||
"""
|
|
||||||
poll = ApplicationPoll.objects.get(pk=poll_id)
|
|
||||||
ballot = poll.ballot
|
|
||||||
options = poll.get_options()
|
|
||||||
if request.user.has_perm('application.can_manage_application'):
|
|
||||||
if request.method == 'POST':
|
|
||||||
form = PollForm(request.POST, prefix="poll")
|
|
||||||
if form.is_valid():
|
|
||||||
poll.votesinvalid = form.cleaned_data['invalid'] or 0
|
|
||||||
poll.votescast = form.cleaned_data['votescast'] or 0
|
|
||||||
poll.save()
|
|
||||||
|
|
||||||
for option in options:
|
|
||||||
option.form = OptionResultForm(request.POST,
|
|
||||||
prefix="o%d" % option.id)
|
|
||||||
if option.form.is_valid():
|
|
||||||
option.voteyes = option.form.cleaned_data['yes']
|
|
||||||
option.voteno = option.form.cleaned_data['no'] or 0
|
|
||||||
option.voteundesided = option.form. \
|
|
||||||
cleaned_data['undesided'] or 0
|
|
||||||
option.save()
|
|
||||||
messages.success(request, _("Votes are successfully saved.") )
|
|
||||||
if not 'apply' in request.POST:
|
|
||||||
return redirect(reverse('application_view', args=[poll.application.id]))
|
|
||||||
else:
|
|
||||||
form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
|
|
||||||
for option in options:
|
|
||||||
option.form = OptionResultForm(initial={
|
|
||||||
'yes': option.voteyes,
|
|
||||||
'no': option.voteno,
|
|
||||||
'undesided': option.voteundesided,
|
|
||||||
}, prefix="o%d" % option.id)
|
|
||||||
return {
|
|
||||||
'poll': poll,
|
|
||||||
'form': form,
|
|
||||||
'options': options,
|
|
||||||
'ballot': ballot,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ViewPoll(PollFormView):
|
class ViewPoll(PollFormView):
|
||||||
|
permission_required = 'application.can_manage_application'
|
||||||
poll_class = ApplicationPoll
|
poll_class = ApplicationPoll
|
||||||
template_name = 'application/poll_view.html'
|
template_name = 'application/poll_view.html'
|
||||||
|
|
||||||
|
@ -438,6 +394,7 @@ class ViewPoll(PollFormView):
|
||||||
context = super(ViewPoll, self).get_context_data(**kwargs)
|
context = super(ViewPoll, self).get_context_data(**kwargs)
|
||||||
self.application = self.poll.get_application()
|
self.application = self.poll.get_application()
|
||||||
context['application'] = self.application
|
context['application'] = self.application
|
||||||
|
context['ballot'] = self.poll.get_ballot()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
|
@ -727,7 +684,7 @@ class ApplicationPollPDF(PDFView):
|
||||||
return super(ApplicationPollPDF, self).get(request, *args, **kwargs)
|
return super(ApplicationPollPDF, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_filename(self):
|
def get_filename(self):
|
||||||
filename = u'filename=%s%s_%s.pdf;' % (_("Application"), str(self.poll.application.number), _("Poll"))
|
filename = u'%s%s_%s' % (_("Application"), str(self.poll.application.number), _("Poll"))
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def append_to_pdf(self, story):
|
def append_to_pdf(self, story):
|
||||||
|
@ -737,7 +694,7 @@ class ApplicationPollPDF(PDFView):
|
||||||
cell.append(Spacer(0,0.8*cm))
|
cell.append(Spacer(0,0.8*cm))
|
||||||
cell.append(Paragraph(_("Application No.")+" "+str(self.poll.application.number), stylesheet['Ballot_title']))
|
cell.append(Paragraph(_("Application No.")+" "+str(self.poll.application.number), stylesheet['Ballot_title']))
|
||||||
cell.append(Paragraph(self.poll.application.title, stylesheet['Ballot_subtitle']))
|
cell.append(Paragraph(self.poll.application.title, stylesheet['Ballot_subtitle']))
|
||||||
#cell.append(Paragraph(str(self.poll.ballot)+". "+_("Vote"), stylesheet['Ballot_description']))
|
cell.append(Paragraph(str(self.poll.get_ballot())+". "+_("Vote"), stylesheet['Ballot_description']))
|
||||||
cell.append(Spacer(0,0.5*cm))
|
cell.append(Spacer(0,0.5*cm))
|
||||||
cell.append(Paragraph(circle+_("Yes"), stylesheet['Ballot_option']))
|
cell.append(Paragraph(circle+_("Yes"), stylesheet['Ballot_option']))
|
||||||
cell.append(Paragraph(circle+_("No"), stylesheet['Ballot_option']))
|
cell.append(Paragraph(circle+_("No"), stylesheet['Ballot_option']))
|
||||||
|
@ -755,16 +712,17 @@ class ApplicationPollPDF(PDFView):
|
||||||
if ballot_papers_selection == "0":
|
if ballot_papers_selection == "0":
|
||||||
number = int(ballot_papers_number)
|
number = int(ballot_papers_number)
|
||||||
# print ballot papers
|
# print ballot papers
|
||||||
for user in xrange(number/2):
|
if number > 0:
|
||||||
data.append([cell,cell])
|
for user in xrange(number/2):
|
||||||
rest = number % 2
|
data.append([cell,cell])
|
||||||
if rest:
|
rest = number % 2
|
||||||
data.append([cell,''])
|
if rest:
|
||||||
t=Table(data, 10.5*cm, 7.42*cm)
|
data.append([cell,''])
|
||||||
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
t=Table(data, 10.5*cm, 7.42*cm)
|
||||||
|
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
||||||
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
||||||
]))
|
]))
|
||||||
story.append(t)
|
story.append(t)
|
||||||
|
|
||||||
|
|
||||||
class Config(FormView):
|
class Config(FormView):
|
||||||
|
|
|
@ -84,11 +84,14 @@ def default_config(sender, key, **kwargs):
|
||||||
return {
|
return {
|
||||||
'event_name': _('OpenSlides'),
|
'event_name': _('OpenSlides'),
|
||||||
'event_description': _('Presentation and voting system'),
|
'event_description': _('Presentation and voting system'),
|
||||||
|
'event_date': '',
|
||||||
|
'event_location': '',
|
||||||
|
'event_organizer': '',
|
||||||
'presentation': '',
|
'presentation': '',
|
||||||
'frontpage_title': _('Welcome'),
|
'frontpage_title': _('Welcome'),
|
||||||
'frontpage_welcometext': _('Welcome to OpenSlides!'),
|
'frontpage_welcometext': _('Welcome to OpenSlides!'),
|
||||||
'show_help_text': True,
|
'show_help_text': True,
|
||||||
'help_text': _('If you need any help wieth OpenSlides, you can find commercial support on our <a href="http://openslides.org/en/support">Webpage</a>.'),
|
'help_text': _('If you need any help with OpenSlides, you can find commercial support on the <a href="http://openslides.org/en/support">OpenSlides webpage</a>.'),
|
||||||
'system_enable_anonymous': False,
|
'system_enable_anonymous': False,
|
||||||
}.get(key)
|
}.get(key)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue