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

Channel details modal fixes #4807

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
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 @@ -390,7 +390,7 @@
this.currentChannel.publishing ||
!this.isChanged ||
!this.currentChannel.language ||
(this.rootNode && !this.rootNode.total_count)
(this.rootNode && !this.rootNode.resource_count)
);
},
publishButtonTooltip() {
Expand Down
15 changes: 8 additions & 7 deletions contentcuration/contentcuration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,12 +1570,15 @@ def get_details(self, channel_id=None):
.values("id")
)

# Get resources
resources = descendants.exclude(kind=content_kinds.TOPIC).order_by()

if channel_id:
channel = Channel.objects.filter(id=channel_id)[0]
else:
channel = self.get_channel()

if not descendants.exists():
if not resources.exists():
data = {
"last_update": pytz.utc.localize(datetime.now()).strftime(
settings.DATE_TIME_FORMAT
Expand Down Expand Up @@ -1604,8 +1607,6 @@ def get_details(self, channel_id=None):
cache.set("details_{}".format(self.node_id), json.dumps(data), None)
return data

# Get resources
resources = descendants.exclude(kind=content_kinds.TOPIC).order_by()
nodes = With(
File.objects.filter(contentnode_id__in=Subquery(resources.values("id")))
.values("checksum", "file_size")
Expand Down Expand Up @@ -1816,10 +1817,10 @@ def get_details(self, channel_id=None):
"sample_pathway": pathway,
"sample_nodes": sample_nodes,
# source model fields for the below default to an empty string, but can also be null
"authors": list(filter(bool, node["authors"])),
"aggregators": list(filter(bool, node["aggregators"])),
"providers": list(filter(bool, node["providers"])),
"copyright_holders": list(filter(bool, node["copyright_holders"])),
"authors": list(filter(bool, node["authors"] or [])),
"aggregators": list(filter(bool, node["aggregators"] or [])),
"providers": list(filter(bool, node["providers"] or [])),
"copyright_holders": list(filter(bool, node["copyright_holders"] or [])),
"levels": node.get("levels") or [],
"categories": node.get("all_categories") or [],
}
Expand Down