Skip to content

Allow publishing of updates to live pages to be optional #60

Description

@SociologicalReview

In the current version of generate_qr_code in wagtail_qrcode/wagtail_hooks.py the last two lines cause draft changes to live pages to be automatically published:

def generate_qr_code(request, page):
    """Add a QR code to the page."""

    # dont try to generate a qrcode if the page does not inherit from QRCodeMixin
    if is_qrcode_instance(page):
        collection = create_collection("QR Codes")

        qrc = WagtailQrCode(page, collection)

        svg, document = qrc.build()

        page.qr_code_svg = svg
        page.qr_code_eps = document

        rev = page.save_revision()

        if page.live:
            rev.publish()

It is quite common for someone to draft changes to a page but hold off on publishing them. This is the case on the site where I have been looking to install Wagtail QRCode and the presence of this behaviour means we cannot use it in its current form.

It does not appear to be necessary to publish a page for the QR codes to be generated. I have tested a version with the lines:

    if page.live:
            rev.publish()

removed and everything appears to work fine, both for updating an existing live page and creating a new page.

The person editing the page can then draft changes as they wish and publish the page when they are ready.

Would it be possible, therefore, to either:

a.) remove these two lines altogether

or:

b.) provide come kind of setting, such as WAGTAIL_QR_CODE_AUTO_PUBLISH_UPDATES=True/False, and allow developers to decide whether this functionality is enabled or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions