diff --git a/requirements/base.txt b/requirements/base.txt index 597037b603..c1ea8014e3 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -12,6 +12,7 @@ django-grappelli==3.0.3 django-guardian==2.4.0 django-modern-rpc==0.12.1 django-simple-history==3.0.0 +django-tabular-permissions==2.9.1 django-tree-queries==0.11.0 django-uuslug==2.0.0 jira==3.4.1 diff --git a/tcms/bugs/apps.py b/tcms/bugs/apps.py index ee7554ad1f..8ada35abc7 100644 --- a/tcms/bugs/apps.py +++ b/tcms/bugs/apps.py @@ -4,7 +4,10 @@ class AppConfig(DjangoAppConfig): + "a doc-string on the AppConfig class" + name = "tcms.bugs" + admin_docs = "a custom defined attribute" def ready(self): from tcms import signals diff --git a/tcms/bugs/models.py b/tcms/bugs/models.py index 887e70fa40..1e61f98d96 100644 --- a/tcms/bugs/models.py +++ b/tcms/bugs/models.py @@ -12,6 +12,7 @@ class Severity(models.Model): + "doc-string on model class" name = models.CharField(max_length=64, unique=True) weight = models.IntegerField(default=0) icon = models.CharField(max_length=64) @@ -21,7 +22,9 @@ def __str__(self): return self.name class Meta: + "docstring on meta class" verbose_name_plural = _("Severity") + _custom_defined = "" class Bug(models.Model, UrlMixin): diff --git a/tcms/kiwi_auth/admin.py b/tcms/kiwi_auth/admin.py index 9c747288cf..6a4e95cb93 100644 --- a/tcms/kiwi_auth/admin.py +++ b/tcms/kiwi_auth/admin.py @@ -13,6 +13,11 @@ from django.utils.text import capfirst from django.utils.translation import gettext_lazy as _ +from tabular_permissions.admin import ( + UserTabularPermissionsMixin, + GroupTabularPermissionsMixin, +) + from tcms.utils.user import delete_user User = get_user_model() # pylint: disable=invalid-name @@ -66,7 +71,7 @@ def save(self, commit=True): return instance -class KiwiUserAdmin(UserAdmin): +class KiwiUserAdmin(UserTabularPermissionsMixin, UserAdmin): list_display = UserAdmin.list_display + ( "is_active", "is_superuser", @@ -216,7 +221,7 @@ def delete_model(self, request, obj): delete_user(obj) -class KiwiGroupAdmin(GroupAdmin): +class KiwiGroupAdmin(GroupTabularPermissionsMixin, GroupAdmin): form = GroupAdminForm def has_delete_permission(self, request, obj=None): diff --git a/tcms/settings/common.py b/tcms/settings/common.py index 1d5d6933b7..35b7172db7 100644 --- a/tcms/settings/common.py +++ b/tcms/settings/common.py @@ -304,6 +304,7 @@ "captcha", "colorfield", "django_extensions", + "tabular_permissions", "tree_queries", "vinaigrette", "tcms.core",