aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/difficulty.py30
-rw-r--r--src/model/priority.py30
-rw-r--r--src/model/task.py12
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