From ab33b9f05a8edb9270d5b0d1aec391118b487203 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 6 Aug 2012 14:58:52 +0200 Subject: [PATCH] fix error in application-supporters an assignment-candidates, for non admin users --- openslides/application/models.py | 2 +- openslides/assignment/templates/assignment/view.html | 2 +- openslides/assignment/views.py | 3 +++ openslides/participant/models.py | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openslides/application/models.py b/openslides/application/models.py index 4b45a5ed8..6da30fe23 100644 --- a/openslides/application/models.py +++ b/openslides/application/models.py @@ -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: diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html index 2614b26d6..cab930676 100644 --- a/openslides/assignment/templates/assignment/view.html +++ b/openslides/assignment/templates/assignment/view.html @@ -54,7 +54,7 @@
{% csrf_token %} {% if perms.assignment.can_nominate_self %}

- {% if user in assignment.candidates %} + {% if user_is_candidate %} {% trans 'Withdraw self candidature' %} diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 0b2ef82a0..6320c459b 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -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) } diff --git a/openslides/participant/models.py b/openslides/participant/models.py index 919e03b95..1913da474 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -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'): """