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 is_admin = False
if user: if user:
try: try:
user.profile user = user.profile
except Profile.DoesNotExist: except Profile.DoesNotExist:
is_admin = True is_admin = True
except AttributeError: except AttributeError:

View File

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

View File

@ -97,11 +97,14 @@ def view(request, assignment_id=None):
else: else:
polls = assignment.poll_set.all() polls = assignment.poll_set.all()
vote_results = assignment.vote_results(only_published=False) vote_results = assignment.vote_results(only_published=False)
user = user2djangouser(request.user)
return { return {
'assignment': assignment, 'assignment': assignment,
'form': form, 'form': form,
'vote_results': vote_results, 'vote_results': vote_results,
'polls': polls, '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.set_password(self.firstpassword)
self.user.save() self.user.save()
def has_perm(self, perm):
return self.user.has_perm(perm)
@models.permalink @models.permalink
def get_absolute_url(self, link='edit'): def get_absolute_url(self, link='edit'):
""" """