some fixes

This commit is contained in:
Oskar Hahn 2012-09-12 10:17:51 +02:00
parent 93ee260856
commit 760f8e042e
7 changed files with 18 additions and 17 deletions

View File

@ -264,7 +264,7 @@ class Application(models.Model, SlideMixin):
ApplicationSupporter(application=self, person=person).save()
self.writelog(_("Supporter: +%s") % (person))
def unsupport(self, user):
def unsupport(self, person):
"""
remove a supporter from the list of supporters of the application
"""
@ -272,11 +272,11 @@ class Application(models.Model, SlideMixin):
# TODO: Use own Exception
raise NameError('This application is already permitted.')
try:
object = self.applicationsupporter_set.get(user=user).delete()
object = self.applicationsupporter_set.get(person=person).delete()
except ApplicationSupporter.DoesNotExist:
pass
else:
self.writelog(_("Supporter: -%s") % (user))
self.writelog(_("Supporter: -%s") % (person))
def set_number(self, number=None, user=None):
"""

View File

@ -264,7 +264,7 @@ def edit(request, application_id=None):
if request.user.has_perm('application.can_manage_application'):
messages.warning(request, _("Attention: Do you really want to edit this motion? The supporters will <b>not</b> be removed automatically because you can manage motions. Please check if the supports are valid after your changing!"))
else:
messages.warning(request, _("Attention: Do you really want to edit this motion? All <b>%s</b> supporters will be removed! Try to convince the supporters again.") % application.supporter.count() )
messages.warning(request, _("Attention: Do you really want to edit this motion? All <b>%s</b> supporters will be removed! Try to convince the supporters again.") % application.count_supporters() )
initial = {'title': application.title,
'text': application.text,
'reason': application.reason}
@ -372,7 +372,7 @@ def support(request, application_id):
support an application.
"""
try:
Application.objects.get(pk=application_id).support(user=request.user)
Application.objects.get(pk=application_id).support(person=request.user)
messages.success(request, _("You have support the motion successfully.") )
except Application.DoesNotExist:
pass
@ -386,7 +386,7 @@ def unsupport(request, application_id):
unsupport an application.
"""
try:
Application.objects.get(pk=application_id).unsupport(user=request.user)
Application.objects.get(pk=application_id).unsupport(person=request.user)
messages.success(request, _("You have unsupport the motion successfully.") )
except Application.DoesNotExist:
pass

View File

@ -131,9 +131,7 @@ class Assignment(models.Model, SlideMixin):
def get_participants(self, only_elected=False, only_candidate=False):
candidates = self.assignment_candidats.exclude(blocked=True)
if only_elected and only_candidate:
# TODO: Use right Exception
raise Exception("only_elected and only_candidate can not both be Treu")
assert not (only_elected and only_candidate)
if only_elected:
candidates = candidates.filter(elected=True)
@ -141,8 +139,11 @@ class Assignment(models.Model, SlideMixin):
if only_candidate:
candidates = candidates.filter(elected=False)
participants = []
for candidate in candidates.all():
yield candidate.person
participants.append(candidate.person)
return participants
#return candidates.values_list('person', flat=True)
def set_elected(self, person, value=True):

View File

@ -421,8 +421,8 @@ class AssignmentPDF(PDFView):
candidate_string = candidate.user.get_full_name()
if candidate in elected_candidates:
candidate_string = "* " + candidate_string
if candidate.group:
candidate_string += "\n(%s)" % candidate.group
if candidate.category:
candidate_string += "\n(%s)" % candidate.category
row.append(candidate_string)
for vote in poll_list:
if vote == None:
@ -581,8 +581,8 @@ class AssignmentPollPDF(PDFView):
candidate = option.candidate
cell.append(Paragraph(circle + candidate.user.get_full_name(),
stylesheet['Ballot_option_name']))
if candidate.group:
cell.append(Paragraph("(%s)" % candidate.group,
if candidate.category:
cell.append(Paragraph("(%s)" % candidate.category,
stylesheet['Ballot_option_group_right']))
else:
cell.append(Paragraph("&nbsp;",

View File

@ -94,7 +94,7 @@ class GroupForm(forms.ModelForm, CssClassMixin):
class UsersettingsForm(forms.ModelForm, CssClassMixin):
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email')
fields = ('username', 'first_name', 'last_name', 'email', 'gender')
class UserImportForm(forms.Form, CssClassMixin):

View File

@ -65,7 +65,7 @@
<tr>
<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 'category' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Category" %}</a></th>
<th><a href="?sort=category&reverse={% if 'category' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Category" %}</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 %}

View File

@ -236,7 +236,7 @@ def print_value(value, percent_base=0):
elif value == -2:
return unicode(_('undocumented'))
elif value is None:
return u''
return unicode(_('undocumented'))
if not percent_base:
return u'%s' % value