Skip to content

Commit

Permalink
fix owner not set bug for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Jul 27, 2022
1 parent de3a377 commit 128de15
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mpcontribs-api/mpcontribs/api/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 128de15

Please sign in to comment.