Skip to content
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

#824 - fix the tags search in my workspace #836

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def check(self):

def search_qs(self, filter=None, q=None, tags=None, user_id=None, show_all=False, *args, **kwargs):
q_base = self.model.query

if filter and any(field for field, condition, value in filter if field.key == "publicable" and value):
pass
elif user_id is not None:
# Admins see all workspaces, non admin users can see only their own workspaces or shared with them
if not show_all:
q_base = q_base.filter_by(user_id=user_id)
q_base = q_base.union(q_base.filter(
WorkspaceEntity.collaborators.any(user_id=user_id)))
else:
q_base = q_base
else:
# No logged in user, show only public (in case was not specified)
q_base = q_base.filter(WorkspaceEntity.publicable == True)


if filter is not None:
if tags:
q_base = q_base.filter(
Expand All @@ -65,22 +81,7 @@ def search_qs(self, filter=None, q=None, tags=None, user_id=None, show_all=False
q_base = q_base.join(self.model.tags).filter(
func.lower(Tag.tag).in_(func.lower(t) for t in tags.split("+")))

if filter and any(field for field, condition, value in filter if field.key == "publicable" and value):
q1 = q_base

elif user_id is not None:
# Admins see all workspaces, non admin users can see only their own workspaces or shared with them
if not show_all:
q1 = q_base.filter_by(user_id=user_id)
q1 = q1.union(q_base.filter(
WorkspaceEntity.collaborators.any(user_id=user_id)))
else:
q1 = q_base
else:
# No logged in user, show only public (in case was not specified)
q1 = q_base.filter(WorkspaceEntity.publicable == True)

return q1.order_by(desc(WorkspaceEntity.timestamp_updated))
return q_base.order_by(desc(WorkspaceEntity.timestamp_updated))

def delete(self, id):
super().delete(id)
Expand Down
Loading