Skip to content

Commit

Permalink
Merge pull request #994 from PRX/feat/episode_apple_status
Browse files Browse the repository at this point in the history
Add Apple publish status
  • Loading branch information
kookster committed Apr 11, 2024
2 parents cdbafba + e9dd08e commit abb5541
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/helpers/episodes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ def episode_explicit_options
end
end

def episode_apple_status(episode)
if episode.apple_status.nil?
"not_found"
elsif episode.apple_status.delivered?
"complete"
else
"incomplete"
end
end

def episode_apple_updated_at(episode)
if episode.apple_status.nil?
Time.now
else
episode.apple_status.created_at
end
end

def episode_status_class(episode)
case episode.publishing_status_was
when "draft"
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/apple_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module AppleDelivery
alias_method :apple_status, :apple_episode_delivery_status
end

def publish_to_apple?
podcast.apple_config&.publish_to_apple?
end

def apple_update_delivery_status(attrs)
new_status = (apple_episode_delivery_status&.dup || apple_episode_delivery_statuses.build)
new_status.assign_attributes(**attrs)
Expand Down
13 changes: 13 additions & 0 deletions app/views/episodes/_form_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
<div class="col-12">
<%= render "form_dropdate", form: form, episode: episode %>
</div>

<% if episode.persisted? && episode.publish_to_apple? %>
<div class="col-12 mt-4">
<p class="status-text">
<strong><%= t(".apple_status") %>:</strong>
<span class="badge rounded-pill prx-badge-<%= episode_apple_status(episode) %>">
<%= t("helpers.label.episode.media_statuses.#{episode_apple_status(episode)}") %>
</span>
<br>
<%= local_time_ago(episode_apple_updated_at(episode)) %>
</p>
</div>
<% end %>
</div>

<div class="card-footer d-flex align-items-center justify-content-between">
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ en:
draft: Draft
published: Published
scheduled: Scheduled
apple_statuses:
complete: Complete
incomplete: Incomplete
not_found: Unknown
season_number: Season Number
segment_count: Number of Segments
subtitle: Subtitle
Expand Down Expand Up @@ -548,6 +552,7 @@ en:
title_published: Published
title_scheduled: Scheduled
unpublish: Unpublish
apple_status: Apple Status
form_tags:
title: Categories
help:
Expand Down

0 comments on commit abb5541

Please sign in to comment.