Skip to content

Commit

Permalink
apply review.
Browse files Browse the repository at this point in the history
  • Loading branch information
yohei.naruse authored and ninneko committed Nov 5, 2016
1 parent bd36487 commit 4de6df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions handlers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ def delete(self, query_id):
class QueryForkResource(BaseResource):
@require_permission('edit_query')
def post(self, query_id):
query = get_object_or_404(models.Query.fork, query_id, self.current_user, self.current_org)
return query.to_dict(with_visualizations=True)
query = get_object_or_404(models.Query.get_by_id_and_org, query_id, self.current_org)
forked_query = query.fork(self.current_user)
return forked_query.to_dict(with_visualizations=True)


class QueryRefreshResource(BaseResource):
Expand Down
7 changes: 3 additions & 4 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,10 @@ def recent(cls, groups, user_id=None, limit=20):

return query

@classmethod
def fork(cls, id, user, org):
query = cls.get_by_id_and_org(id, org)
def fork(self, user):
query = self
forked_query = Query()
forked_query.name = 'Copy of (#{}) {}'.format(id, query.name)
forked_query.name = 'Copy of (#{}) {}'.format(query.id, query.name)
forked_query.user = user
forked_list = ['org', 'data_source', 'latest_query_data', 'description', 'query', 'query_hash']
for a in forked_list:
Expand Down

0 comments on commit 4de6df4

Please sign in to comment.