Skip to content

Commit 38398a9

Browse files
committed
Run black
1 parent cd99f6d commit 38398a9

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

ansible_base/rbac/management/create_types.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ def get_local_DAB_contenttypes(using: str, ct_model: Type[models.Model], service
1010
# This should work in migration scenarios, but other code checks for existence of it on manager
1111
ct_model.objects.clear_cache()
1212

13-
return {
14-
(ct.service, ct.model): ct
15-
for ct in ct_model.objects.using(using).filter(service=service)
16-
}
13+
return {(ct.service, ct.model): ct for ct in ct_model.objects.using(using).filter(service=service)}
1714

1815

1916
def create_DAB_contenttypes(
@@ -31,9 +28,7 @@ def create_DAB_contenttypes(
3128
"""
3229
DABContentType = apps.get_model("dab_rbac", "DABContentType")
3330

34-
content_types = get_local_DAB_contenttypes(
35-
using, DABContentType, service
36-
)
31+
content_types = get_local_DAB_contenttypes(using, DABContentType, service)
3732

3833
cts = [
3934
DABContentType(
@@ -49,7 +44,4 @@ def create_DAB_contenttypes(
4944
DABContentType.objects.using(using).bulk_create(cts)
5045
if verbosity >= 2:
5146
for ct in cts:
52-
print(
53-
"Adding DAB content type "
54-
f"'{ct.service}:{ct.app_label} | {ct.model}'"
55-
)
47+
print("Adding DAB content type " f"'{ct.service}:{ct.app_label} | {ct.model}'")

ansible_base/rbac/models/permission.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ class DABPermission(models.Model):
99

1010
name = models.CharField("name", max_length=255, help_text=_("The name of this permission."))
1111
# TODO: make non-null, make db_constraint
12-
content_type = models.ForeignKey(DABContentType, models.CASCADE, null=True, verbose_name="content type", help_text=_("The content type this permission will apply to."), db_constraint=False)
12+
content_type = models.ForeignKey(
13+
DABContentType,
14+
models.CASCADE,
15+
null=True,
16+
verbose_name="content type",
17+
help_text=_("The content type this permission will apply to."),
18+
db_constraint=False,
19+
)
1320
# tmp_content_type = models.ForeignKey(ContentType, models.CASCADE, verbose_name="content type", help_text=_("The content type this permission will apply to."))
1421
codename = models.CharField(
1522
"codename",

ansible_base/rbac/models/role.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ class Meta:
317317

318318
# role_definition set on child models to set appropriate help_text and related_name
319319
content_type = models.ForeignKey(
320-
DABContentType, on_delete=models.CASCADE, help_text=_("The content type of the subject of permission assignments. Duplicated from related RoleDefinition.")
320+
DABContentType,
321+
on_delete=models.CASCADE,
322+
help_text=_("The content type of the subject of permission assignments. Duplicated from related RoleDefinition."),
321323
)
322324
object_id = models.TextField(null=False, help_text=_("The database primary key of the subject of permission assignments."))
323325
content_object = FederatedForeignKey('content_type', 'object_id')

test_app/tests/rbac/models/test_content_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_post_migrate_creates_contenttype():
1717
@pytest.mark.django_db
1818
class DABContentTypeTests(TestCase):
1919
"""These tests originally came from Django contenttypes"""
20+
2021
def setUp(self):
2122
DABContentType.objects.clear_cache()
2223
self.addCleanup(DABContentType.objects.clear_cache)

0 commit comments

Comments
 (0)