Skip to content

Conversation

@scottsds
Copy link
Member

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-3245 (Please fill in issue number and remove this comment.)

Purpose

Adds a check in the Works Controller to make sure a Collection isn't closed. If it is, and the User is not Owner or Moderator, it redirects them back to the collection index page with a message.

Credit

Scott (he/him)

@Bilka2 Bilka2 changed the title AO3-3245 - Manually entering the post link for a closed collection gives a misleading error AO3-3245 Manually entering the post link for a closed collection gives a misleading error Dec 15, 2025
Copy link
Contributor

@marcus8448 marcus8448 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

@unposted = current_user.unposted_work

# Check if collection is closed and user doesn't have permission to post
if @collection&.closed? && !@collection&.user_is_owner?(current_user) && !@collection&.user_is_maintainer?(current_user)
Copy link
Contributor

Choose a reason for hiding this comment

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

user_is_maintainer? should already include all owners.

edit_tags:
page_title: Edit Work Tags
new:
closed_collection_error: Sorry, the collection %{collection_title} is closed, new works cannot be added to it.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we prefer to not have an _error suffix on translation keys.

Suggested change
closed_collection_error: Sorry, the collection %{collection_title} is closed, new works cannot be added to it.
closed_collection: Sorry, the collection %{collection_title} is closed. New works cannot be added to it.

include LoginMacros
include RedirectExpectationHelper

describe "GET #new" do
Copy link
Contributor

Choose a reason for hiding this comment

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

The work spec is split across multiple files, so these tests should join the rest of the new tests in default_rails_actions_spec.rb:


before do
fake_login_known_user(user)
collection.collection_participants.create(pseud: user.default_pseud, participant_role: CollectionParticipant::OWNER)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be a bit nicer to create the participant in a let statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants