From 18e77cafa98b7fe109323c0b9b7faf1f7ad384e2 Mon Sep 17 00:00:00 2001 From: Mark Whiting Date: Thu, 12 Oct 2017 13:03:38 -0700 Subject: [PATCH 1/2] Revert "Merge branch 'develop' into update_topic" This reverts commit 3a9650178ab7adce5a9ed3f8263856657f3dbdaa, reversing changes made to 983434075a045cacae47e2a5b0ef0e4f48916f6d. --- crowdsourcing/discourse.py | 11 +++++++++++ crowdsourcing/tasks.py | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crowdsourcing/discourse.py b/crowdsourcing/discourse.py index 67003159f..2cd25c9e7 100644 --- a/crowdsourcing/discourse.py +++ b/crowdsourcing/discourse.py @@ -164,6 +164,17 @@ def create_topic(self, title, category, timeout, price, requester_handle, projec "**Timeout** : %s \n" % (title, preview_url, requester_handle, price, timeout), **kwargs) + def update_topic(self, topicURL, status, enabled, **kwargs): + """ Edit an atribute of a topic + attribute: string + status: string + """ + url = topicURL + '/status' + kwargs['status'] = status + kwargs['enabled'] = enabled + + return self._post(url, **kwargs) + def topic_timings(self, topic_id, time, timings={}, **kwargs): """ Set time spent reading a post time: overall time for the topic diff --git a/crowdsourcing/tasks.py b/crowdsourcing/tasks.py index 66e12f88f..eb05eb03e 100644 --- a/crowdsourcing/tasks.py +++ b/crowdsourcing/tasks.py @@ -84,7 +84,7 @@ def expire_tasks(): INNER JOIN crowdsourcing_task t ON tw.task_id = t.id INNER JOIN crowdsourcing_project p ON t.project_id = p.id INNER JOIN crowdsourcing_taskworkersession sessions ON sessions.task_worker_id = tw.id - WHERE tw.status=%(in_progress)s + WHERE tw.status=%(in_progress)s GROUP BY tw.id, p.id HAVING sum(coalesce(sessions.ended_at, now()) - sessions.started_at) > coalesce(p.timeout, INTERVAL '24 hour')) @@ -136,7 +136,7 @@ def auto_approve_tasks(): INNER JOIN auth_user u_worker ON tw.worker_id = u_worker.id WHERE tw.submitted_at + INTERVAL %(auto_approve_freq)s < NOW() AND tw.status=%(submitted)s) - UPDATE crowdsourcing_taskworker tw_up SET status=%(accepted)s, approved_at = %(approved_at)s, + UPDATE crowdsourcing_taskworker tw_up SET status=%(accepted)s, approved_at = %(approved_at)s, auto_approved=TRUE FROM taskworkers WHERE taskworkers.id=tw_up.id @@ -1198,6 +1198,9 @@ def post_to_discourse(project_id): if topic is not None: url = '/t/%s/%d' % (topic['topic_slug'], topic['topic_id']) + + client.update_topic(url,'visible','false') + instance.discussion_link = url instance.topic_id = topic['topic_id'] instance.post_id = topic['id'] From eaaff3b29ec174ec789ba8529fb52d05c81173b3 Mon Sep 17 00:00:00 2001 From: Mark Whiting Date: Thu, 12 Oct 2017 13:07:27 -0700 Subject: [PATCH 2/2] Made comment consistent with variable names --- crowdsourcing/discourse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsourcing/discourse.py b/crowdsourcing/discourse.py index 2cd25c9e7..c9ee29dfe 100644 --- a/crowdsourcing/discourse.py +++ b/crowdsourcing/discourse.py @@ -166,8 +166,8 @@ def create_topic(self, title, category, timeout, price, requester_handle, projec def update_topic(self, topicURL, status, enabled, **kwargs): """ Edit an atribute of a topic - attribute: string status: string + enabled: string """ url = topicURL + '/status' kwargs['status'] = status