wagtail-nest / wagtail-review

A Wagtail extension for gathering annotations and feedback on pages before publication
BSD 3-Clause "New" or "Revised" License
49 stars 19 forks source link

About the "respond" review mode #2

Open patillacode opened 5 years ago

patillacode commented 5 years ago

Hi!

So, I have been trying to add this, everything seems to work out of the box except for one thing.

This is what I would like to see in my review page:

screenshot 2019-01-07 at 18 59 53

screenshot 2019-01-07 at 18 50 13

And this in my Audit Trail:

screenshot 2019-01-07 at 18 51 59

In my case, I can never see the nice respond window, nor the comment or status in the Audit Trail (see images above) unless I hard code it like this: 'allow_responses': True, in wagtailreview_tags.py

I have noticed there are three values forwagtailreview_mode: view, comment and respond

I believe the respond mode is missing in the view_review_page view in admin.py or maybe I am not fully understanding or I am just missing something?

I am the designated reviewer (in case you could think I jsut don't have permissions)

It is impossible for me, with the code as is, to ever entrer a review in respond mode, so my questions would be:

Thanks for this piece of code and I hope you can respond soon!

Cheers!

patillacode commented 5 years ago

Hi again,

sorry for the various edits of this comment.

I believe that what could be missing in order to ever get a respond method to be used in admin.py could be:

    if review.submitter == request.user:
        dummy_request.wagtailreview_mode = 'comment'
    elif reviewer.user == request.user:
        dummy_request.wagtailreview_mode = 'respond'
    else:
        dummy_request.wagtailreview_mode = 'view'

Thanks to Maylon for the final idea.

Also, after some thought, I think it could be useful to have the default modes for submitters, reviewers and users to be defined in the settings file, maybe something like:

WAGTAIL_REVIEW_DEFAULT_SUBMITTER_MODE, WAGTAIL_REVIEW_DEFAULT_REVIEWER_MODE & WAGTAIL_REVIEW_DEFAULT_USER_MODE

Then in admin.py we could have the following:

    if review.submitter == request.user:
        dummy_request.wagtailreview_mode = getattr(settings, "WAGTAIL_REVIEW_DEFAULT_SUBMITTER_MODE", "comment")
    elif reviewer.user == request.user:
        dummy_request.wagtailreview_mode = getattr(settings, "WAGTAIL_REVIEW_DEFAULT_REVIEWER_MODE", "respond")
    else:
        dummy_request.wagtailreview_mode = getattr(settings, "WAGTAIL_REVIEW_DEFAULT_USER_MODE", "view")

This would allow the developer to decide based on the specific use case what to do while having the fallback to the default behaviour if the variables are not defined. For instance, someone could always allow comments to any user in their wagtail installation leaving them with the following in their settings file:

WAGTAIL_REVIEW_DEFAULT_USER_MODE="comment"

I will create a PR shortly, hopefully you'll like the idea.