fix error in application-supporters an assignment-candidates, for non admin users

This commit is contained in:
Oskar Hahn 2012-08-06 14:58:52 +02:00
parent 1a1bcb2358
commit ab33b9f05a
4 changed files with 8 additions and 2 deletions

View File

@ -362,7 +362,7 @@ class Application(models.Model, SlideMixin):
is_admin = False
if user:
try:
user.profile
user = user.profile
except Profile.DoesNotExist:
is_admin = True
except AttributeError:

View File

@ -54,7 +54,7 @@
<form action="" method="post">{% csrf_token %}
{% if perms.assignment.can_nominate_self %}
<p>
{% if user in assignment.candidates %}
{% if user_is_candidate %}
<a href='{% url assignment_delrun assignment.id %}'>
<span class="button">
<span class="icon removeuser">{% trans 'Withdraw self candidature' %}</span>

View File

@ -97,11 +97,14 @@ def view(request, assignment_id=None):
else:
polls = assignment.poll_set.all()
vote_results = assignment.vote_results(only_published=False)
user = user2djangouser(request.user)
return {
'assignment': assignment,
'form': form,
'vote_results': vote_results,
'polls': polls,
'user_is_candidate': assignment.is_candidate(user)
}

View File

@ -58,6 +58,9 @@ class Profile(models.Model, UserMixin):
self.user.set_password(self.firstpassword)
self.user.save()
def has_perm(self, perm):
return self.user.has_perm(perm)
@models.permalink
def get_absolute_url(self, link='edit'):
"""