From fd79cd47c786534d956e5a50bae6e5cc9d9cfaf3 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Fri, 5 Jul 2024 11:33:21 +0200 Subject: [PATCH] refactor(backend): make ruff happy --- backend/timed/permissions.py | 22 +++++++--------------- backend/timed/tracking/factories.py | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/backend/timed/permissions.py b/backend/timed/permissions.py index a5d5b525e..3d8689057 100644 --- a/backend/timed/permissions.py +++ b/backend/timed/permissions.py @@ -109,13 +109,11 @@ def has_permission(self, request, view): if not super().has_permission(request, view): # pragma: no cover return False - if ( + return ( request.user.customer_assignees.filter(is_reviewer=True).exists() or request.user.project_assignees.filter(is_reviewer=True).exists() or request.user.task_assignees.filter(is_reviewer=True).exists() - ): - return True - return False + ) def has_object_permission(self, request, view, obj): if not super().has_object_permission(request, view, obj): # pragma: no cover @@ -220,13 +218,11 @@ def has_permission(self, request, view): if not super().has_permission(request, view): # pragma: no cover return False - if ( + return ( request.user.customer_assignees.filter(is_manager=True).exists() or request.user.project_assignees.filter(is_manager=True).exists() or request.user.task_assignees.filter(is_manager=True).exists() - ): - return True - return False + ) def has_object_permission(self, request, view, obj): if not super().has_object_permission(request, view, obj): # pragma: no cover @@ -280,13 +276,11 @@ def has_permission(self, request, view): if not super().has_permission(request, view): # pragma: no cover return False - if ( + return ( request.user.customer_assignees.filter(is_resource=True).exists() or request.user.project_assignees.filter(is_resource=True).exists() or request.user.task_assignees.filter(is_resource=True).exists() - ): - return True - return False + ) def has_object_permission(self, request, view, obj): if not super().has_object_permission(request, view, obj): # pragma: no cover @@ -339,6 +333,4 @@ def has_permission(self, request, view): if not super().has_permission(request, view): # pragma: no cover return False - if request.user.customer_assignees.filter(is_customer=True).exists(): - return True - return False + return request.user.customer_assignees.filter(is_customer=True).exists() diff --git a/backend/timed/tracking/factories.py b/backend/timed/tracking/factories.py index a4e8ba471..97ed81437 100644 --- a/backend/timed/tracking/factories.py +++ b/backend/timed/tracking/factories.py @@ -59,7 +59,7 @@ class ActivityFactory(DjangoModelFactory): not_billable = False @lazy_attribute - def from_time(self): + def from_time(self): # noqa: F811 return datetime.time(hour=randint(0, 22), minute=randint(0, 59)) @lazy_attribute