Skip to content

Commit

Permalink
check if 1st task
Browse files Browse the repository at this point in the history
  • Loading branch information
knightebsuku committed Oct 6, 2024
1 parent e09981b commit ad511d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion umsebenzi/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

def get_task_code(project : Project) -> int:
"""Get latest projects task code and increment by 1"""
task = Task.objects.filter(project=project).latest('id')
try:
task = Task.objects.filter(project=project).latest('id')
code = int(task.code.split('-')[-1])
return code + 1
except (IndexError, ValueError):
raise TaskCodeException
except Task.DoesNotExist:
return 1

0 comments on commit ad511d1

Please sign in to comment.