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() ApplicationSupporter(application=self, person=person).save()
self.writelog(_("Supporter: +%s") % (person)) self.writelog(_("Supporter: +%s") % (person))
def unsupport(self, user): def unsupport(self, person):
""" """
remove a supporter from the list of supporters of the application remove a supporter from the list of supporters of the application
""" """
@ -272,11 +272,11 @@ class Application(models.Model, SlideMixin):
# TODO: Use own Exception # TODO: Use own Exception
raise NameError('This application is already permitted.') raise NameError('This application is already permitted.')
try: try:
object = self.applicationsupporter_set.get(user=user).delete() object = self.applicationsupporter_set.get(person=person).delete()
except ApplicationSupporter.DoesNotExist: except ApplicationSupporter.DoesNotExist:
pass pass
else: else:
self.writelog(_("Supporter: -%s") % (user)) self.writelog(_("Supporter: -%s") % (person))
def set_number(self, number=None, user=None): 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'): 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!")) 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: 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, initial = {'title': application.title,
'text': application.text, 'text': application.text,
'reason': application.reason} 'reason': application.reason}
@ -372,7 +372,7 @@ def support(request, application_id):
support an application. support an application.
""" """
try: 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.") ) messages.success(request, _("You have support the motion successfully.") )
except Application.DoesNotExist: except Application.DoesNotExist:
pass pass
@ -386,7 +386,7 @@ def unsupport(request, application_id):
unsupport an application. unsupport an application.
""" """
try: 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.") ) messages.success(request, _("You have unsupport the motion successfully.") )
except Application.DoesNotExist: except Application.DoesNotExist:
pass pass

View File

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

View File

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

View File

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

View File

@ -65,7 +65,7 @@
<tr> <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=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=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=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> <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 %} {% if perms.participant.can_manage_participant %}

View File

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