aboutsummaryrefslogtreecommitdiff
path: root/todo/model
diff options
context:
space:
mode:
authorJoris2020-06-06 17:44:26 +0200
committerJoris2020-06-06 19:54:03 +0200
commit1595e0de940a86a7810df0e02e43838d97c0d846 (patch)
tree9701eeec0d98baa9f6044b1911df68e4c8539819 /todo/model
parent6b9195000eb5404c247288b384d7ca2bacc1ab23 (diff)
downloadtodo-1595e0de940a86a7810df0e02e43838d97c0d846.tar.gz
todo-1595e0de940a86a7810df0e02e43838d97c0d846.tar.bz2
todo-1595e0de940a86a7810df0e02e43838d97c0d846.zip
Provide nix build
Diffstat (limited to 'todo/model')
-rw-r--r--todo/model/__init__.py0
-rw-r--r--todo/model/difficulty.py30
-rw-r--r--todo/model/priority.py30
-rw-r--r--todo/model/status.py30
-rw-r--r--todo/model/tag.py12
-rw-r--r--todo/model/task.py22
-rw-r--r--todo/model/task_tag.py5
7 files changed, 129 insertions, 0 deletions
diff --git a/todo/model/__init__.py b/todo/model/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/todo/model/__init__.py
diff --git a/todo/model/difficulty.py b/todo/model/difficulty.py
new file mode 100644
index 0000000..526cdb9
--- /dev/null
+++ b/todo/model/difficulty.py
@@ -0,0 +1,30 @@
+from enum import IntEnum
+from typing import Optional
+
+class Difficulty(IntEnum):
+ EASY = 0
+ NORMAL = 1
+ HARD = 2
+
+values = [
+ Difficulty.EASY,
+ Difficulty.NORMAL,
+ Difficulty.HARD]
+
+def format(difficulty: Difficulty) -> str:
+ if difficulty == Difficulty.EASY:
+ return "Easy"
+ elif difficulty == Difficulty.NORMAL:
+ return "Normal"
+ elif difficulty == Difficulty.HARD:
+ return "Hard"
+
+def parse(string: str) -> Optional[Difficulty]:
+ if string == "Easy":
+ return Difficulty.EASY
+ elif string == "Normal":
+ return Difficulty.NORMAL
+ elif string == "Hard":
+ return Difficulty.HARD
+ else:
+ return None
diff --git a/todo/model/priority.py b/todo/model/priority.py
new file mode 100644
index 0000000..5948104
--- /dev/null
+++ b/todo/model/priority.py
@@ -0,0 +1,30 @@
+from enum import IntEnum
+from typing import Optional
+
+class Priority(IntEnum):
+ LOW = 0
+ MIDDLE = 1
+ HIGH = 2
+
+values = [
+ Priority.LOW,
+ Priority.MIDDLE,
+ Priority.HIGH]
+
+def format(priority: Priority) -> str:
+ if priority == Priority.LOW:
+ return "Low"
+ elif priority == Priority.MIDDLE:
+ return "Middle"
+ elif priority == Priority.HIGH:
+ return "High"
+
+def parse(string: str) -> Optional[Priority]:
+ if string == "Low":
+ return Priority.LOW
+ elif string == "Middle":
+ return Priority.MIDDLE
+ elif string == "High":
+ return Priority.HIGH
+ else:
+ return None
diff --git a/todo/model/status.py b/todo/model/status.py
new file mode 100644
index 0000000..6881e0a
--- /dev/null
+++ b/todo/model/status.py
@@ -0,0 +1,30 @@
+from enum import IntEnum
+from typing import Optional
+
+class Status(IntEnum):
+ READY = 0
+ WAITING = 1
+ MAYBE = 2
+
+values = [
+ Status.READY,
+ Status.WAITING,
+ Status.MAYBE]
+
+def format(status: Status) -> str:
+ if status == Status.READY:
+ return "Ready"
+ elif status == Status.WAITING:
+ return "Waiting"
+ elif status == Status.MAYBE:
+ return "Maybe"
+
+def parse(string: str) -> Optional[Status]:
+ if string == "Ready":
+ return Status.READY
+ elif string == "Waiting":
+ return Status.WAITING
+ elif string == "Maybe":
+ return Status.MAYBE
+ else:
+ return None
diff --git a/todo/model/tag.py b/todo/model/tag.py
new file mode 100644
index 0000000..030b223
--- /dev/null
+++ b/todo/model/tag.py
@@ -0,0 +1,12 @@
+from typing import NamedTuple
+
+class Tag(NamedTuple):
+ id: int
+ created_at: int
+ updated_at: int
+ name: str
+ color: str
+
+class ValidTagForm(NamedTuple):
+ name: str
+ color: str
diff --git a/todo/model/task.py b/todo/model/task.py
new file mode 100644
index 0000000..f20cbc9
--- /dev/null
+++ b/todo/model/task.py
@@ -0,0 +1,22 @@
+from typing import NamedTuple, List
+
+from todo.model.difficulty import Difficulty
+from todo.model.priority import Priority
+
+class Task(NamedTuple):
+ id: int
+ created_at: int
+ updated_at: int
+ name: str
+ duration: int
+ difficulty: Difficulty
+ priority: Priority
+ description: str
+
+class ValidTaskForm(NamedTuple):
+ name: str
+ duration: int
+ difficulty: Difficulty
+ priority: Priority
+ tags: List[int]
+ description: str
diff --git a/todo/model/task_tag.py b/todo/model/task_tag.py
new file mode 100644
index 0000000..0a33c66
--- /dev/null
+++ b/todo/model/task_tag.py
@@ -0,0 +1,5 @@
+from typing import NamedTuple
+
+class TaskTag(NamedTuple):
+ task_id: int
+ tag_id: int