updated some parts of OpenSlides to the new user-api
This commit is contained in:
parent
465497ab30
commit
1a1bcb2358
@ -59,7 +59,7 @@
|
||||
{% if not forloop.last %}<br>{%endif%}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{{ application.submitter.profile }}</td>
|
||||
<td>{{ application.submitter }}</td>
|
||||
<td>{{ application.creation_time }}</td>
|
||||
<td>
|
||||
<span style="width: 1px; white-space: nowrap;">
|
||||
|
@ -53,7 +53,7 @@
|
||||
{% endwith %}
|
||||
|
||||
<p><b>{% trans "Submitter" %}:</b><br>
|
||||
{{ application.submitter.profile }}
|
||||
{{ application.submitter }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -748,13 +748,10 @@ class ApplicationPDF(PDFView):
|
||||
if application.status == "pub":
|
||||
cell1b.append(Paragraph("__________________________________________",stylesheet['Signaturefield']))
|
||||
cell1b.append(Spacer(0,0.1*cm))
|
||||
cell1b.append(Paragraph(" "+unicode(application.submitter.profile), stylesheet['Small']))
|
||||
cell1b.append(Paragraph(" "+unicode(application.submitter), stylesheet['Small']))
|
||||
cell1b.append(Spacer(0,0.2*cm))
|
||||
else:
|
||||
try:
|
||||
cell1b.append(Paragraph(unicode(application.submitter.profile), stylesheet['Normal']))
|
||||
except Profile.DoesNotExist:
|
||||
pass
|
||||
cell1b.append(Paragraph(unicode(application.submitter), stylesheet['Normal']))
|
||||
|
||||
# supporters
|
||||
cell2a = []
|
||||
@ -764,7 +761,7 @@ class ApplicationPDF(PDFView):
|
||||
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4']))
|
||||
|
||||
for supporter in application.supporters:
|
||||
cell2b.append(Paragraph("<seq id='counter'/>. %s" % unicode(s.profile), stylesheet['Signaturefield']))
|
||||
cell2b.append(Paragraph("<seq id='counter'/>. %s" % unicode(supporter), stylesheet['Signaturefield']))
|
||||
if application.status == "pub":
|
||||
for x in range(0,application.missing_supporters):
|
||||
cell2b.append(Paragraph("<seq id='counter'/>. __________________________________________",stylesheet['Signaturefield']))
|
||||
|
@ -16,7 +16,6 @@ from django.utils.translation import ugettext_lazy as _, ugettext_noop
|
||||
from openslides.utils.forms import CssClassMixin
|
||||
from openslides.utils.user import UserFormField
|
||||
|
||||
from openslides.participant.models import Profile
|
||||
from openslides.assignment.models import Assignment
|
||||
|
||||
|
||||
@ -26,7 +25,7 @@ class AssignmentForm(forms.ModelForm, CssClassMixin):
|
||||
|
||||
class Meta:
|
||||
model = Assignment
|
||||
exclude = ('status', 'profile', 'elected')
|
||||
exclude = ('status', 'elected')
|
||||
|
||||
|
||||
class AssignmentRunForm(forms.Form, CssClassMixin):
|
||||
|
@ -23,8 +23,6 @@ from openslides.config.signals import default_config_value
|
||||
from openslides.projector.api import register_slidemodel
|
||||
from openslides.projector.projector import SlideMixin
|
||||
|
||||
from openslides.participant.models import Profile
|
||||
|
||||
from openslides.poll.models import (BasePoll, CountInvalid, CountVotesCast,
|
||||
BaseOption, PublishPollMixin, BaseVote)
|
||||
|
||||
@ -71,28 +69,27 @@ class Assignment(models.Model, SlideMixin):
|
||||
self.status = status
|
||||
self.save()
|
||||
|
||||
def run(self, profile, user=None):
|
||||
def run(self, candidate, user=None):
|
||||
"""
|
||||
run for a vote
|
||||
"""
|
||||
if self.is_candidate(profile):
|
||||
raise NameError(_('<b>%s</b> is already a candidate.') % profile)
|
||||
# TODO: don't make any permission checks here.
|
||||
# Use other Exceptions
|
||||
if self.is_candidate(candidate):
|
||||
raise NameError(_('<b>%s</b> is already a candidate.') % candidate)
|
||||
if not user.has_perm("assignment.can_manage_assignment") and self.status != 'sea':
|
||||
raise NameError(_('The candidate list is already closed.'))
|
||||
AssignmentCandidate(assignment=self, user=profile, elected=False).save()
|
||||
AssignmentCandidate(assignment=self, user=candidate, elected=False).save()
|
||||
|
||||
def delrun(self, user):
|
||||
def delrun(self, candidate):
|
||||
"""
|
||||
stop running for a vote
|
||||
"""
|
||||
if self.status != 'sea':
|
||||
# TODO: Use an OpenSlides Error
|
||||
raise Exception(_('The candidate list is already closed.'))
|
||||
if self.is_candidate(user):
|
||||
assignment_candidats.get(user=user).delete()
|
||||
if self.is_candidate(candidate):
|
||||
self.assignment_candidats.get(user=candidate).delete()
|
||||
else:
|
||||
# TODO: Use an OpenSlides Error
|
||||
raise Exception(_('%s is no candidate') % user)
|
||||
raise Exception(_('%s is no candidate') % candidate)
|
||||
|
||||
def is_candidate(self, user):
|
||||
if self.assignment_candidats.filter(user=user).exists():
|
||||
|
@ -31,7 +31,7 @@
|
||||
<tr class="{% cycle '' 'odd' %}
|
||||
{% if assignment.active %}activeline{% endif %}">
|
||||
<td><a href="{% url assignment_view assignment.id %}">{{ assignment }}</a></td>
|
||||
<td>{{ assignment.profile.count }} / {{ assignment.posts }}</td>
|
||||
<td>{{ assignment.candidates|length }} / {{ assignment.posts }}</td>
|
||||
<td>{{ assignment.get_status_display }}</td>
|
||||
<td>
|
||||
<span style="width: 1px; white-space: nowrap;">
|
||||
|
@ -54,21 +54,18 @@
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
{% if perms.assignment.can_nominate_self %}
|
||||
<p>
|
||||
{% if user.profile in assignment.profile.all %}
|
||||
|
||||
<a href='{% url assignment_delrun assignment.id %}'>
|
||||
<span class="button">
|
||||
<span class="icon removeuser">{% trans 'Withdraw self candidature' %}</span>
|
||||
</span>
|
||||
</a>
|
||||
{% if user in assignment.candidates %}
|
||||
<a href='{% url assignment_delrun assignment.id %}'>
|
||||
<span class="button">
|
||||
<span class="icon removeuser">{% trans 'Withdraw self candidature' %}</span>
|
||||
</span>
|
||||
</a>
|
||||
{% else %}
|
||||
{% if user.profile %}
|
||||
<a href='{% url assignment_run assignment.id %}'>
|
||||
<span class="button">
|
||||
<span class="icon adduser">{% trans 'Self candidature' %}</span>
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href='{% url assignment_run assignment.id %}'>
|
||||
<span class="button">
|
||||
<span class="icon adduser">{% trans 'Self candidature' %}</span>
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@ -28,17 +28,17 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scrollcontent %}
|
||||
{% if not assignment.profile.exists %}
|
||||
{% if not assignment.candidates %}
|
||||
<p>
|
||||
<div class="text">{{ assignment.description|linebreaks }}</div>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if assignment.profile.exists and assignment.status != "fin" %}
|
||||
{% if assignment.candidates and assignment.status != "fin" %}
|
||||
<h3>{% trans "Candidates" %}</h3>
|
||||
<ol>
|
||||
{% for profile in assignment.profile.all|dictsort:"user.first_name" %}
|
||||
<li>{{ profile }} </li>
|
||||
{% for candidate in assignment.candidates %}
|
||||
<li>{{ candidate }} </li>
|
||||
{% empty %}
|
||||
<li style="list-style: none outside none;">
|
||||
<i>{% trans "No candidates available." %}</i>
|
||||
@ -122,7 +122,7 @@
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
{% elif assignment.profile.exists %}
|
||||
{% elif assignment.candidates %}
|
||||
<i>{% trans "No ballots available." %}</i>
|
||||
{% endif %}
|
||||
<br>
|
||||
|
@ -33,7 +33,9 @@ from openslides.utils.views import FormView, DeleteView, PDFView, RedirectView
|
||||
from openslides.utils.user import get_user
|
||||
|
||||
from openslides.config.models import config
|
||||
|
||||
from openslides.participant.models import Profile
|
||||
from openslides.participant.api import user2djangouser
|
||||
|
||||
from openslides.projector.projector import Widget
|
||||
|
||||
@ -169,13 +171,10 @@ def set_status(request, assignment_id=None, status=None):
|
||||
def run(request, assignment_id):
|
||||
assignment = Assignment.objects.get(pk=assignment_id)
|
||||
try:
|
||||
assignment.run(request.user.profile, request.user)
|
||||
assignment.run(user2djangouser(request.user), request.user)
|
||||
messages.success(request, _('You have set your candidature successfully.') )
|
||||
except NameError, e:
|
||||
messages.error(request, e)
|
||||
except Profile.DoesNotExist:
|
||||
messages.error(request,
|
||||
_("You can't candidate. Your user account is only for administration."))
|
||||
return redirect(reverse('assignment_view', args=[assignment_id]))
|
||||
|
||||
|
||||
@ -183,7 +182,10 @@ def run(request, assignment_id):
|
||||
def delrun(request, assignment_id):
|
||||
assignment = Assignment.objects.get(pk=assignment_id)
|
||||
try:
|
||||
assignment.delrun(request.user.profile)
|
||||
if assignment.status == 'sea' or user.has_perm("assignment.can_manage_assignment"):
|
||||
assignment.delrun(user2djangouser(request.user))
|
||||
else:
|
||||
messages.error(request, _('The candidate list is already closed.'))
|
||||
except Exception, e:
|
||||
messages.error(request, e)
|
||||
else:
|
||||
@ -370,7 +372,7 @@ class AssignmentPDF(PDFView):
|
||||
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset" \
|
||||
" id='counter'>" % _("Candidates"), stylesheet['Heading4']))
|
||||
cell2b = []
|
||||
for candidate in assignment.profile.all():
|
||||
for candidate in assignment.candidates:
|
||||
cell2b.append(Paragraph("<seq id='counter'/>. %s" % candidate,
|
||||
stylesheet['Signaturefield']))
|
||||
if assignment.status == "sea":
|
||||
|
Loading…
Reference in New Issue
Block a user