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

wagtail-review

An extension for Wagtail allowing pages to be submitted for review (including to non-Wagtail users) prior to publication

Screencast demo

Requirements

Wagtail 5.2 or higher

Installation

Install the package from PyPI:

pip install wagtail-review

Add to your project's INSTALLED_APPS:

'wagtail_review',

Add to your project's URL config:

from wagtail_review import urls as wagtailreview_urls

# Somewhere above the include(wagtail_urls) line:
    path("review/", include(wagtailreview_urls)),

Add a {% wagtailreview %} tag to your project's base template(s), towards the bottom of the document <body>:

{% load wagtailreview_tags %}

{% wagtailreview %}

Custom notification emails

To customise the notification email sent to reviewers, override the templates wagtail_review/email/request_review_subject.txt (for the subject line) and wagtail_review/email/request_review.txt (for the email content). This needs to be done in an app which appears above wagtail_review in the INSTALLED_APPS list.

The following context variables are available within the templates:

To customise the notification email sent to the review submitter when a reviewer responds, override the templates wagtail_review/email/response_received_subject.txt (for the subject line) and wagtail_review/email/response_received.txt (for the email content). The following context variables are available:

Custom review models

To define a custom review model:

# my_project/my_app/models.py

from wagtail_review.models import BaseReview

REVIEW_TYPE_CHOICES = [
    ('clinical', "Clinical review"),
    ('editorial', "Editorial review"),
]

class Review(BaseReview):
    review_type = models.CharField(max_length=255, choices=REVIEW_TYPE_CHOICES)

# my_project/my_app/forms.py

from wagtail_review.forms import CreateReviewForm as BaseCreateReviewForm

class CreateReviewForm(BaseCreateReviewForm):
    class Meta(BaseCreateReviewForm.Meta):
        fields = ['review_type']

# my_project/settings.py

WAGTAILREVIEW_REVIEW_MODEL = 'my_app.Review'  # appname.ModelName identifier for model
WAGTAILREVIEW_REVIEW_FORM = 'my_project.my_app.forms.CreateReviewForm'  # dotted path to form class

Custom response form

The form for responding to reviews can be customised by overriding the template wagtail_review/response_form_fields.html; this needs to be done in an app which appears above wagtail_review in the INSTALLED_APPS list. The HTML for the default form is:

<fieldset>
    <legend>Submit your review</legend>

    {% for radio in response_form.result %}
        <div class="o-form__group o-form__group--radios">
            {{ radio }}
        </div>
    {% endfor %}

    <div class="o-form__group">
        <label for="id_comment" class="label-comment">Leave a comment</label>
        {{ response_form.comment }}
    </div>

    <div class="o-form__group">
        <input type="submit" value="Submit review" id="submit" />
    </div>

</fieldset>