summaryrefslogtreecommitdiff
path: root/backend_api.py
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-02-23 15:52:06 +0400
committerAndrew <saintruler@gmail.com>2020-02-23 15:52:06 +0400
commitfe016a980f9ac422c3ee940b4676184532a30b26 (patch)
tree27db7d50b03ac0aadc73ef604b78ad1e3c72be9c /backend_api.py
parent88113dc7d45dbdff76a8bb03b1d1cf0377949d4d (diff)
Added rating system for tasks, changed flow of answering the task and
implemented new views.
Diffstat (limited to 'backend_api.py')
-rw-r--r--backend_api.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/backend_api.py b/backend_api.py
index 491560f..a8270a4 100644
--- a/backend_api.py
+++ b/backend_api.py
@@ -115,10 +115,20 @@ def get_profile(tg_id: int):
def publish_task(title: str):
url_title = urllib.parse.quote(title)
- return patch_request(f"{BACKEND_URL}/api/tasks/{url_title}/update/", data={
- "first_published": dt.datetime.now(),
- "is_public": True
- })
+ code, resp = get_task(title)
+
+ if code != 200:
+ return code, {}
+
+ if resp["first_published"] is None:
+ return patch_request(f"{BACKEND_URL}/api/tasks/{url_title}/update/", data={
+ "first_published": dt.datetime.now(),
+ "is_public": True
+ })
+ else:
+ return patch_request(f"{BACKEND_URL}/api/tasks/{url_title}/update/", data={
+ "is_public": True
+ })
def hide_task(title: str):