Skip to content

Commit

Permalink
ci: auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 2d4c2e7 commit 51e81a4
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 87 deletions.
20 changes: 10 additions & 10 deletions djangocms_moderation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def form_submission(self, obj):

opts = ConfirmationFormSubmission._meta
url = reverse(
"admin:{}_{}_change".format(opts.app_label, opts.model_name),
f"admin:{opts.app_label}_{opts.model_name}_change",
args=[instance.pk],
)
return format_html(
Expand All @@ -107,6 +107,7 @@ def get_readonly_fields(self, request, obj=None):
return self.fields


@admin.register(ModerationRequestTreeNode)
class ModerationRequestTreeAdmin(TreeAdmin):
"""
This admin is purely for the change list of Moderation Requests using the treebeard nodes to
Expand Down Expand Up @@ -466,6 +467,7 @@ def _traverse_moderation_nodes(node_item):
return HttpResponseRedirect(redirect_url)


@admin.register(ModerationRequest)
class ModerationRequestAdmin(admin.ModelAdmin):
class Media:
js = ('admin/js/jquery.init.js', 'djangocms_moderation/js/actions.js',)
Expand Down Expand Up @@ -813,11 +815,13 @@ def changelist_view(self, request, extra_context=None):
return tree_node_admin.changelist_view(request, extra_context)


@admin.register(Role)
class RoleAdmin(admin.ModelAdmin):
list_display = ["name", "user", "group", "confirmation_page"]
fields = ["name", "user", "group", "confirmation_page"]


@admin.register(CollectionComment)
class CollectionCommentAdmin(admin.ModelAdmin):
list_display = ["date_created", "message", "author"]
fields = ["collection", "message", "author"]
Expand Down Expand Up @@ -900,6 +904,7 @@ def get_readonly_fields(self, request, obj=None):
return self.list_display


@admin.register(RequestComment)
class RequestCommentAdmin(admin.ModelAdmin):
list_display = ["date_created", "message", "get_author"]
fields = ["moderation_request", "message", "author"]
Expand Down Expand Up @@ -990,6 +995,7 @@ def get_extra(self, request, obj=None, **kwargs):
return 1


@admin.register(Workflow)
class WorkflowAdmin(admin.ModelAdmin):
inlines = [WorkflowStepInline]
list_display = ["name", "is_default"]
Expand All @@ -1002,6 +1008,7 @@ class WorkflowAdmin(admin.ModelAdmin):
]


@admin.register(ModerationCollection)
class ModerationCollectionAdmin(admin.ModelAdmin):
class Media:
js = ("admin/js/jquery.init.js", "djangocms_moderation/js/actions.js",)
Expand Down Expand Up @@ -1136,6 +1143,7 @@ def has_delete_permission(self, request, obj=None):
return False


@admin.register(ConfirmationPage)
class ConfirmationPageAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
view_on_site = True

Expand All @@ -1153,6 +1161,7 @@ def _url(regex, fn, name, **kwargs):
return url_patterns + super().get_urls()


@admin.register(ConfirmationFormSubmission)
class ConfirmationFormSubmissionAdmin(admin.ModelAdmin):
list_display = ["moderation_request", "for_step", "submitted_at"]
fields = [
Expand Down Expand Up @@ -1202,12 +1211,3 @@ def form_data(self, obj):
form_data.short_description = _("Form Data")


Check warning on line 1213 in djangocms_moderation/admin.py

View workflow job for this annotation

GitHub Actions / flake8

blank line at end of file

Check warning on line 1213 in djangocms_moderation/admin.py

View workflow job for this annotation

GitHub Actions / flake8

blank line at end of file
admin.site.register(ModerationRequestTreeNode, ModerationRequestTreeAdmin)
admin.site.register(ModerationRequest, ModerationRequestAdmin)
admin.site.register(CollectionComment, CollectionCommentAdmin)
admin.site.register(RequestComment, RequestCommentAdmin)
admin.site.register(ModerationCollection, ModerationCollectionAdmin)
admin.site.register(Role, RoleAdmin)
admin.site.register(Workflow, WorkflowAdmin)
admin.site.register(ConfirmationPage, ConfirmationPageAdmin)
admin.site.register(ConfirmationFormSubmission, ConfirmationFormSubmissionAdmin)
4 changes: 2 additions & 2 deletions djangocms_moderation/admin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ def add_items_to_collection(modeladmin, request, queryset):
args=(),
),
version_ids=",".join(version_ids),
return_to_url=request.META.get("HTTP_REFERER", ""),
return_to_url=request.headers.get("referer", ""),
)
return HttpResponseRedirect(admin_url)
else:
modeladmin.message_user(
request, _("No suitable items found to add to moderation collection")
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", ""))
return HttpResponseRedirect(request.headers.get("referer", ""))


add_items_to_collection.short_description = _("Add to moderation collection")
Expand Down
4 changes: 2 additions & 2 deletions djangocms_moderation/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class ModerationConfig(AppConfig):
verbose_name = _("django CMS Moderation")

def ready(self):
import djangocms_moderation.handlers # noqa: F401
import djangocms_moderation.monkeypatch # noqa: F401
import djangocms_moderation.handlers
import djangocms_moderation.monkeypatch
import djangocms_moderation.signals # noqa: F401
2 changes: 1 addition & 1 deletion djangocms_moderation/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def sequential_number_with_identifier_prefix_backend(**kwargs):
semi-sequential numbers, prefixed with `workflow.identifier` field, if set
"""
moderation_request = kwargs["moderation_request"]
return "{}{}".format(moderation_request.workflow.identifier, moderation_request.pk)
return f"{moderation_request.workflow.identifier}{moderation_request.pk}"
4 changes: 2 additions & 2 deletions djangocms_moderation/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _add_moderation_buttons(self):
opts = ModerationRequest._meta
codename = get_permission_codename("add", opts)
if not self.request.user.has_perm(
"{app_label}.{codename}".format(app_label=opts.app_label, codename=codename)
f"{opts.app_label}.{codename}"
):
return
version = Version.objects.get_for_content(self.toolbar.obj)
Expand All @@ -91,7 +91,7 @@ def _add_moderation_menu(self):
opts = ModerationCollection._meta
codename = get_permission_codename("change", opts)
if not self.request.user.has_perm(
"{app_label}.{codename}".format(app_label=opts.app_label, codename=codename)
f"{opts.app_label}.{codename}"
):
return
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER)
Expand Down
4 changes: 2 additions & 2 deletions djangocms_moderation/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _send_email(
"job_id": collection.job_id,
"by_user": by_user,
}
template = "djangocms_moderation/emails/moderation-request/{}".format(template)
template = f"djangocms_moderation/emails/moderation-request/{template}"

