Skip to content

Commit

Permalink
Merge pull request #4807 from rtibbles/channel_details_modal
Browse files Browse the repository at this point in the history
Channel details modal fixes
  • Loading branch information
bjester authored Nov 12, 2024
2 parents 624963b + e18df39 commit 3ef9044
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 3ef9044

Please sign in to comment.