From 56da2a879e8816cd632e77ff027e125e96edac10 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Fri, 27 Mar 2026 20:53:41 -0500 Subject: [PATCH 01/12] If the user is a guest, fulfilled prompt works display as restricted --- app/views/prompts/_prompt_blurb.html.erb | 11 ++++++++++- config/locales/views/en.yml | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index d4834502206..a0fedfa02c0 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -86,7 +86,16 @@ diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index 5d48f12b2a1..5b3b1d2e2b9 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -2515,6 +2515,10 @@ en: edit_my_pseuds: Manage My Pseuds edit_my_works: Edit My Works edit_profile: Edit Profile + prompts: + prompt_blurb: + restricted: + work_unavailable: This work is only available to registered users of the Archive. pseuds: delete_preview: cancel: Cancel From feba22b74c671a797a869ea36f209a32840346e3 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 1 Apr 2026 12:45:01 -0500 Subject: [PATCH 02/12] Added scopes for pulling the fulfilled and restricted claims --- app/models/challenge_claim.rb | 3 +++ app/models/prompt.rb | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/app/models/challenge_claim.rb b/app/models/challenge_claim.rb index ea104c56d03..75909aafd97 100755 --- a/app/models/challenge_claim.rb +++ b/app/models/challenge_claim.rb @@ -71,6 +71,9 @@ def self.order_by_offering_pseud(dir="ASC") CollectionItem.user_approval_statuses[:approved], CollectionItem.collection_approval_statuses[:approved]) } + scope :fulfilled_restricted, -> { + fulfilled.where("works.restricted = 1") + } scope :posted, -> { joins(WORKS_JOIN).where("challenge_claims.creation_id IS NOT NULL AND works.posted = 1") } diff --git a/app/models/prompt.rb b/app/models/prompt.rb index cdae4bb6a4a..fb86eab117e 100755 --- a/app/models/prompt.rb +++ b/app/models/prompt.rb @@ -209,6 +209,10 @@ def fulfilled_claims self.request_claims.fulfilled end + def fulfilled_restricted_claims + self.request_claims.fulfilled_restricted + end + # Computes the "full" tag set (tag_set + optional_tag_set), and stores the # result as an instance variable for speed. This is used by the matching # algorithm, which doesn't change any signup/prompt/tagset information, so From d90677b45eb477988f1c31c20c8567f1b71a559d Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 1 Apr 2026 12:46:02 -0500 Subject: [PATCH 03/12] Updated prompt notice to look better when there's multiple restricted Works --- app/views/prompts/_prompt_blurb.html.erb | 11 +++++++---- config/locales/views/en.yml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index a0fedfa02c0..5ce3f39d023 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -84,16 +84,19 @@
<%= ts("Fulfilled By")%>
    - <% prompt.fulfilled_claims.map(&:creation).each do |creation| %> - <% if creation.is_a?(Work) %> - <% if guest? && creation.restricted %> + <% if guest? && prompt.fulfilled_restricted_claims.count > 0 %> +
  • <%= image_tag("lockblue.png", size: "15x15", alt: ts("(Restricted)"), title: ts("Restricted"), skip_pipeline: true) %> <%= t(".restricted.work_unavailable") %> - <% else%> +
  • + <% end %> + <% prompt.fulfilled_claims.map(&:creation).each do |creation| %> + <% if creation.is_a?(Work) %> + <% unless guest? && creation.restricted %> <%= render "works/work_blurb", :work => creation %> <% end %> <% end %> diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index 5b3b1d2e2b9..c50100f921f 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -2518,7 +2518,7 @@ en: prompts: prompt_blurb: restricted: - work_unavailable: This work is only available to registered users of the Archive. + work_unavailable: Some of these prompts are only available to registered users of the Archive. pseuds: delete_preview: cancel: Cancel From 8a307b54de13268eaf7b3c7f2922ca5d619a9f35 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 1 Apr 2026 13:11:29 -0500 Subject: [PATCH 04/12] Style - Lambda can be one line --- app/models/challenge_claim.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/challenge_claim.rb b/app/models/challenge_claim.rb index 75909aafd97..875bcd65e81 100755 --- a/app/models/challenge_claim.rb +++ b/app/models/challenge_claim.rb @@ -71,9 +71,7 @@ def self.order_by_offering_pseud(dir="ASC") CollectionItem.user_approval_statuses[:approved], CollectionItem.collection_approval_statuses[:approved]) } - scope :fulfilled_restricted, -> { - fulfilled.where("works.restricted = 1") - } + scope :fulfilled_restricted, -> { fulfilled.where("works.restricted = 1") } scope :posted, -> { joins(WORKS_JOIN).where("challenge_claims.creation_id IS NOT NULL AND works.posted = 1") } From b51471cdf3a8bc561b36e3ab8bb44e411f367d7d Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 1 Apr 2026 13:18:44 -0500 Subject: [PATCH 05/12] Change lock imagetag to match other code --- app/views/prompts/_prompt_blurb.html.erb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index 5ce3f39d023..3dda4d274ef 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -86,12 +86,8 @@
      <% if guest? && prompt.fulfilled_restricted_claims.count > 0 %>
    • - <%= image_tag("lockblue.png", size: "15x15", - alt: ts("(Restricted)"), - title: ts("Restricted"), - skip_pipeline: true) %> - - <%= t(".restricted.work_unavailable") %> + <%= image_tag("lockblue.png", size: "15x15", alt: "(Restricted)", title: "Restricted", skip_pipeline: true) %> + <%= t(".restricted.work_unavailable") %>
    • <% end %> <% prompt.fulfilled_claims.map(&:creation).each do |creation| %> From 8740292353236c039e515496f0fc4237e0307e0e Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 1 Apr 2026 13:31:58 -0500 Subject: [PATCH 06/12] Updated the hash syntax --- app/views/prompts/_prompt_blurb.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index 3dda4d274ef..ab92d8621a3 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -93,7 +93,7 @@ <% prompt.fulfilled_claims.map(&:creation).each do |creation| %> <% if creation.is_a?(Work) %> <% unless guest? && creation.restricted %> - <%= render "works/work_blurb", :work => creation %> + <%= render "works/work_blurb", work: creation %> <% end %> <% end %> <% end %> From b41ec5d7e5f5a6694dcdc13dfa422154191a37d6 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Sun, 12 Apr 2026 15:16:51 -0500 Subject: [PATCH 07/12] Do not render the "Fulfilled By" box for guests if there are no unrestricted claims --- app/models/challenge_claim.rb | 2 +- app/models/prompt.rb | 4 ++-- app/views/prompts/_prompt_blurb.html.erb | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/models/challenge_claim.rb b/app/models/challenge_claim.rb index 875bcd65e81..33e62b15f0c 100755 --- a/app/models/challenge_claim.rb +++ b/app/models/challenge_claim.rb @@ -71,7 +71,7 @@ def self.order_by_offering_pseud(dir="ASC") CollectionItem.user_approval_statuses[:approved], CollectionItem.collection_approval_statuses[:approved]) } - scope :fulfilled_restricted, -> { fulfilled.where("works.restricted = 1") } + scope :fulfilled_unrestricted, -> { fulfilled.where("works.restricted = 0") } scope :posted, -> { joins(WORKS_JOIN).where("challenge_claims.creation_id IS NOT NULL AND works.posted = 1") } diff --git a/app/models/prompt.rb b/app/models/prompt.rb index fb86eab117e..53c05c78c0f 100755 --- a/app/models/prompt.rb +++ b/app/models/prompt.rb @@ -209,8 +209,8 @@ def fulfilled_claims self.request_claims.fulfilled end - def fulfilled_restricted_claims - self.request_claims.fulfilled_restricted + def fulfilled_unrestricted_claims + self.request_claims.fulfilled_unrestricted end # Computes the "full" tag set (tag_set + optional_tag_set), and stores the diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index ab92d8621a3..00078c9fbd0 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -80,16 +80,10 @@ <% end %> <% # if prompt has been fulfilled list works %> - <% unless prompt.unfulfilled? %> + <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_unrestricted_claims.count < 1) %>
      <%= ts("Fulfilled By")%>
        - <% if guest? && prompt.fulfilled_restricted_claims.count > 0 %> -
      • - <%= image_tag("lockblue.png", size: "15x15", alt: "(Restricted)", title: "Restricted", skip_pipeline: true) %> - <%= t(".restricted.work_unavailable") %> -
      • - <% end %> <% prompt.fulfilled_claims.map(&:creation).each do |creation| %> <% if creation.is_a?(Work) %> <% unless guest? && creation.restricted %> From adb54b93c10b57648f42296f55bfd4458b8b3d67 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Sun, 12 Apr 2026 15:32:05 -0500 Subject: [PATCH 08/12] Remove newly unused string --- config/locales/views/en.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index c50100f921f..5d48f12b2a1 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -2515,10 +2515,6 @@ en: edit_my_pseuds: Manage My Pseuds edit_my_works: Edit My Works edit_profile: Edit Profile - prompts: - prompt_blurb: - restricted: - work_unavailable: Some of these prompts are only available to registered users of the Archive. pseuds: delete_preview: cancel: Cancel From 7a17a644f9fd7af717f040f641a0619182934156 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 22 Apr 2026 11:35:23 -0500 Subject: [PATCH 09/12] Change new scope to be chainable and have a more fitting name Co-Authored-By: sarken <907055+sarken@users.noreply.github.com> --- app/models/challenge_claim.rb | 3 ++- app/models/prompt.rb | 5 ++--- app/views/prompts/_prompt_blurb.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/challenge_claim.rb b/app/models/challenge_claim.rb index 33e62b15f0c..5841ee42843 100755 --- a/app/models/challenge_claim.rb +++ b/app/models/challenge_claim.rb @@ -71,7 +71,8 @@ def self.order_by_offering_pseud(dir="ASC") CollectionItem.user_approval_statuses[:approved], CollectionItem.collection_approval_statuses[:approved]) } - scope :fulfilled_unrestricted, -> { fulfilled.where("works.restricted = 0") } + # TODO: AO3-6024 for making sure we also exclude works hidden by admin + scope :work_visible_to_all, -> { where("works.restricted = 0") } scope :posted, -> { joins(WORKS_JOIN).where("challenge_claims.creation_id IS NOT NULL AND works.posted = 1") } diff --git a/app/models/prompt.rb b/app/models/prompt.rb index 53c05c78c0f..9f18cef92d8 100755 --- a/app/models/prompt.rb +++ b/app/models/prompt.rb @@ -209,10 +209,9 @@ def fulfilled_claims self.request_claims.fulfilled end - def fulfilled_unrestricted_claims - self.request_claims.fulfilled_unrestricted + def fulfilled_claims_visible_to_all + self.request_claims.fulfilled.work_visible_to_all end - # Computes the "full" tag set (tag_set + optional_tag_set), and stores the # result as an instance variable for speed. This is used by the matching # algorithm, which doesn't change any signup/prompt/tagset information, so diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index 00078c9fbd0..0e900569b3d 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -80,7 +80,7 @@ <% end %> <% # if prompt has been fulfilled list works %> - <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_unrestricted_claims.count < 1) %> + <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_claims_visible_to_all.count < 1) %>
        <%= ts("Fulfilled By")%>
          From 4e634e2e6683bbce60c1674664bc85966afa33ee Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 22 Apr 2026 11:35:53 -0500 Subject: [PATCH 10/12] Use empty check instead of count where possible Co-Authored-By: sarken <907055+sarken@users.noreply.github.com> --- app/views/prompts/_prompt_blurb.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index 0e900569b3d..be901dc41e7 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -80,7 +80,7 @@ <% end %> <% # if prompt has been fulfilled list works %> - <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_claims_visible_to_all.count < 1) %> + <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_claims_visible_to_all.empty?) %>
          <%= ts("Fulfilled By")%>
            From 67e22b1d8c9ad43d36ff0b057d721ba9b4cfa147 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Fri, 24 Apr 2026 19:13:10 -0500 Subject: [PATCH 11/12] Added feature test for restricted challenge claims --- .../challenge_promptmeme_posting_fills.feature | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature index 106a38dbe52..729601bd6d1 100755 --- a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature +++ b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature @@ -593,3 +593,21 @@ Feature: Prompt Meme Challenge And I uncheck "Battle 12 (prompter)" And I press "Update" Then I should see "For prompter." + + Scenario: When a prompt is filled with a restricted work, the work should only be visible to logged-in users + + Given I have Battle 12 prompt meme fully set up + When I am logged in as "myname1" + When I sign up for Battle 12 + When I am logged in as "myname2" + And I claim a prompt from "Battle 12" + And I start to fulfill my claim with "Restricted Fill" + And I lock the work + And I press "Post" + And I go to "Battle 12" collection's page + And I follow "Prompts (" + Then I should see "Fulfilled By" + When I log out + And I go to "Battle 12" collection's page + And I follow "Prompts (" + Then I should not see "Fulfilled By" From af9d27967d37fa45bcba7ba6e8c0524d6f42dbf1 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Mon, 27 Apr 2026 12:39:03 -0500 Subject: [PATCH 12/12] Clean up feature test based on feedback --- .../challenge_promptmeme_posting_fills.feature | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature index 729601bd6d1..ab084824435 100755 --- a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature +++ b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature @@ -597,17 +597,18 @@ Feature: Prompt Meme Challenge Scenario: When a prompt is filled with a restricted work, the work should only be visible to logged-in users Given I have Battle 12 prompt meme fully set up - When I am logged in as "myname1" - When I sign up for Battle 12 - When I am logged in as "myname2" + And I am logged in as "myname1" + And I sign up for Battle 12 + And I am logged in as "myname2" And I claim a prompt from "Battle 12" And I start to fulfill my claim with "Restricted Fill" And I lock the work And I press "Post" - And I go to "Battle 12" collection's page - And I follow "Prompts (" + When I view prompts for "Battle 12" Then I should see "Fulfilled By" + And I should see "Restricted Fill" When I log out And I go to "Battle 12" collection's page And I follow "Prompts (" Then I should not see "Fulfilled By" + And I should not see "Restricted Fill"