From 128de158888a6f0c760dedbe4ea228042fb68a9f Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Wed, 27 Jul 2022 11:40:53 -0700 Subject: [PATCH] fix owner not set bug for admin --- mpcontribs-api/mpcontribs/api/projects/views.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mpcontribs-api/mpcontribs/api/projects/views.py b/mpcontribs-api/mpcontribs/api/projects/views.py index 205729e5c..f4d267ffa 100644 --- a/mpcontribs-api/mpcontribs/api/projects/views.py +++ b/mpcontribs-api/mpcontribs/api/projects/views.py @@ -90,6 +90,7 @@ def has_add_permission(self, req, obj): if self.is_anonymous(req): return False + obj.owner = req.headers.get("X-Consumer-Username") groups = self.get_groups(req) is_admin = self.is_admin(groups) if is_admin: @@ -99,10 +100,6 @@ def has_add_permission(self, req, obj): if obj.is_approved: raise Unauthorized(f"Only admins can set `is_approved=True`") - # set owner to username - obj.owner = req.headers.get("X-Consumer-Username") - print("OWNER", obj.owner) - # limit the number of projects a user can own (unless admin) nr_projects = Projects.objects(owner=obj.owner).count() print("#PROJECTS", nr_projects)