-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.py
More file actions
76 lines (59 loc) · 1.82 KB
/
Copy pathtask.py
File metadata and controls
76 lines (59 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from data import get_data, save
from datetime import datetime
import uuid
def task_create(request):
title = request.get('title')
task_priority = request.get('task_priority')
if not title:
return {"error":"Enter Title"}
if not task_priority and task_priority not in ['low','medium','high']:
task_priority = "low"
data = get_data()
new_id = str(uuid.uuid4())
description = request.get('description')
status = request.get('status')
priority = request.get('priority')
new_task = {
"id":new_id,
"title":title,
"task_priority":task_priority,
"description":description,
"status":status,
}
data.append(new_task)
save(data)
return new_task
def get_tasks_list():
tasks = get_data()
return tasks
def task_detail(task_id):
tasks_list = get_data()
for task in tasks_list:
print("task===>",task['id'])
if task['id'] == task_id:
return task
return {}
def task_delete(task_id):
data = get_data()
updated_data = []
for task in data:
if task['id'] != task_id:
updated_data.append(task)
return save(updated_data)
def task_update(task_id , updated_data):
data = get_data()
for task in data:
if task['id'] == task_id:
if "title" in updated_data:
task["title"] = updated_data["title"]
if "description" in updated_data:
task["description"] = updated_data["description"]
if "task_priority" in updated_data:
task["task_priority"] = updated_data["task_priority"]
return save(data)
def task_complete_update(task_id):
data = get_data()
for task in data:
if task['id'] == task_id:
task['status'] = "Completed"
return save(data)