Commit b4dc2575 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

allows curators to download former version iff they did the change

parent eb85c9aa
......@@ -421,7 +421,8 @@ def data_source_history_list(request, pk):
)
def get_log_entry_with_permission_check_or_404(request, pk, log_pk):
@login_required
def get_log_entry_with_permission_check_or_404(request, pk, log_pk, allow_curator=False, user_id=None):
if request.user.is_superuser and not models.DataSource.objects.filter(pk=pk).exists():
# Allows superuser to access to back up of deleted data source after they have been deleted
data_source = None
......@@ -430,15 +431,27 @@ def get_log_entry_with_permission_check_or_404(request, pk, log_pk):
self=None,
request=request,
queryset=models.DataSource.objects,
allow_curator=allow_curator,
), pk=pk)
log_entries = LogEntry.objects.filter(object_id=pk,
content_type=ContentType.objects.get_for_model(models.DataSource))
if user_id:
log_entries = log_entries.filter(user_id=user_id)
return data_source, get_object_or_404(
LogEntry.objects.filter(object_id=pk, content_type=ContentType.objects.get_for_model(models.DataSource)),
log_entries,
pk=log_pk,
)
@login_required
def data_source_history_download(request, pk, log_pk):
data_source, le = get_log_entry_with_permission_check_or_404(request, pk, log_pk)
data_source, le = get_log_entry_with_permission_check_or_404(
request,
pk,
log_pk,
allow_curator=True,
user_id=request.user.id,
)
file_path = business_process.get_backup_file_path(le, test_if_exists=True)
if file_path is None:
......
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