Skip to content

Commit a6b6f91

Browse files
committed
refactor: ♻️ make validation functions of repository as instance methods
1 parent b6476e2 commit a6b6f91

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

time_tracker_api/time_entries/time_entries_model.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,24 @@ class TimeEntriesCosmosDBDao(APICosmosDBDao, TimeEntriesDao):
275275
def __init__(self, repository):
276276
CosmosDBDao.__init__(self, repository)
277277

278-
@classmethod
279-
def check_whether_current_user_owns_item(cls, data):
278+
def check_whether_current_user_owns_item(self, data):
280279
if (
281280
data.owner_id is not None
282-
and data.owner_id != cls.current_user_id()
281+
and data.owner_id != self.current_user_id()
283282
):
284283
raise CustomError(
285284
HTTPStatus.FORBIDDEN,
286285
"The current user is not the owner of this time entry",
287286
)
288287

289-
@classmethod
290-
def check_time_entry_is_not_stopped(cls, data):
288+
def check_time_entry_is_not_stopped(self, data):
291289
if data.end_date is not None:
292290
raise CustomError(
293291
HTTPStatus.UNPROCESSABLE_ENTITY,
294292
"The specified time entry is already stopped",
295293
)
296294

297-
@classmethod
298-
def check_time_entry_is_not_started(cls, data):
295+
def check_time_entry_is_not_started(self, data):
299296
if data.end_date is None:
300297
raise CustomError(
301298
HTTPStatus.UNPROCESSABLE_ENTITY,

0 commit comments

Comments
 (0)