Commit e70ce322 authored by felix.herrmann's avatar felix.herrmann
Browse files

Merge branch...

Merge branch '432-files-not-accessible-at-restricted-access-when-access-has-been-granted' into 'master'

Resolve "Files not accessible at "restricted access" when access has been granted"

Closes #432

See merge request !406
parents cc068cef 9a07193c
......@@ -202,11 +202,11 @@ def check_perms_403(permission, user, dd_obj):
raise PermissionDenied
def is_curator_or_check_perms(permission, user, ds): # ds.dataset_management_object
def is_curator_or_check_perms_for_ds(permission, user, ds):
if user in ds.get_curators():
return True
else:
check = check_perms(permission, user, ds.dataset_management_object)
check = check_perms(permission, user, ds)
return check
......
......@@ -9,7 +9,7 @@ from django.utils.translation import gettext as _
from django_sendfile import sendfile
from discuss_data.core.decorators import dd_tou_accepted
from discuss_data.core.helpers import check_perms, is_curator_or_check_perms
from discuss_data.core.helpers import check_perms, is_curator_or_check_perms_for_ds
from discuss_data.core.views import core_search_view
from discuss_data.dddatasets.models import (
DataFile,
......@@ -78,8 +78,11 @@ def files(request, uuid):
datafile.FILE_TYPE_CONVERTED,
):
# if dataset is RA check permissions
if ds.data_access != ds.RESTRICTED_ACCESS or is_curator_or_check_perms(
"ra_view_dataset", request.user, datafile.dataset
if (
ds.data_access != ds.RESTRICTED_ACCESS
or is_curator_or_check_perms_for_ds(
"ra_view_dataset", request.user, datafile.dataset
)
):
datafiles.append(
(datafile, datafile.file.size, datafile.get_file_format())
......@@ -114,7 +117,7 @@ def files_zip(request, uuid):
except DataFile.DoesNotExist as e:
raise Http404 from e
if ds.data_access != ds.RESTRICTED_ACCESS or is_curator_or_check_perms(
if ds.data_access != ds.RESTRICTED_ACCESS or is_curator_or_check_perms_for_ds(
"ra_view_dataset", request.user, datafile.dataset
):
return download(request, datafile)
......@@ -136,7 +139,7 @@ def files_download(request, uuid, df_uuid):
datafile.FILE_TYPE_CONVERTED,
):
# if dataset is RA check permissions
if ds.data_access != ds.RESTRICTED_ACCESS or is_curator_or_check_perms(
if ds.data_access != ds.RESTRICTED_ACCESS or is_curator_or_check_perms_for_ds(
"ra_view_dataset", request.user, datafile.dataset
):
return download(request, datafile)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment