Repository: wagtail/wagtail
File: wagtail/admin/views/pages/edit.py (Python)

Code before:
            and self.workflow_state.user_can_cancel(self.request.user)
        )

    @cached_property
    def is_out_of_date(self):
        # Check the autosave revision if present, otherwise fall back to the
        # initially loaded revision.
        submitted_revision_id = self.request.POST.get(
            "overwrite_revision_id"
        ) or self.request.POST.get("loaded_revision_id")

        return submitted_revision_id and (
            submitted_revision_id != str(self.page.latest_revision_id)
        )

    def post(self, request, *args, **kwargs):
        # Don't allow POST requests if the page is an alias
        if self.page.alias_of_id:
            # Return 405 "Method Not Allowed" response
            return HttpResponse(status=405)

        # For autosave, we only want to save the page if there are no conflicts
        if self.expects_json_response and self.is_out_of_date:
            return self.json_error_response(
                "invalid_revision",
                _("Saving will overwrite a newer version"),
            )

        self.form = self.form_class(
            self.request.POST,
            self.request.FILES,
            instance=self.page,
            subscription=self.subscription,
            parent_page=self.parent,
            for_user=self.request.user,
        )

        if self.action_name == "save":
            self.form.defer_required_fields()

        if self.form.is_valid() and not self.locked_for_user:
            return self.form_valid(self.form)
        else:
            self.form.restore_required_fields()
            return self.form_invalid(self.form)

    def workflow_action_is_valid(self):
        self.workflow_action = self.request.POST["workflow-action-name"]
        available_actions = self.page.current_workflow_task.get_actions(
            self.page, self.request.user
        )

Review comment (suggestion):
If the intention is for `errorMessage` to be user-facing, we need to translate them and be consistent with using (or not using) a period at the end. Right now it's a bit inconsistent, especially since the `invalid_revision` error's `errorMessage` can come from `Revision.save_revision`, which at the moment doesn't use translatable messages.

Code after:
            bool(self.request.POST.get("action-cancel-workflow"))
            and self.workflow_state
            and self.workflow_state.user_can_cancel(self.request.user)
        )

    @cached_property
    def is_out_of_date(self):
        # Check the autosave revision if present, otherwise fall back to the
        # initially loaded revision.
        submitted_revision_id = self.request.POST.get(
            "overwrite_revision_id"
        ) or self.request.POST.get("loaded_revision_id")

        return submitted_revision_id and (
            submitted_revision_id != str(self.page.latest_revision_id)
        )

    def post(self, request, *args, **kwargs):
        # Don't allow POST requests if the page is an alias
        if self.page.alias_of_id:
            # Return 405 "Method Not Allowed" response
            return HttpResponse(status=405)

        # For autosave, we only want to save the page if there are no conflicts
        if self.expects_json_response and self.is_out_of_date:
            return self.json_error_response(
                "invalid_revision",
                _("Saving will overwrite a newer version."),
            )

        self.form = self.form_class(
            self.request.POST,
            self.request.FILES,
            instance=self.page,
            subscription=self.subscription,
            parent_page=self.parent,
            for_user=self.request.user,
        )

        if self.action_name == "save":
            self.form.defer_required_fields()

        if self.form.is_valid() and not self.locked_for_user:
            return self.form_valid(self.form)
        else:
            self.form.restore_required_fields()
            return self.form_invalid(self.form)

    def workflow_action_is_valid(self):
        self.workflow_action = self.request.POST["workflow-action-name"]
        available_actions = self.page.current_workflow_task.get_actions(