pyvikunja 0.10__py3-none-any.whl → 0.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyvikunja/models/task.py +59 -4
- {pyvikunja-0.10.dist-info → pyvikunja-0.12.dist-info}/METADATA +1 -1
- {pyvikunja-0.10.dist-info → pyvikunja-0.12.dist-info}/RECORD +6 -6
- {pyvikunja-0.10.dist-info → pyvikunja-0.12.dist-info}/LICENSE +0 -0
- {pyvikunja-0.10.dist-info → pyvikunja-0.12.dist-info}/WHEEL +0 -0
- {pyvikunja-0.10.dist-info → pyvikunja-0.12.dist-info}/top_level.txt +0 -0
pyvikunja/models/task.py
CHANGED
@@ -10,10 +10,58 @@ from pyvikunja.models.user import User
|
|
10
10
|
|
11
11
|
class Task(BaseModel):
|
12
12
|
def __init__(self, api: 'VikunjaAPI', data: Dict):
|
13
|
-
|
14
13
|
super().__init__(data)
|
15
14
|
self.api = api
|
15
|
+
self.id: int = -1
|
16
|
+
self.data = data
|
17
|
+
self.title: str = ""
|
18
|
+
self.description: str = ""
|
19
|
+
self.done: bool = False
|
20
|
+
self.done_at: Optional[datetime] = None
|
21
|
+
self.due_date: Optional[datetime] = None
|
22
|
+
self.start_date: Optional[datetime] = None
|
23
|
+
self.end_date: Optional[datetime] = None
|
24
|
+
self.hex_color: Optional[str] = None
|
25
|
+
self.is_favorite: bool = False
|
26
|
+
self.percent_done: int = 0
|
27
|
+
self.priority: Optional[Priority] = None
|
28
|
+
self.project_id: Optional[int] = None
|
29
|
+
self.labels: List[Label] = []
|
30
|
+
self.assignees: List[User] = []
|
31
|
+
self.repeat_mode: Optional[RepeatMode] = None
|
32
|
+
self.repeat_after: Optional[timedelta] = None
|
33
|
+
self.repeat_enabled = False
|
34
|
+
|
35
|
+
self.parse_data(data)
|
36
|
+
|
37
|
+
def __eq__(self, other):
|
38
|
+
if not isinstance(other, Task):
|
39
|
+
return False
|
40
|
+
|
41
|
+
return (
|
42
|
+
self.id == other.id and
|
43
|
+
self.title == other.title and
|
44
|
+
self.description == other.description and
|
45
|
+
self.done == other.done and
|
46
|
+
self.done_at == other.done_at and
|
47
|
+
self.due_date == other.due_date and
|
48
|
+
self.start_date == other.start_date and
|
49
|
+
self.end_date == other.end_date and
|
50
|
+
self.hex_color == other.hex_color and
|
51
|
+
self.is_favorite == other.is_favorite and
|
52
|
+
self.percent_done == other.percent_done and
|
53
|
+
self.priority == other.priority and
|
54
|
+
self.project_id == other.project_id and
|
55
|
+
self.repeat_mode == other.repeat_mode and
|
56
|
+
self.repeat_after == other.repeat_after and
|
57
|
+
self.repeat_enabled == other.repeat_enabled and
|
58
|
+
sorted(self.labels, key=lambda x: x.id) == sorted(other.labels, key=lambda x: x.id) and
|
59
|
+
sorted(self.assignees, key=lambda x: x.id) == sorted(other.assignees, key=lambda x: x.id)
|
60
|
+
)
|
61
|
+
|
62
|
+
def parse_data(self, data):
|
16
63
|
self.data = data
|
64
|
+
self.id: int = data.get('id', -1)
|
17
65
|
self.title: str = data.get('title', '')
|
18
66
|
self.description: str = data.get('description', '')
|
19
67
|
self.done: bool = data.get('done', False)
|
@@ -34,10 +82,11 @@ class Task(BaseModel):
|
|
34
82
|
self.assignees: List[User] = [User(user_data) for user_data in data.get('assignees', []) or []]
|
35
83
|
|
36
84
|
# Parse repeat_mode into an enum
|
37
|
-
self.repeat_mode: RepeatMode = self._parse_repeat_mode(data.get('repeat_mode'))
|
85
|
+
self.repeat_mode: Optional[RepeatMode] = self._parse_repeat_mode(data.get('repeat_mode'))
|
38
86
|
|
39
87
|
# Parse repeat_after into timedelta
|
40
88
|
self.repeat_after: Optional[timedelta] = self._parse_repeat_after(data.get('repeat_after'))
|
89
|
+
self.repeat_enabled = self.repeat_after is not None
|
41
90
|
|
42
91
|
def _parse_repeat_mode(self, mode: Optional[int]) -> Optional[RepeatMode]:
|
43
92
|
"""Convert repeat_mode integer into an Enum value, defaulting to NONE."""
|
@@ -62,7 +111,7 @@ class Task(BaseModel):
|
|
62
111
|
updated_data = await self.api.update_task(self.id, combined)
|
63
112
|
|
64
113
|
# Update the local data with the response
|
65
|
-
self.
|
114
|
+
self.parse_data(updated_data)
|
66
115
|
|
67
116
|
return self
|
68
117
|
|
@@ -115,7 +164,13 @@ class Task(BaseModel):
|
|
115
164
|
iso_date = str(date.isoformat())
|
116
165
|
return await self.update({'end_date': iso_date})
|
117
166
|
|
118
|
-
async def
|
167
|
+
async def set_repeating_enabled(self, enabled: bool):
|
168
|
+
return await self.update({
|
169
|
+
'repeat_after': None if not enabled else 3600 # 1 hour min
|
170
|
+
})
|
171
|
+
|
172
|
+
async def set_repeating_interval(self, interval: Optional[timedelta] = None,
|
173
|
+
mode: Optional[RepeatMode] = None) -> 'Task':
|
119
174
|
new_interval = interval if interval else self.repeat_after
|
120
175
|
total_seconds = int(new_interval.total_seconds())
|
121
176
|
|
@@ -3,13 +3,13 @@ pyvikunja/api.py,sha256=mHPn0XPFrYNCG3ChIUnluAOP08z3YyUL_3nors9RuYU,6920
|
|
3
3
|
pyvikunja/models/label.py,sha256=cOOuVYDVDMmK96Ev22EDgWwXljkAonQNL4XsTMay4K4,467
|
4
4
|
pyvikunja/models/models.py,sha256=RCPsYQtcgE-W5ZmhwGDejAI76nHZ9-1X-x5GeTG4RnI,637
|
5
5
|
pyvikunja/models/project.py,sha256=viVIe3lVgbh7k05ADDds1cwzvC1vf4tT2vSNjbB7KMk,1179
|
6
|
-
pyvikunja/models/task.py,sha256=
|
6
|
+
pyvikunja/models/task.py,sha256=1X2Wh-v6suhvyvWn6P8amVfvwaZSnEpMb_8yFZ9TUvM,7752
|
7
7
|
pyvikunja/models/team.py,sha256=0Z3828Cm3nNuNr1z2on63fLYAVW325_SQKi5RmqXf-I,559
|
8
8
|
pyvikunja/models/user.py,sha256=36duFNyGXKzlwqO0d6FA-C1KTCci2sIMU1IBIF-N_LM,310
|
9
9
|
pyvikunja/models/enum/repeat_mode.py,sha256=xkDPfYeRz342ovqro1UVBAoegpPgpZQYTnyo2sf6R7I,112
|
10
10
|
pyvikunja/models/enum/task_priority.py,sha256=aVz1HEofIqwUkXG0vYm58n_vLNbgqtbvHuQ5K-YQqA0,119
|
11
|
-
pyvikunja-0.
|
12
|
-
pyvikunja-0.
|
13
|
-
pyvikunja-0.
|
14
|
-
pyvikunja-0.
|
15
|
-
pyvikunja-0.
|
11
|
+
pyvikunja-0.12.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
12
|
+
pyvikunja-0.12.dist-info/METADATA,sha256=3yFTnPAGKGDL8W1DVnNqRXwPFaR3BotI3VPgzKKyYug,188
|
13
|
+
pyvikunja-0.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
14
|
+
pyvikunja-0.12.dist-info/top_level.txt,sha256=WVV9zgxUBuWOkUY1t_U7zI0paWWTVelKYB4vjsiKsks,10
|
15
|
+
pyvikunja-0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|