Skip to content

Commit

Permalink
Merge pull request galaxyproject#19394 from jdavcs/dev_deleted_users_…
Browse files Browse the repository at this point in the history
…items

Better handling of public pages and workflows authored by deleted users
  • Loading branch information
mvdbeek authored Jan 27, 2025
2 parents 40910b5 + c7c69ae commit c51a049
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 4 deletions.
15 changes: 15 additions & 0 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14740,6 +14740,11 @@ export interface components {
PageContentFormat: "markdown" | "html";
/** PageDetails */
PageDetails: {
/**
* Author deleted
* @description Whether the author of this Page has been deleted.
*/
author_deleted: boolean;
/**
* Content
* @description Raw text contents of the last page revision (type dependent on content_format).
Expand Down Expand Up @@ -14838,6 +14843,11 @@ export interface components {
};
/** PageSummary */
PageSummary: {
/**
* Author deleted
* @description Whether the author of this Page has been deleted.
*/
author_deleted: boolean;
/**
* Create Time
* Format: date-time
Expand Down Expand Up @@ -16387,6 +16397,11 @@ export interface components {
creator?:
| (components["schemas"]["Person"] | components["schemas"]["galaxy__schema__schema__Organization"])[]
| null;
/**
* Creator deleted
* @description Whether the creator of this Workflow has been deleted.
*/
creator_deleted: boolean;
/**
* Deleted
* @description Whether this item is marked as deleted.
Expand Down
11 changes: 9 additions & 2 deletions client/src/components/Common/PublishedItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Item {
owner?: string;
username?: string;
email_hash?: string;
author_deleted?: boolean;
tags?: string[];
title?: string;
}
Expand All @@ -37,8 +38,14 @@ const plural = computed(() => {
return `${modelTitle.value}s`;
});
const owner = computed(() => {
if (props.item?.author_deleted) {
return "Archived author";
}
return props.item?.owner ?? props.item?.username ?? "Unavailable";
});
const gravatarSource = computed(() => `https://secure.gravatar.com/avatar/${props.item?.email_hash}?d=identicon`);
const owner = computed(() => props.item?.owner ?? props.item?.username ?? "Unavailable");
const pluralPath = computed(() => plural.value.toLowerCase());
const publishedByUser = computed(() => `/${pluralPath.value}/list_published?f-username=${owner.value}`);
const urlAll = computed(() => `/${pluralPath.value}/list_published`);
Expand Down Expand Up @@ -76,7 +83,7 @@ const urlAll = computed(() => `/${pluralPath.value}/list_published`);
<router-link :to="urlAll">All published {{ plural }}</router-link>
</div>

<div>
<div v-if="!props.item?.author_deleted">
<router-link :to="publishedByUser"> Published {{ plural }} by {{ owner }}</router-link>
</div>
</div>
Expand Down
14 changes: 12 additions & 2 deletions client/src/components/Workflow/Published/WorkflowInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ const fullLink = computed(() => {
const userOwned = computed(() => {
return userStore.matchesCurrentUsername(props.workflowInfo.owner);
});
const owner = computed(() => {
if (props.workflowInfo?.creator_deleted) {
return "Archived author";
}
return props.workflowInfo.owner;
});
</script>

<template>
Expand All @@ -58,12 +65,15 @@ const userOwned = computed(() => {
<div class="workflow-info-box">
<hgroup class="mb-2">
<Heading h3 size="md" class="mb-0">Author</Heading>
<span class="ml-2">{{ workflowInfo.owner }}</span>
<span class="ml-2">{{ owner }}</span>
</hgroup>

<img alt="User Avatar" :src="gravatarSource" class="mb-2" />

<RouterLink :to="publishedByUser" :target="props.embedded ? '_blank' : ''">
<RouterLink
v-if="!props.workflowInfo?.creator_deleted"
:to="publishedByUser"
:target="props.embedded ? '_blank' : ''">
All published Workflows by {{ workflowInfo.owner }}
</RouterLink>
</div>
Expand Down
4 changes: 4 additions & 0 deletions lib/galaxy/managers/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def index_query(

stmt = select(self.model_class)

# Do not include pages authored by deleted users
if show_published:
stmt = stmt.join(Page.user).where(User.deleted == false())

filters = []
if show_own or (not show_published and not show_shared and not is_admin):
filters = [self.model_class.user == user]
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def index_query(
filters.append(StoredWorkflow.published == true())

stmt = select(StoredWorkflow)

# Do not include workflows authored by deleted users
if show_published or show_shared:
stmt = stmt.join(StoredWorkflow.user).where(User.deleted == false())

if show_shared:
stmt = stmt.outerjoin(StoredWorkflow.users_shared_with)
stmt = stmt.outerjoin(StoredWorkflow.tags)
Expand Down
7 changes: 7 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7842,6 +7842,7 @@ def to_dict(self, view="collection", value_mapper=None):
rval["latest_workflow_uuid"] = (lambda uuid: str(uuid) if self.latest_workflow.uuid else None)(
self.latest_workflow.uuid
)
rval["creator_deleted"] = self.user.deleted
return rval


Expand Down Expand Up @@ -10462,6 +10463,7 @@ class Page(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpdateTime):
"deleted",
"username",
"email_hash",
"author_deleted",
"create_time",
"update_time",
]
Expand All @@ -10488,6 +10490,11 @@ def username(self):
def email_hash(self):
return md5_hash_str(self.user.email)

# needed to determine how to display page details
@property
def author_deleted(self):
return self.user.deleted


class PageRevision(Base, Dictifiable, RepresentById):
__tablename__ = "page_revision"
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,11 @@ class PageSummary(PageSummaryBase, WithModelClass):
title="Encoded email",
description="The encoded email of the user.",
)
author_deleted: bool = Field(
..., # Required
title="Author deleted",
description="Whether the author of this Page has been deleted.",
)
published: bool = Field(
..., # Required
title="Published",
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/schema/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ class StoredWorkflowDetailed(StoredWorkflowSummary):
title="Creator",
description=("Additional information about the creator (or multiple creators) of this workflow."),
)
creator_deleted: bool = Field(
...,
title="Creator deleted",
description="Whether the creator of this Workflow has been deleted.",
)
steps: Dict[
int,
Annotated[
Expand Down

0 comments on commit c51a049

Please sign in to comment.