Skip to content

Change warning message when users try to export private silo as JSON - #540

Merged
jefmoura merged 2 commits into
toladata:masterfrom
ybekdemir:issue-530
Jul 20, 2018
Merged

Change warning message when users try to export private silo as JSON#540
jefmoura merged 2 commits into
toladata:masterfrom
ybekdemir:issue-530

Conversation

@ybekdemir

Copy link
Copy Markdown

Purpose

Currently, when user tries to export private silo as JSON feed, we are warning to redirect them to API. However, we need more clear message with simple instruction.

Approach

Warning message was changed and user token added to message to inform users about how can they use API.

_Related ticket: #530

@jefmoura jefmoura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Why did you decide to use the DRF token?
  • I don't think it's a good idea to use it because the token doesn't expire and if somebody gets the user's token, the can access some other endpoints. It's better to add the Django OAuth Toolkit to Track and use the Bearer token.

@ybekdemir

ybekdemir commented Jul 18, 2018

Copy link
Copy Markdown
Author

I thought that if users use API call then that means they are making request from code (If they are not using postman or similar tools to get data). So, if they are working with code I think token shouldn't change.

@jefmoura

Copy link
Copy Markdown
Member
  • API calls can be made from whenever they want.
  • If they are working with code, postman or any other tool, they should send a request with credentials to the server, the server will check if the credentials are valid and return a token, and then they can use the token in the next calls

@ybekdemir
ybekdemir force-pushed the issue-530 branch 4 times, most recently from 5ba68e6 to c9483b9 Compare July 19, 2018 15:25
Comment thread silo/api.py Outdated
silo = Silo.objects.get(pk=id)
if silo.public == False:
return HttpResponse("This table is not public. You must use the private API.")
url = "http://{}/api/silo/{}/data?query={}&shown_cols={}" \

@jefmoura jefmoura Jul 19, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the function reverse to generate the URL?

Comment thread silo/api.py Outdated
from urlparse import urljoin
from datetime import datetime

from django.contrib.sites.shortcuts import get_current_site

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using this import

Comment thread silo/api.py Outdated
from django.shortcuts import get_object_or_404, redirect


from rest_framework.authtoken.models import Token

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using this import

@ybekdemir
ybekdemir force-pushed the issue-530 branch 2 times, most recently from c443899 to cdb0756 Compare July 20, 2018 08:21
Comment thread silo/api.py Outdated
if silo.public == False:
return HttpResponse("This table is not public. You must use the private API.")
url = reverse('silos-data', kwargs={'id': silo.pk})
params = '?query={}&shown_cols={}'\

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know that you can use the function urlencode from the lib urllib with the request.GET as a parameter to create the URL query?

Comment thread silo/api.py Outdated
@@ -106,29 +108,32 @@ def data(self, request, id):

silo = Silo.objects.get(pk=id)
if silo.public == False:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this condition as well?

@jefmoura
jefmoura merged commit af1df38 into toladata:master Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants