From fe016a980f9ac422c3ee940b4676184532a30b26 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 23 Feb 2020 15:52:06 +0400 Subject: Added rating system for tasks, changed flow of answering the task and implemented new views. --- backend_api.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'backend_api.py') 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): -- cgit v1.2.3