Comments you submit will be routed for moderation. If you have an account, please log in first.
Modify

Ticket #3824 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Allow moderated users to submit attachments without moderation

Reported by: steven.studniarz@… Owned by: jdsiiro
Priority: major Milestone: TracTicketModerator 1.0
Component: TracTicketModerator Version: TracTicketModerator 0.2
Keywords: Cc:

Description

When checking the box for "I have files to attach to this ticket", the user is not redirected to the page for adding attachments, but instead straight to the page alerting them that the ticket has been submitted for moderation.

Perhaps this is temporarily by design? If so, consider this ticket a request to get attachments working ASAP.

Thanks!

Attachments

Change History

comment:1 Changed 5 years ago by jdsiiro

Is this behavior observed for moderated users or unmoderated users (i.e. users with the MODERATOR_UNMODERATED permission)?

Users that do not require moderation should still be able to submit attachments as usual. The TicketModerator currently prevents moderated users from submitting attachments to submit attachments (see #3807). I believe that the plugin should actually strip the "I have files to attach" checkbox from moderated users -- if it is not, then that is a bug that should be fixed.

comment:2 Changed 5 years ago by steven.studniarz@…

Normal (UNMODERATED) users are able to submit attachments.

The "I have files to attach" checkbox can be toggled on and off by granting permission for TICKET_APPEND. I currently have authenticated users as UNMODERATED (and they also have TICKET_APPEND permissions). Thusly authenticated users are able to submit unmoderated tickets (and attachments). Anonymous users submit moderated tickets and currently do not have the option to attach files.

For our purposes (and we feel it may be the case for others), attaching files to tickets is a pretty important feature to have. We are using this plugin as a bit of a firewall to separate "external" tickets from our internal software team's tickets, and selectively allowing them in to our internal team. If an external user can not submit an attachment (such as a log file, code output product, etc), they may be forced to copy/paste the information into the description field of the ticket (which will lead to VERY big, messy tickets). This is pretty much a dealbreaker for us.

For my needs, a moderator doesn't necessarily need to be able to moderate attachments (are you talking about selectively deleting files to a ticket)? It's MUCH more important to us that a moderated user be able to submit an attachment, though... This seems like it would be a fairly straightforward feature to implement.

comment:3 Changed 5 years ago by jdsiiro

  • Summary changed from Attachments to tickets not working to Allow moderated users to submit attachments without moderation

OK - I see what you are doing. For your purposes, the easiest thing will be to provide a configuration option to disable the block on attachments for moderated users. That will at least allow moderated users to attach files to existing tickets.

Unfortunately, enabling the "I have files to attach" button for moderated users is going to be significantly more difficult. There are lots of reasons (and I can get into the details if you want to), but it boils down to Trac using completely different subsystems for managing tickets and attachments. In the normal (unmoderated) case, when you select that checkbox, Trac creates the ticket and then immediately redirects the user to the "Attach file" handler. This is hard to emulate in the moderated case, as there is no ticket to attach the file to. Further, I have to figure out a strategy for usurping the normal attachment system to store the attachments in a location that can be viewed by the Moderator, but not by any one else (even if directly accessed through a hand-crafted URL). Regardless, I would like to move this discussion over to the original ticket (#3807).

So, here's my plan: I am leaving this ticket open and renaming it to "Allow moderated users to submit attachments without moderation". It will track what I covered in the first paragraph. Ticket #3807 will continue to track the enhancement to add support for proper moderation of ticket attachments by unmoderated users. A new ticket (#3826) will track the side problem you brought up that if we are not allowing moderated users to attach files, the "I have files to attach..." checkbox should be suppressed.

comment:4 Changed 5 years ago by steven.studniarz@…

Thanks! I anxiously look forward to the resolution of this ticket...

As for the permissions you mentioned, from what I'm seeing Trac uses the TICKET_APPEND permission to dictate whether or not a user can append to existing tickets, OR attach files to new tickets. This seems to make sense and I'm perfectly fine with this behavior.

comment:5 Changed 5 years ago by jdsiiro

r1950 adds an unmoderated_attachments option to the [ticketmoderator] section of trac.ini to allow users who normally require ticket moderation to submit unmoderated ticket attachments.

This enables the "Attach file" button for existing tickets. However, the "I have files to attach" checkbox still appears on new ticket submissions and still does not work (for the reasons mentioned in comment:3).

comment:6 Changed 5 years ago by steven.studniarz@…

Just an idea (no idea if it could actually work this way) to get around the "I have files to attach" checkbox appearing for now...

Is it possible to temporarily override permissions? i.e. that checkbox is displayed based on whether or not a user has the TICKET_APPEND property. Is it possible to temporarily set that to false and therefore disable it for new moderated tickets?

comment:7 follow-up: ↓ 8 Changed 5 years ago by jdsiiro

The short answer is a qualified "Yes".

The checkbox is actually controlled by the ATTACHMENT_CREATE permission in the ticket context. That permission gets mapped to TICKET_APPEND by the LegacyAttachmentPolicy. To override this behavior, we need to create a new Permission Policy provider within the TicketModerator. The Trac site administrator will then need to edit the trac.ini file, and insert the new policy provider into the [trac] permission_policies list before the LegacyAttachmentPolicy.

Straightforward, but somewhat kludgy (life would be /much/ simpler if Trac didn't combine comment and attachment permissions in the first place). I am planning on implementing this tonight... but it is really all just a stopgap until I can figure how to support true attachment moderation (#3801).

comment:8 in reply to: ↑ 7 ; follow-up: ↓ 9 Changed 5 years ago by jdsiiro

Replying to jdsiiro:

To override this behavior, we need to create a new Permission Policy provider within the TicketModerator. The Trac site administrator will then need to edit the trac.ini file, and insert the new policy provider into the [trac] permission_policies list before the LegacyAttachmentPolicy.

This is implemented in r1984 / r1985.

comment:9 in reply to: ↑ 8 Changed 5 years ago by jdsiiro

  • Status changed from new to closed
  • Resolution set to fixed

Replying to jdsiiro:

This is implemented in r1984 / r1985.

I spoke too soon: while it turns out that the TicketModerator permission policy implemented in r1985 will successfully disable the "I have files to attach..." checkbox (#3826), it is not compatible with the unmoderated_attachments option requested by this ticket.

What happens is that both the "I have files to attach..." checkbox on a new ticket and the "Attach file" button on an existing ticket look at the ATTACHMENT_CREATE permission to see if they should be shown. The solution to #3826 (as implemented in r1984 / r1985) turns off that permission for users who do not have MODERATOR_UNMODERATED permissions. So, including the TicketModerator permission will disable *all* attachments from moderated users (including the "Attach file" button).

The only way I can think of to leave the "Attach file" button enabled, but hide the "I have files to attach..." checkbox is with a post-processing Genshi template filter. This will not be easy to craft, and I think it will be more useful in the long run to work on implementing proper attachment support. As a result, I am closing this ticket as "fixed as it's going to get." For those interested in following the attachment moderation development, please add yourselves to the CC list on #3807.

comment:10 Changed 5 years ago by jdsiiro

r2007 provides a better implementation for this ticket. The unmoderated_attachmentsoption is replaced by the MODERATOR_PASS_ATTACH permission.

comment:11 follow-up: ↓ 12 Changed 5 years ago by jdsiiro

r2182 fully moves the responsibility for hiding the "Attach file" button and the "I have files to attach" checkbox to the TicketModerator permission policy to better leverage the fine-grained permissions introduced in r2007.

The MODERATOR_PASS_ATTACH permission governs the visibility of the "Attach file" button (provided, of course, the user has TICKET_APPEND permissions). The "I have files to attach" checkbox is more complicated. Users who can submit unmoderated new tickets (i.e. have MODERATOR_PASS_CREATE permissions) will see the checkbox if they also have MODERATOR_PASS_ATTACH permissions. If they do not have MODERATOR_PASS_CREATE permissions, they will not be able to see the checkbox regardless of if they have MODERATOR_PASS_ATTACH permissions.

The net effect is that attachments work as usual for users with MODERATOR_UNMODERATED privileges, users without any MODERATOR_* permissions never see any attachment interfaces, and complex situations described earlier in this ticket should (finally) work "as expected."

comment:12 in reply to: ↑ 11 Changed 4 years ago by steven.studniarz@…

Replying to jdsiiro:

The "I have files to attach" checkbox is more complicated. Users who can submit unmoderated new tickets (i.e. have MODERATOR_PASS_CREATE permissions) will see the checkbox if they also have MODERATOR_PASS_ATTACH permissions. If they do not have MODERATOR_PASS_CREATE permissions, they will not be able to see the checkbox regardless of if they have MODERATOR_PASS_ATTACH permissions.

I have my permissions set to include only MODERATOR_PASS_MODIFY out of the MODERATOR_* permissions and I'm still seeing the "I have files to attach" checkbox.

Taking a look at the code, I believe it MAY be related to the if statement on line 347 and 348 of api.py. Should the conditions really be or-ed (it seems to me this ought to be an "and" relationship, maybe)?

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.