fixed link creation and updated model

This commit is contained in:
vabene1111
2018-06-06 23:31:47 +02:00
parent 2e2144a9e3
commit 8b6f7bd7cb
9 changed files with 23 additions and 46 deletions

View File

@ -31,9 +31,9 @@ def import_all(monitor):
import_count = 0
for recipe in recipes['entries']: # TODO check if has_more is set and import that as well
path = recipe['path_lower']
if not Recipe.objects.filter(path=path).exists() and not RecipeImport.objects.filter(path=path).exists():
if not Recipe.objects.filter(file_path=path).exists() and not RecipeImport.objects.filter(file_path=path).exists():
name = os.path.splitext(recipe['name'])[0]
new_recipe = RecipeImport(name=name, path=path, storage=monitor.storage, file_uid=recipe['id'])
new_recipe = RecipeImport(name=name, file_path=path, storage=monitor.storage, file_uid=recipe['id'])
new_recipe.save()
import_count += 1
@ -46,16 +46,16 @@ def import_all(monitor):
return True
def get_share_link(recipe_path):
url = "https://api.dropboxapi.com/2/sharing/create_shared_link"
def get_share_link(recipe):
url = "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"
headers = {
"Authorization": "Bearer " + settings.DROPBOX_API_KEY,
"Authorization": "Bearer " + recipe.storage.token,
"Content-Type": "application/json"
}
data = {
"path": recipe_path
"path": recipe.file_uid
}
r = requests.post(url, headers=headers, data=json.dumps(data))