fixed broken test for good and improved file api

This commit is contained in:
vabene1111
2021-01-28 16:21:19 +01:00
parent 93e965697a
commit cc980b2e8a
2 changed files with 13 additions and 5 deletions

View File

@@ -23,7 +23,15 @@ class TestViewsApi(TestViews):
self.assertEqual(self.superuser_client.get(url).status_code, 200)
def test_file_permission(self):
url = reverse('api_get_recipe_file', args=[1])
recipe = Recipe.objects.create(
internal=False,
link='test',
working_time=1,
waiting_time=1,
created_by=auth.get_user(self.user_client_1)
)
url = reverse('api_get_recipe_file', args=[recipe.pk])
self.assertEqual(self.anonymous_client.get(url).status_code, 302)
self.assertEqual(self.guest_client_1.get(url).status_code, 200)

View File

@@ -402,10 +402,10 @@ def get_external_file_link(request, recipe_id):
@group_required('guest')
def get_recipe_file(request, recipe_id):
recipe = Recipe.objects.get(id=recipe_id)
# if not recipe.cors_link:
# update_recipe_links(recipe)
return FileResponse(get_recipe_provider(recipe).get_file(recipe))
if recipe.storage:
return FileResponse(get_recipe_provider(recipe).get_file(recipe))
else:
return FileResponse()
@group_required('user')