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 related work #4607

Merged
merged 32 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bd104e4
A related work should not break anonymity
Oct 25, 2020
069fb7c
Follow review
zz9pzza Oct 26, 2020
d54eb74
Improve senario title
zz9pzza Oct 26, 2020
2ea682a
Respect unrevealed collections in downloads
zz9pzza Dec 25, 2020
5b36bc3
Fix test
zz9pzza Dec 25, 2020
c045e17
Follow recomendations :)
zz9pzza Dec 29, 2020
4cb220d
fix test
zz9pzza Jan 3, 2021
cf1f610
AO3-6058 i18n and add tests for downloads
weeklies Aug 15, 2023
80d7a27
AO3-6058 External works use default formats
weeklies Aug 15, 2023
8873f6d
Remove deprecated .html suffix
weeklies Aug 16, 2023
3cd5c0e
Add more tests
weeklies Aug 16, 2023
58c01c1
AO3-6058 Hound
weeklies Aug 16, 2023
d0d0747
AO3-6058 First draft
weeklies Aug 16, 2023
3f3823d
AO3-6058 Fix some logic
weeklies Aug 16, 2023
00aae1c
AO3-6058 Make sure download URLS update
weeklies Aug 17, 2023
83368b2
AO3-6058 Feedback
weeklies Aug 20, 2023
2f94562
AO3-6058 Hi Reviewdog
weeklies Aug 20, 2023
19994d8
AO3-6058 Doggo
weeklies Aug 20, 2023
ae21bda
AO3-6058 oops
weeklies Aug 20, 2023
90994d5
AO3-6058 Feedback draft
weeklies Sep 15, 2023
a670bf3
AO3-6058 Add i18n hints
weeklies Sep 15, 2023
e311915
AO3-6058 Style fix
weeklies Sep 14, 2023
652fef6
AO3-6058 Hound
weeklies Sep 15, 2023
344e54b
AO3-6058 The sequel
weeklies Sep 15, 2023
db3d115
AO3-6058 Fixing
weeklies Sep 15, 2023
e6e7040
AO3-6058 Fix
weeklies Sep 15, 2023
246ca9e
AO3-6058 Fix
weeklies Sep 15, 2023
8a0b0bd
AO3-6058 Fix downloads not being able to render restricted notes
weeklies Sep 15, 2023
96f3123
AO3-6058 Avoid periods and update tests
weeklies Sep 19, 2023
7692484
AO3-6058 Merge branch 'master' into AO3-6058
weeklies Oct 21, 2023
9abb668
AO3-6058 Hardcode locale for downloads
weeklies Oct 21, 2023
564c5c1
Merge branch 'master' into AO3-6058
sarken Oct 29, 2023
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
33 changes: 33 additions & 0 deletions app/helpers/works_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,39 @@ def get_inspired_by(work)
work.approved_related_works.where(translation: false)
end

def related_work_note(related_work, relation, download: false)
weeklies marked this conversation as resolved.
Show resolved Hide resolved
work_link = link_to related_work.title, polymorphic_url(related_work)
language = tag.span(related_work.language.name, lang: related_work.language.short) if related_work.language
default_locale = download ? :en : nil
sarken marked this conversation as resolved.
Show resolved Hide resolved

creator_link = if download
byline(related_work, visibility: "public", only_path: false)
else
byline(related_work)
end

if related_work.respond_to?(:unrevealed?) && related_work.unrevealed?
if relation == "translated_to"
weeklies marked this conversation as resolved.
Show resolved Hide resolved
t(".#{relation}.unrevealed_html",
language: language)
else
t(".#{relation}.unrevealed",
locale: default_locale)
end
elsif related_work.restricted? && (download || !logged_in?)
t(".#{relation}.restricted_html",
language: language,
locale: default_locale,
creator_link: creator_link)
else
t(".#{relation}.revealed_html",
language: language,
locale: default_locale,
work_link: work_link,
creator_link: creator_link)
end
end

