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

AO3-6058 Hide byline of unrevealed work in notes of child related work #3911

Closed
wants to merge 7 commits into from
Closed
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
16 changes: 11 additions & 5 deletions app/views/downloads/_download_preface.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@
<ul>
<% related_works.each do |work| %>
<li>
<% relation_text = work.translation ?
"A translation of %{work_link} by %{author_link}" :
"Inspired by %{work_link} by %{author_link}"
%>
<% work_info = if work.parent.unrevealed?
"a work in an unrevealed collection"
else
"%{work_link} by %{author_link}"
end
relation_text = if work.translation
"A translation of %{work_info}."
else
"Inspired by %{work_info}."
end %>
<% work_link = link_to work.parent.title.html_safe, url_for(work.parent) %>
<% author_link = byline(work.parent, visibility: 'public', only_path: false) %>

<%= ts(relation_text, work_link: work_link, author_link: author_link).html_safe %>
<%= ts(relation_text, work_link: work_link, author_link: author_link, work_info: work_info).html_safe %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work when the parent isn't unrevealed? I would have thought I18n would stop after the first substitution.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've spoke with Translation, and if it turns out it doesn't work, it would actually be better to have this i18ned like:

<% relation = work.translation ? "translation_of" : "inspired_by" %>

<% if work.parent.unrevealed? %>
  <%= t(".#{relation}.unrevealed") %>
<% else %>
  <%= t(".#{relation}.revealed", work_link: work_link, creator_link: author_link) %>
<% end %>

Giving Translation this:

  inspired_by:
    revealed: Inspired by %{work_link} by %{creator_link}.
    unrevealed: Inspired by a work in an unrevealed collection.
  translation_of:
    revealed: Translation of %{work_link} by %{creator_link}.
    unrevealed: Translation of a work in an unrevealed collection.

</li>
<% end %>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions app/views/works/_work_header_notes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

<% if related_work.parent.is_a?(ExternalWork) %>
<%= link_to related_work.parent.title.html_safe, related_work.parent %> by <%= byline(related_work.parent) %>.
<% elsif related_work.parent.unrevealed? %>
<%= ts("a work in an unrevealed collection.") %>
<% elsif related_work.parent.restricted? && !logged_in? %>
<%= ts("[Restricted Work] by") %> <%= byline(related_work.parent) %>. <%= ts("Log in to view.") %>
<% else %>
Expand Down
15 changes: 15 additions & 0 deletions features/works/work_related.feature
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,18 @@ Scenario: When a user is notified that a co-authored work has been inspired by a
And I should not see "A work in an unrevealed collection"
And I should not see "Worldbuilding Translated by translator"
And I should not see "From English to Deutsch"

Scenario: A work that is inspired by a work in an unrevealed collection does not list the title or creator of the unrevealed work in its notes
Given a hidden collection "Hidden"
And I have related works setup
When I am logged in as "inspiration"
And I add the work "Worldbuilding" to the collection "Hidden"
And I post a related work as remixer
When I view the work "Followup"
Then I should not see "Worldbuilding"
And I should not see "inspiration"
And I should see "Inspired by a work in an unrevealed collection."
And I follow "HTML"
Then I should not see "Worldbuilding"
And I should not see "inspiration"
And I should see "Inspired by a work in an unrevealed collection."