4242
4343
4444class TimeEntriesDao (CRUDDao ):
45- @staticmethod
46- def current_user_id ():
47- return current_user_id ()
48-
4945 @abc .abstractmethod
5046 def find_running (self ):
5147 pass
@@ -375,10 +371,7 @@ def __init__(self, repository):
375371 CosmosDBDao .__init__ (self , repository )
376372
377373 def check_whether_current_user_owns_item (self , data ):
378- if (
379- data .owner_id is not None
380- and data .owner_id != self .current_user_id ()
381- ):
374+ if data .owner_id is not None and data .owner_id != current_user_id ():
382375 raise CustomError (
383376 HTTPStatus .FORBIDDEN ,
384377 "The current user is not the owner of this time entry" ,
@@ -424,7 +417,8 @@ def get_all(self, conditions: dict = None, **kwargs) -> list:
424417 conditions .update ({"owner_id" : event_ctx .user_id })
425418
426419 custom_query = self .build_custom_query (
427- is_admin = event_ctx .is_admin , conditions = conditions ,
420+ is_admin = event_ctx .is_admin ,
421+ conditions = conditions ,
428422 )
429423 date_range = self .handle_date_filter_args (args = conditions )
430424 limit = conditions .get ("limit" , None )
@@ -444,7 +438,8 @@ def get_all_paginated(self, conditions: dict = None, **kwargs) -> list:
444438 event_ctx = self .create_event_context ("read-many" )
445439 get_all_conditions .update ({"owner_id" : event_ctx .user_id })
446440 custom_query = self .build_custom_query (
447- is_admin = event_ctx .is_admin , conditions = get_all_conditions ,
441+ is_admin = event_ctx .is_admin ,
442+ conditions = get_all_conditions ,
448443 )
449444 date_range = self .handle_date_filter_args (args = get_all_conditions )
450445 records_total = self .repository .count (
@@ -455,7 +450,8 @@ def get_all_paginated(self, conditions: dict = None, **kwargs) -> list:
455450 )
456451 conditions .update ({"owner_id" : event_ctx .user_id })
457452 custom_query = self .build_custom_query (
458- is_admin = event_ctx .is_admin , conditions = conditions ,
453+ is_admin = event_ctx .is_admin ,
454+ conditions = conditions ,
459455 )
460456 date_range = self .handle_date_filter_args (args = conditions )
461457 length = conditions .get ("length" , None )
@@ -499,7 +495,11 @@ def update(self, id, data: dict, description=None):
499495 time_entry = self .repository .find (id , event_ctx )
500496 self .check_whether_current_user_owns_item (time_entry )
501497
502- return self .repository .partial_update (id , data , event_ctx ,)
498+ return self .repository .partial_update (
499+ id ,
500+ data ,
501+ event_ctx ,
502+ )
503503
504504 def stop (self , id ):
505505 event_ctx = self .create_event_context ("update" , "Stop time entry" )
@@ -509,7 +509,9 @@ def stop(self, id):
509509 self .check_time_entry_is_not_stopped (time_entry )
510510
511511 return self .repository .partial_update (
512- id , {'end_date' : current_datetime_str ()}, event_ctx ,
512+ id ,
513+ {'end_date' : current_datetime_str ()},
514+ event_ctx ,
513515 )
514516
515517 def restart (self , id ):
@@ -520,15 +522,18 @@ def restart(self, id):
520522 self .check_time_entry_is_not_started (time_entry )
521523
522524 return self .repository .partial_update (
523- id , {'end_date' : None }, event_ctx ,
525+ id ,
526+ {'end_date' : None },
527+ event_ctx ,
524528 )
525529
526530 def delete (self , id ):
527531 event_ctx = self .create_event_context ("delete" )
528532 time_entry = self .repository .find (id , event_ctx )
529533 self .check_whether_current_user_owns_item (time_entry )
530534 self .repository .delete (
531- id , event_ctx ,
535+ id ,
536+ event_ctx ,
532537 )
533538
534539 def find_running (self ):
0 commit comments