Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/parklab/refinery-platform
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
jkmarx committed Jun 22, 2015
2 parents 97c5421 + fe32361 commit f6b9fc0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions refinery/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def groups_with_user(self, user):
def has_access(self, user, res):
for i in self.groups_with_user(user):
perms = self.get_perms(res, i)
owner = res.get_owner()

if owner and owner.id == user.id:
return True

if perms['read'] or perms['change'] or res.is_public():
return True

Expand Down Expand Up @@ -115,10 +120,11 @@ def do_filtering(self, res_list, get_req_dict):
# Turns on certain things depending on flags
def build_res_list(self, user, res_list, request, **kwargs):
for i in res_list:
own = i.get_owner()
setattr(i, 'public', i.is_public())
setattr(i, 'owner_id', i.get_owner().id)
setattr(i, 'is_owner', i.get_owner().id == user.id)
setattr(i, 'owner_username', i.get_owner().username)
setattr(i, 'owner_id', None if own is None else own.id)
setattr(i, 'is_owner', None if own is None else own.id == user.id)
setattr(i, 'owner_username', None if own is None else own.username)

if 'sharing' in kwargs and kwargs['sharing']:
setattr(i, 'share_list', self.get_share_list(user, i))
Expand Down

0 comments on commit f6b9fc0

Please sign in to comment.