Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Tasks posts invisible #986

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crowdsourcing/discourse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
status: string
enabled: 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
Expand Down
7 changes: 5 additions & 2 deletions crowdsourcing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down