diff options
author | Joris | 2020-05-10 12:50:46 +0200 |
---|---|---|
committer | Joris | 2020-05-10 12:50:46 +0200 |
commit | 7372ab407535ade48ce0b642ae051990e3bef7ed (patch) | |
tree | 65ae22d72cf10e40e777c4fa1919539d8e065e46 /src/model | |
parent | a134f20eb62e6d174e7da81fd4adb7ff9e8b3b71 (diff) |
Add task difficulty and priority fields
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/difficulty.py | 30 | ||||
-rw-r--r-- | src/model/priority.py | 30 | ||||
-rw-r--r-- | src/model/task.py | 12 |
3 files changed, 69 insertions, 3 deletions
diff --git a/src/model/difficulty.py b/src/model/difficulty.py new file mode 100644 index 0000000..595f844 --- /dev/null +++ b/src/model/difficulty.py @@ -0,0 +1,30 @@ +from enum import IntEnum +from typing import Optional + +class Difficulty(IntEnum): + LOW = 0 + MEDIUM = 1 + HIGH = 2 + +values = [ + Difficulty.LOW, + Difficulty.MEDIUM, + Difficulty.HIGH] + +def format(difficulty: Difficulty) -> str: + if difficulty == Difficulty.LOW: + return 'Low' + elif difficulty == Difficulty.MEDIUM: + return 'Medium' + elif difficulty == Difficulty.HIGH: + return 'High' + +def parse(string: str) -> Optional[Difficulty]: + if string == 'Low': + return Difficulty.LOW + elif string == 'Medium': + return Difficulty.MEDIUM + elif string == 'High': + return Difficulty.HIGH + else: + return None diff --git a/src/model/priority.py b/src/model/priority.py new file mode 100644 index 0000000..873369d --- /dev/null +++ b/src/model/priority.py @@ -0,0 +1,30 @@ +from enum import IntEnum +from typing import Optional + +class Priority(IntEnum): + LOW = 0 + MEDIUM = 1 + HIGH = 2 + +values = [ + Priority.LOW, + Priority.MEDIUM, + Priority.HIGH] + +def format(priority: Priority) -> str: + if priority == Priority.LOW: + return 'Low' + elif priority == Priority.MEDIUM: + return 'Medium' + elif priority == Priority.HIGH: + return 'High' + +def parse(string: str) -> Optional[Priority]: + if string == 'Low': + return Priority.LOW + elif string == 'Medium': + return Priority.MEDIUM + elif string == 'High': + return Priority.HIGH + else: + return None diff --git a/src/model/task.py b/src/model/task.py index cc7758d..f5e0ae5 100644 --- a/src/model/task.py +++ b/src/model/task.py @@ -1,17 +1,23 @@ from typing import NamedTuple -from datetime import datetime + +from model.difficulty import Difficulty +from model.priority import Priority class Task(NamedTuple): id: int created_at: int modified_at: int name: str - description: str duration: int tag: str + difficulty: Difficulty + priority: Priority + description: str class ValidTaskForm(NamedTuple): name: str - description: str duration: int tag: str + difficulty: Difficulty + priority: Priority + description: str |