# TODO What language should the email be sent in? e.g. `with force_language(lang):`
subject = force_str(subject)
Expand All @@ -61,7 +61,7 @@ def notify_collection_author(collection, moderation_requests, action, by_user):
moderation_requests=moderation_requests,
recipients=[collection.author.email],
subject=email_subjects[action],
template="{}.txt".format(action),
template=f"{action}.txt",
by_user=by_user,
)
return status
Expand Down
2 changes: 1 addition & 1 deletion djangocms_moderation/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def moderation_confirmation_form_submission(
sender, page, language, user, form_data, **kwargs
):
for field_data in form_data:
if not set(("label", "value")).issubset(field_data):
if not {"label", "value"}.issubset(field_data):
raise ValueError("Each field dict should contain label and value keys.")

# TODO Confirmation pages are not used/working in 1.0.x yet
Expand Down
2 changes: 1 addition & 1 deletion djangocms_moderation/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_active_moderation_request(content_object):
If this returns None, it means there is no active_moderation request for this
object, and it means it can be submitted for new moderation
"""
from djangocms_moderation.models import ModerationRequest # noqa
from djangocms_moderation.models import ModerationRequest

version = Version.objects.get_for_content(content_object)

Expand Down
6 changes: 3 additions & 3 deletions djangocms_moderation/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ class Migration(migrations.Migration):
),
),
migrations.AlterUniqueTogether(
name="workflowstep", unique_together=set([("role", "workflow")])
name="workflowstep", unique_together={("role", "workflow")}
),
migrations.AlterUniqueTogether(
name="moderationrequest",
unique_together=set([("collection", "object_id", "content_type")]),
unique_together={("collection", "object_id", "content_type")},
),
migrations.AlterUniqueTogether(
name="confirmationformsubmission",
unique_together=set([("request", "for_step")]),
unique_together={("request", "for_step")},
),
]
2 changes: 1 addition & 1 deletion djangocms_moderation/migrations/0003_auto_20180903_1206.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Migration(migrations.Migration):
preserve_default=False,
),
migrations.AlterUniqueTogether(
name="moderationrequest", unique_together=set([("collection", "version")])
name="moderationrequest", unique_together={("collection", "version")}
),
migrations.RemoveField(model_name="moderationrequest", name="content_type"),
migrations.RemoveField(model_name="moderationrequest", name="object_id"),
Expand Down
2 changes: 1 addition & 1 deletion djangocms_moderation/migrations/0011_auto_20181008_1328.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
# AlterUniqueTogether needs to happen before removing field
migrations.AlterUniqueTogether(
name="confirmationformsubmission",
unique_together=set([("moderation_request", "for_step")]),
unique_together={("moderation_request", "for_step")},
),
migrations.RemoveField(model_name="confirmationformsubmission", name="request"),
migrations.RemoveField(model_name="moderationrequestaction", name="request"),
Expand Down
10 changes: 5 additions & 5 deletions djangocms_moderation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def __str__(self):

@property
def job_id(self):
return "{}".format(self.pk)
return f"{self.pk}"

@property
def author_name(self):
Expand Down Expand Up @@ -444,7 +444,7 @@ class Meta:
ordering = ["id"]

def __str__(self):
return "{} {}".format(self.pk, self.version_id)
return f"{self.pk} {self.version_id}"

@cached_property
def workflow(self):
Expand Down Expand Up @@ -651,7 +651,7 @@ class Meta:
verbose_name_plural = _("Actions")

def __str__(self):
return "{} - {}".format(self.moderation_request_id, self.get_action_display())
return f"{self.moderation_request_id} - {self.get_action_display()}"

def get_by_user_name(self):
if not self.to_user:
Expand Down Expand Up @@ -686,7 +686,7 @@ def save(self, **kwargs):

if next_step:
self.to_role_id = next_step.role_id
super(ModerationRequestAction, self).save(**kwargs)
super().save(**kwargs)


class AbstractComment(models.Model):
Expand Down Expand Up @@ -743,7 +743,7 @@ class ConfirmationFormSubmission(models.Model):
)

def __str__(self):
return "{} - {}".format(self.request_id, self.for_step)
return f"{self.request_id} - {self.for_step}"

class Meta:
verbose_name = _("Confirmation Form Submission")
Expand Down
10 changes: 5 additions & 5 deletions djangocms_moderation/static/djangocms_moderation/css/actions.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ a.btn.cms-moderation-action-btn span {
display: inline-block;
}
span.svg-juxtaposed-font {
text-rendering: auto;
display: inline-block;
line-height: 1rem;
vertical-align: 20%;
margin-top: -2px !important;
text-rendering: auto;
display: inline-block;
line-height: 1rem;
vertical-align: 20%;
margin-top: -2px !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

{% block post_content %}{% endblock %}
</div>

{% render_block "js" %}
{% block extrajs %}{% endblock %}
</body>
Expand Down
2 changes: 1 addition & 1 deletion djangocms_moderation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_absolute_url(location, site=None):
scheme = "https"
else:
scheme = "http"
domain = "{}://{}".format(scheme, site.domain)
domain = f"{scheme}://{site.domain}"
return urljoin(domain, location)


Expand Down
2 changes: 1 addition & 1 deletion docs/comment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Comment
================================================
Comments may be added to various moderation entities:
Comments may be added to various moderation entities:
* :ref:`moderation_collection`
* :ref:`moderation_request`
* :ref:`moderation_request_action`
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down
6 changes: 3 additions & 3 deletions docs/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Moderation Review Lock
================================================
As soon as a :ref:`moderation_collection` status becomes in review then its drafts are automatically locked, in the sense that their content can no longer be edited (not at all, not by anyone, not even the collection author). Also once a collection is in Review then content versions cannot be added to the collection. This means that once you’ve clicked “Submit for review”:
As soon as a :ref:`moderation_collection` status becomes in review then its drafts are automatically locked, in the sense that their content can no longer be edited (not at all, not by anyone, not even the collection author). Also once a collection is in Review then content versions cannot be added to the collection. This means that once you’ve clicked “Submit for review”:
* Collection Lock: New drafts cannot be added to the :ref:`moderation_collection`
* Version Lock: Drafts in the :ref:`moderation_collection` cannot be edited unless rejected
Once a version is published the Moderation Version Lock is removed automatically.

Once a version is published the Moderation Version Lock is removed automatically.
12 changes: 6 additions & 6 deletions docs/moderation_collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Moderation Collection
================================================

A Moderation Collection is primarily intended as a way of being able to group draft content versions together for:
a) review and
A Moderation Collection is primarily intended as a way of being able to group draft content versions together for:
a) review and
b) publishing

The rules for adding items to a Collection, removing items from a Collection and the actions that can be taken on items the Collection may vary by :ref:`workflow`.

Publishing is a `djangocms-versioning` feature, thus `djangocms-moderation` depends on and extends the functionality made available by the Versioning addon.
Expand All @@ -16,7 +16,7 @@ Collections are stateful. The available states are:
* In review
* Archived
* Cancelled

Drafts can only be added to a Collection during the `Collecting` phase (see :ref:`lock`)

Buttons
Expand Down Expand Up @@ -76,7 +76,7 @@ A collection can also be flagged as cancelled. This is similar to Archived excep

Bulk Actions
-------------------------------------------------
These will appear in the Collection’s action drop-down for each content-type registered with Moderation.
These will appear in the Collection’s action drop-down for each content-type registered with Moderation.

Remove from collection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -92,4 +92,4 @@ Flags a draft as being in need of further editing

Submit for review
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Useful for items that have been flagged for rework - resubmits them for review, sending out notifications again.
Useful for items that have been flagged for rework - resubmits them for review, sending out notifications again.
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Overview

Moderation provides an approval workflow mechanism for organisations who need to ensure that content is approved before it is published. It is designed to extend and compliment the Versioning addon and has that as a dependency.

The general idea is that a draft version can be submitted for moderation. This involves adding that draft to a :ref:`moderation_collection`, which can be thought of as a chapter, edition or batch of content that aims to all be published simultaneously. Various drafts can be added to the same :ref:`moderation_collection`.
The general idea is that a draft version can be submitted for moderation. This involves adding that draft to a :ref:`moderation_collection`, which can be thought of as a chapter, edition or batch of content that aims to all be published simultaneously. Various drafts can be added to the same :ref:`moderation_collection`.

Drafts within the :ref:`moderation_collection` can then be approved rejected by various parties according to :ref:`role`s defined within the :ref:`workflow` assigned to the :ref:`moderation_collection`.

Expand Down
Loading

0 comments on commit 51e81a4

Please sign in to comment.