-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Link landscapes directly to shared files, links and visualizations #904
Conversation
1444cc8
to
2a351b3
Compare
def is_user_allowed_to_view_data_entry(data_entry, user): | ||
shared_resources = data_entry.shared_resources.all() | ||
for shared_resource in shared_resources: | ||
if is_target_member(user, shared_resource.target): | ||
return True | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can there be a case where there are multiple shared resources and the user is only a member of one of them? what happens then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulschreiber Yes, that can happen, so if the user has access to at least one of the targets where the resource is shared they can view it, that is why the algorithm exists early inside the for loop if the user is a member of any target.
group = Group.objects.get(slug=group_slug) | ||
except Group.DoesNotExist: | ||
target = model_class.objects.get(slug=target_slug) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can you specify a more specific exception type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
def resolve_source(self, info, **kwargs): | ||
return self.source | ||
|
||
def resolve_target(self, info, **kwargs): | ||
return self.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Curious why these resolve
methods are necessary, is this something to do with the ContentType
model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@david-code Yes, this has to do with the generic relationship, graphene is not able to do this automatically so it expects this to be defined explicitely
…re specific exception
8800c53
to
ed3430a
Compare
Description
Link landscapes directly to shared files, links and visualizations
Checklist
Related Issues
Related PRs