FIX: setup permission check based on group membership.
former permission check, based on django model permission won't work, because we have no model, that would create the permission.
This commit is contained in:
@@ -13,6 +13,7 @@ DEFAULT_SETTINGS = (
|
|||||||
DefaultSetting('max_total_size_mib', 100),
|
DefaultSetting('max_total_size_mib', 100),
|
||||||
DefaultSetting('metadata_file_name', 'metadata.txt'),
|
DefaultSetting('metadata_file_name', 'metadata.txt'),
|
||||||
DefaultSetting('cached_zip_file_name', '.cache.zip'),
|
DefaultSetting('cached_zip_file_name', '.cache.zip'),
|
||||||
|
DefaultSetting('download_group', 'downloaders'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ from django.conf import settings
|
|||||||
# MAX_FILE_SIZE_MIB = 50
|
# MAX_FILE_SIZE_MIB = 50
|
||||||
# MAX_TOTAL_SIZE_MIB = 100
|
# MAX_TOTAL_SIZE_MIB = 100
|
||||||
# METADATA_FILE_NAME = 'metadata.txt'
|
# METADATA_FILE_NAME = 'metadata.txt'
|
||||||
# CACHED_ZIP_FILE_NAME = '.cache.zip'
|
# CACHED_ZIP_FILE_NAME = '.cache.zip'
|
||||||
|
# DOWNLOAD_GROUP = 'downloaders'
|
||||||
@@ -82,7 +82,8 @@ class ListView(generic.ListView):
|
|||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
if not request.user.has_perm('download_submissions'):
|
permission_group = app_config.settings.download_group
|
||||||
|
if not request.user.groups.filter(name=permission_group).exists():
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
return super(ListView, self).dispatch(request, *args, **kwargs)
|
return super(ListView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
@@ -130,7 +131,8 @@ class DownloadView(generic.DetailView):
|
|||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
if not request.user.has_perm('download_submissions'):
|
permission_group = app_config.settings.download_group
|
||||||
|
if not request.user.groups.filter(name=permission_group).exists():
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
return super(DownloadView, self).dispatch(request, *args, **kwargs)
|
return super(DownloadView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user