@@ -204,7 +204,7 @@ def add_task() -> Response: # add the task to the task list
204
204
repeat_often = int (request .form .get ("repeat_often" )
205
205
) # get task repeat often
206
206
user : Union [User , None ] = User .query .first () # get first user
207
- if user : # if user exists
207
+ if user is not None : # if user exists
208
208
new_task = Task (
209
209
name = name ,
210
210
user_id = user .id ,
@@ -223,7 +223,7 @@ def add_task() -> Response: # add the task to the task list
223
223
@app .route ("/complete_task/<int:task_id>" )
224
224
def complete_task (task_id ) -> Response : # complete task from task id
225
225
task : Union [Task , None ] = Task .query .get (task_id ) # get task by task id
226
- if task : # if task exists
226
+ if task is not None : # if task exists
227
227
due_multiplier : float = 1.0 # set default due multiplier to 1
228
228
if task .repeat_often == 5 : # if the task is a one-time task
229
229
task .completed = True # complete the task
@@ -310,7 +310,7 @@ def complete_task(task_id) -> Response: # complete task from task id
310
310
active_tasks : int = Task .query .filter_by (
311
311
completed = False
312
312
).count () # get number of active tasks (tasks that are not completed)
313
- if user : # if user exists
313
+ if user is not None : # if user exists
314
314
user .tasks_completed += 1 # increase the number of tasks completed by 1
315
315
day_difference : timedelta = datetime .now () - datetime (
316
316
user .last_completion_date .year ,
@@ -370,7 +370,7 @@ def complete_task(task_id) -> Response: # complete task from task id
370
370
@app .route ("/delete_task/<int:task_id>" )
371
371
def delete_task (task_id ) -> Response : # delete task from task id
372
372
task : Union [Task , None ] = Task .query .get (task_id ) # get task by task id
373
- if task : # if task exists
373
+ if task is not None : # if task exists
374
374
db .session .delete (task ) # delete task from task list
375
375
db .session .commit () # commit database changes
376
376
return redirect (url_for ("index" )) # redirect to index page template
0 commit comments