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

[#1005] Hide individual attachments #7327

Closed
wants to merge 21 commits into from

Conversation

gbp
Copy link
Member

@gbp gbp commented Sep 27, 2022

Relevant issue(s)

Requires #7324
Fixes #1005

What does this do?

  1. Adds attachment admin UI
  2. Adds prominence and reason to FoiAttachment
  3. Show prominence notice in frontend
  4. Add checks for attachments with prominence before downloading/viewed as HTML
  5. Prevents attachments with prominence from being indexed by Xapian

Why was this needed?

Easier admin of responses and attachments.

Screenshots

Incoming message admin

image

Attachment admin

image

Hidden attachment as public / Hidden attachment as requester

image

Hidden attachment as site admin

image

Requester only attachment as public

image

Requester only attachment as requester

image

Requester only attachment as site admin

image

Hidden main body attachment as public / Hidden main body attachment as requester

image

Hidden main body attachment as site admin

image

Requester only main body attachment as public

image

Requester only main body attachment as requester

image

Requester only main body attachment as site admin

image

@gbp gbp force-pushed the 1005-prep-for-attachment-prominence branch from 363c9e1 to 0b630ce Compare September 27, 2022 11:01
@gbp gbp force-pushed the 1005-hide-individual-attachments branch from 782edd7 to 9fad5b6 Compare September 27, 2022 12:47
Copy link
Member

@garethrees garethrees left a comment

Choose a reason for hiding this comment

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

This is looking great!!

Some minor comments inline, and a few more here.

Reduced prominence content is included in zip downloads and RSS feed (will also need to check a batch zip download):

Screenshot 2022-09-28 at 13 58 12

Screenshot 2022-09-28 at 13 59 44

Minor, but in some cases the attachment logo overflows its container:

Screenshot 2022-09-28 at 12 04 03

I don't quite understand what's going on with b0bcb87, so maybe one worth talking over when we next catch up.

app/helpers/admin/link_helper.rb Show resolved Hide resolved
<table class="table table-striped table-condensed">
<tbody>
<% @foi_attachment.for_admin_column(
:filename, :content_type, :charset, :display_size
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to render out the full admin column set?

app/views/admin/foi_attachments/edit.html.erb Outdated Show resolved Hide resolved
redirect_to edit_admin_incoming_message_path(@incoming_message)

else
render action: 'edit'
Copy link
Member

Choose a reason for hiding this comment

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

Should this come with some sort of indication that the update was unsuccessful?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't do this in the other admin controllers.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we do when we show model validation errors, but doesn't look like we're doing that here so a fail would be completely silent. I think we only need a error: 'Save unsuccessful' flash on the end of the render call.

app/models/foi_attachment.rb Outdated Show resolved Hide resolved
app/controllers/attachments_controller.rb Outdated Show resolved Hide resolved
app/models/incoming_message.rb Outdated Show resolved Hide resolved
app/views/request/hidden_attachment.html.erb Outdated Show resolved Hide resolved
spec/controllers/attachments_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/attachments_controller_spec.rb Outdated Show resolved Hide resolved
gbp added 16 commits October 7, 2022 14:52
Move specs into shared example block so these can be included within
other model's specs.
Take into account hidden or requester only prominence.
Requires a `message` local variable in order to be rendered.
Update the attachment caching to take place after the authentication. In
changing this a regression for returning a 'Directory listing not
allowed' error is introduced.

In order to fix the routes have been tightened up so we can simply check
for the present of `file_name` parameter.

Fixes #6477
We need to check attachment prominence when:
1. serving them directly or when converted to HTML
2. generating the Xapian index.
This is shared across all classes which include `MessageProminence` so
can be extracted.
@gbp gbp force-pushed the 1005-hide-individual-attachments branch from 857545f to 1e1e401 Compare October 7, 2022 14:35
@gbp gbp changed the base branch from 1005-prep-for-attachment-prominence to develop October 7, 2022 14:35
gbp added 4 commits October 18, 2022 13:14
Rename variable `message` to `prominenceable` as this will allow us to
use this partial for attachments as well as messages.
@gbp
Copy link
Member Author

gbp commented Oct 18, 2022

@garethrees this should be working now. There is loads of fixups do you want to see those or should I go ahead and rebase before you re-review?

@gbp
Copy link
Member Author

gbp commented Oct 18, 2022

Specs are green locally not sure why GitHub actions aren't running.

@gbp gbp requested a review from garethrees October 18, 2022 13:37
@garethrees
Copy link
Member

There is loads of fixups do you want to see those or should I go ahead and rebase before you re-review?

Happy to review as-is.

Specs are green locally not sure why GitHub actions aren't running.

Might be because of the merge conflict?

@garethrees
Copy link
Member

On running I get:

Screenshot 2022-10-21 at 15 43 45

Fixed with:

diff --git a/app/helpers/prominence_helper.rb b/app/helpers/prominence_helper.rb
index 2a26944b4..c81994e99 100644
--- a/app/helpers/prominence_helper.rb
+++ b/app/helpers/prominence_helper.rb
@@ -98,7 +98,7 @@ def default_prominence_reason
     end
   end

-  class InfoRequest::Prominence::Helper < Base # :nodoc:
+  class InfoRequest::Prominence::Helper < ProminenceHelper::Base # :nodoc:
     def user
       prominenceable.user
     end
@@ -166,6 +166,8 @@ def sign_in_notice(*args)

   ::OutgoingMessage::Prominence::Helper = IncomingMessage::Prominence::Helper

+  module FoiAttachment::Prominence ; end
+
   class FoiAttachment::Prominence::Helper < Base # :nodoc:
     def user
       prominenceable.incoming_message.info_request.user

@gbp
Copy link
Member Author

gbp commented Oct 21, 2022

On running I get:

Missed a file, pushed a fixup

Copy link
Member

@garethrees garethrees left a comment

Choose a reason for hiding this comment

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

As an admin user I though I should be able to see reduced-prominence main body parts below the prominence reason?

Screenshot 2022-10-21 at 16 25 47

I think this is getting quite a big and complicated PR, so maybe let's pair on this on Monday to get some of the more incidental parts merged, and then get left with just the main body of work that adds attachment prominence.

app/models/ability.rb Show resolved Hide resolved
app/models/incoming_message.rb Show resolved Hide resolved
@gbp
Copy link
Member Author

gbp commented Oct 24, 2022

Superseded by #7391

@gbp gbp closed this Oct 24, 2022
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.

Allow individual attachments to incoming messages to be hidden
2 participants