# Can the work be downloaded, i.e. is it posted and visible to all registered
# users.
def downloadable?
Expand Down
10 changes: 9 additions & 1 deletion app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def new_recipients_allow_gifts
after_save :moderate_spam
after_save :notify_of_hiding

after_save :notify_recipients, :expire_caches, :update_pseud_index, :update_tag_index, :touch_series
after_save :notify_recipients, :expire_caches, :update_pseud_index, :update_tag_index, :touch_series, :touch_related_works
after_destroy :expire_caches, :update_pseud_index

before_destroy :send_deleted_work_notification, prepend: true
Expand Down Expand Up @@ -923,6 +923,14 @@ def parents_after_saving
parent_work_relationships.reject(&:marked_for_destruction?)
end

def touch_related_works
return unless saved_change_to_in_unrevealed_collection?

# Make sure download URLs of child and parent works expire to preserve anonymity.
children.touch_all
parents_after_saving.each { |rw| rw.parent.touch }
end

#################################################################################
#
# In this section we define various named scopes that can be chained together
Expand Down
19 changes: 12 additions & 7 deletions app/views/downloads/_download_afterword.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
</div>
<% end %>

<% unless @work.approved_children.blank? %>
<%# i18n-tasks-use t("downloads.download_afterword.inspired_by.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_afterword.inspired_by.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_afterword.inspired_by.unrevealed") %>
<% if @work.approved_children.present? %>
<dl>
<dt><%= ts('Works inspired by this one') %></dt>
<dd>
<%= @work.approved_related_works.where(:translation => false).map{|rw|
"#{link_to(rw.work.title.html_safe, work_url(rw.work))} #{ts('by')} #{byline(rw.work, visibility: 'public', only_path: false)}"}.join(",
").html_safe %>
</dd>
<dt><%= t(".inspired_by.title") %></dt>
<% for child_work in @work.approved_related_works %>
<% next if child_work.translation %>

<dd>
<%= related_work_note(child_work.work, "inspired_by", download: true) %>
</dd>
<% end %>
</dl>
<% end %>
</div>
Expand Down
16 changes: 8 additions & 8 deletions app/views/downloads/_download_preface.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@
<% end %>
<% end %>

<%# i18n-tasks-use t("downloads.download_preface.inspired_by.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_preface.inspired_by.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_preface.inspired_by.unrevealed") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.unrevealed") %>
<% related_works = @work.parent_work_relationships.reject { |wr| !wr.parent } %>
<% if related_works.length > 0 %>
<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_link = link_to work.parent.title.html_safe, polymorphic_url(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 %>
<% relation = work.translation ? "translation_of" : "inspired_by" %>
<%= related_work_note(work.parent, relation, download: true) %>
</li>
<% end %>
</ul>
Expand Down
30 changes: 9 additions & 21 deletions app/views/works/_work_approved_children.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
<!--approved children-->

<div id="children" class="children module">
<h3 class="heading"><%= ts('Works inspired by this one:') %></h3>
<h3 class="heading"><%= t(".inspired_by.title") %>:</h3>
<ul>
<% for child_work in inspired_by %>
<li>
<% if child_work.work.is_a?(ExternalWork) %>
<%= link_to child_work.work.title.html_safe, child_work.work %> <%= ts("by") %> <%= byline(child_work.work) %>
<% if child_work.translation %>
<%= ts("(translation into %{language})", language: tag.span(child_work.work.language.name, lang: child_work.work.language.short)).html_safe %>
<% end %>
<% elsif child_work.work.restricted? && !logged_in? %>
<%= ts("A [Restricted Work] by") %> <%= byline(child_work.work) %>
<% if child_work.translation %>
<%= ts("(translation into %{language})", language: tag.span(child_work.work.language.name, lang: child_work.work.language.short)).html_safe %>
<% end %> <%= ts("Log in to view.") %>
<% else %>
<%= link_to child_work.work.title.html_safe, child_work.work %> <%= ts("by") %> <%= byline(child_work.work) %>
<% if child_work.translation %>
<%= ts("(translation into %{language})", language: tag.span(child_work.work.language.name, lang: child_work.work.language.short)).html_safe %>
<% end %>
<% end %>
</li>
<% end %>
<%# i18n-tasks-use t("works.work_approved_children.inspired_by.restricted_html") %>
<%# i18n-tasks-use t("works.work_approved_children.inspired_by.revealed_html") %>
<%# i18n-tasks-use t("works.work_approved_children.inspired_by.unrevealed") %>
<% for child_work in inspired_by %>
<li>
<%= related_work_note(child_work.work, "inspired_by") %>
</li>
<% end %>
</ul>
</div>
32 changes: 12 additions & 20 deletions app/views/works/_work_header_notes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,31 @@
<% end %>

<% # translations %>
<%# i18n-tasks-use t("works.work_header_notes.translated_to.restricted_html") %>
<%# i18n-tasks-use t("works.work_header_notes.translated_to.revealed_html") %>
<%# i18n-tasks-use t("works.work_header_notes.translated_to.unrevealed_html") %>
<% for related_work in @work.approved_related_works %>
<% if related_work.translation %>
<li>
<%= ts("Translation into %{language} available: ",
language: tag.span(related_work.work.language.name, lang: related_work.work.language.short)).html_safe %>
<% if related_work.work.restricted? && !logged_in? %>
<%= ts("[Restricted Work] by") %> <%= byline(related_work.work) %>. <%= ts("Log in to view.") %>
<% else %>
<%= link_to related_work.work.title.html_safe, related_work.work %> <%= ts("by") %> <%= byline(related_work.work) %>
<% end %>
<%= related_work_note(related_work.work, "translated_to") %>
</li>
<% else %>
<% related_works_link ||= link_to ts("other works inspired by this one"), get_related_works_url %>
<% end %>
<% end %>

<% # parent works %>
<%# i18n-tasks-use t("works.work_header_notes.translation_of.restricted_html") %>
<%# i18n-tasks-use t("works.work_header_notes.translation_of.revealed_html") %>
<%# i18n-tasks-use t("works.work_header_notes.translation_of.unrevealed") %>
<%# i18n-tasks-use t("works.work_header_notes.inspired_by.restricted_html") %>
<%# i18n-tasks-use t("works.work_header_notes.inspired_by.revealed_html") %>
<%# i18n-tasks-use t("works.work_header_notes.inspired_by.unrevealed") %>
<% for related_work in @work.parents_after_saving %>
<% if related_work.parent %>
<li>
<% if related_work.translation %>
<%= ts('A translation of') %>
<% else %>
<%= ts('Inspired by') %>
<% end %>

<% 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.restricted? && !logged_in? %>
<%= ts("[Restricted Work] by") %> <%= byline(related_work.parent) %>. <%= ts("Log in to view.") %>
<% else %>
<%= link_to related_work.parent.title.html_safe, related_work.parent %> <%= ts("by") %> <%= byline(related_work.parent) %>.
<% end %>
<% relation = related_work.translation ? "translation_of" : "inspired_by" %>
<%= related_work_note(related_work.parent, relation) %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ ignore_missing:
# File: app/views/pseuds/show.html.erb
- pseuds.show.edit_link
- pseuds.show.index_link
# File: app/views/series/manage.html.er
# File: app/views/series/manage.html.erb
- series.manage.manage_series

## Consider these keys used:
Expand Down
33 changes: 33 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,22 @@ en:
unrevealed: Sorry, you can't add or edit comments on an unrevealed work.
downloads:
download_afterword:
inspired_by:
restricted_html: "[Restricted Work] by %{creator_link}"
revealed_html: "%{work_link} by %{creator_link}"
title: Works inspired by this one
unrevealed: A work in an unrevealed collection
please_comment_html: Please %{work_comment_link} to let the creator know if you enjoyed their work!
work_comment: drop by the Archive and comment
download_preface:
inspired_by:
restricted_html: Inspired by [Restricted Work] by %{creator_link}
revealed_html: Inspired by %{work_link} by %{creator_link}
unrevealed: Inspired by a work in an unrevealed collection
translation_of:
restricted_html: A translation of [Restricted Work] by %{creator_link}
revealed_html: A translation of %{work_link} by %{creator_link}
unrevealed: A translation of a work in an unrevealed collection
feedbacks:
new:
abuse:
Expand Down Expand Up @@ -771,5 +785,24 @@ en:
unrestricted: Show to all
show:
unposted_deletion_notice_html: This work is a draft and has not been posted. The draft will be <strong>scheduled for deletion</strong> on %{deletion_date}.
work_approved_children:
inspired_by:
restricted_html: "[Restricted Work] by %{creator_link} (Log in to access.)"
revealed_html: "%{work_link} by %{creator_link}"
title: Works inspired by this one
unrevealed: A work in an unrevealed collection
work_header_notes:
inspired_by:
restricted_html: Inspired by [Restricted Work] by %{creator_link} (Log in to access.)
revealed_html: Inspired by %{work_link} by %{creator_link}
unrevealed: Inspired by a work in an unrevealed collection
translated_to:
restricted_html: 'Translation into %{language} available: [Restricted Work] by %{creator_link} (Log in to access.)'
revealed_html: 'Translation into %{language} available: %{work_link} by %{creator_link}'
unrevealed_html: 'Translation into %{language} available: A work in an unrevealed collection'
translation_of:
restricted_html: A translation of [Restricted Work] by %{creator_link} (Log in to access.)
revealed_html: A translation of %{work_link} by %{creator_link}
unrevealed: A translation of a work in an unrevealed collection
work_module:
draft_deletion_notice_html: This draft will be <strong>scheduled for deletion</strong> on %{deletion_date}.
21 changes: 18 additions & 3 deletions features/step_definitions/work_related_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

Given /^an inspiring parent work has been posted$/ do
step %{I post an inspiring parent work as testy}
step "I post an inspiring parent work as testuser"
end

# given for remixes / related works
Expand All @@ -42,7 +42,7 @@

### WHEN

When /^I post an inspiring parent work as testy$/ do
When "I post an inspiring parent work as testuser" do
step %{I am logged in as "testuser"}
step %{I post the work "Parent Work"}
end
Expand Down Expand Up @@ -159,12 +159,22 @@
step %{I should see "Followup by remixer" within ".afterword .children"}
end

Then "I should see the related work listed on the original work" do
step %{I should see "See the end of the work for other works inspired by this one"}
step %{I should see "Works inspired by this one:"}
step %{I should see "Followup by remixer"}
end

Then /^I should not see the related work listed on the original work$/ do
step %{I should not see "See the end of the work for other works inspired by this one"}
step %{I should not see "Works inspired by this one:"}
step %{I should not see "Followup by remixer"}
end

Then "I should not see the inspiring parent work in the beginning notes" do
step %{I should not see "Inspired by Parent Work by testuser" within ".preface .notes"}
end

# then for translations

Then /^a parent translated work should be seen$/ do
Expand All @@ -173,11 +183,16 @@
step %{I should see "A translation of Worldbuilding by inspiration" within ".preface .notes"}
end

Then /^I should see the translation in the beginning notes$/ do
Then "I should see the translation in the beginning notes" do
step %{I should see "Translation into Deutsch available:" within ".preface .notes"}
step %{I should see "Worldbuilding Translated by translator" within ".preface .notes"}
end

Then "I should see the translation listed on the original work" do
step %{I should see "Translation into Deutsch available:"}
step %{I should see "Worldbuilding Translated by translator"}
end

Then /^I should not see the translation listed on the original work$/ do
step %{I should not see "Translation into Deutsch available:"}
step %{I should not see "Worldbuilding Translated by translator"}
Expand Down
Loading
Loading