Merge pull request #21 from emanuelschuetze/master

3 fixes: missing number of supporters and attribute error for anonymous
This commit is contained in:
Oskar Hahn 2012-09-19 11:05:40 -07:00
commit 9c2400ac1a
4 changed files with 10 additions and 4 deletions

View File

@ -164,7 +164,10 @@ class Application(models.Model, SlideMixin):
yield object.person yield object.person
def is_supporter(self, person): def is_supporter(self, person):
try:
return self.applicationsupporter_set.filter(person=person).exists() return self.applicationsupporter_set.filter(person=person).exists()
except AttributeError:
return False
@property @property
def enough_supporters(self): def enough_supporters(self):

View File

@ -49,7 +49,7 @@
<td>{% if application.number %}{{ application.number }}{% else %}-{% endif %}</td> <td>{% if application.number %}{{ application.number }}{% else %}-{% endif %}</td>
<td><a href="{% url application_view application.id %}">{{ application.public_version.title }}</a></td> <td><a href="{% url application_view application.id %}">{{ application.public_version.title }}</a></td>
{% if min_supporters > 0 %} {% if min_supporters > 0 %}
<td>{{ application.supporter.count }}</td> <td>{{ application.count_supporters }}</td>
{% endif %} {% endif %}
<td>{% if application.status != "pub" %} <td>{% if application.status != "pub" %}
{{ application.get_status_display }}<br> {{ application.get_status_display }}<br>

View File

@ -466,7 +466,7 @@ class ApplicationDelete(DeleteView):
elif self.object: elif self.object:
if not 'delete' in self.object.get_allowed_actions(user=request.user): if not 'delete' in self.object.get_allowed_actions(user=request.user):
messages.error(request, _("You can not delete motion <b>%s</b>.") % self.object) messages.error(request, _("You can not delete motion <b>%s</b>.") % self.object)
else: elif self.get_answer() == 'yes':
title = self.object.title title = self.object.title
self.object.delete(force=True) self.object.delete(force=True)
messages.success(request, _("Motion <b>%s</b> was successfully deleted.") % title) messages.success(request, _("Motion <b>%s</b> was successfully deleted.") % title)

View File

@ -122,8 +122,11 @@ class Assignment(models.Model, SlideMixin):
""" """
return True, if person is a candidate. return True, if person is a candidate.
""" """
try:
return self.assignment_candidats.filter(person=person) \ return self.assignment_candidats.filter(person=person) \
.exclude(blocked=True).exists() .exclude(blocked=True).exists()
except AttributeError:
return False
def is_blocked(self, person): def is_blocked(self, person):
""" """