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

Add Apple publish status #994

Merged
merged 1 commit into from
Apr 11, 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
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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, I deleted the podcast.apple_config association in my PR. I should re-add that as a memoized method or something.

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
Loading