Changeset View
Changeset View
Standalone View
Standalone View
swh/web/misc/origin_save.py
# Copyright (C) 2018-2021 The Software Heritage developers | # Copyright (C) 2018-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from django.conf.urls import url | from django.conf.urls import url | ||||
from django.core.paginator import Paginator | from django.core.paginator import Paginator | ||||
from django.db.models import Q | from django.db.models import Q | ||||
from django.http import JsonResponse | from django.http import JsonResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from swh.web.auth.utils import privileged_user | |||||
from swh.web.common.models import SaveOriginRequest | from swh.web.common.models import SaveOriginRequest | ||||
from swh.web.common.origin_save import ( | from swh.web.common.origin_save import ( | ||||
get_savable_visit_types, | get_savable_visit_types, | ||||
get_save_origin_task_info, | get_save_origin_task_info, | ||||
) | ) | ||||
def _origin_save_view(request): | def _origin_save_view(request): | ||||
return render( | return render( | ||||
request, | request, | ||||
"misc/origin-save.html", | "misc/origin-save.html", | ||||
{"heading": ("Request the saving of a software origin into the archive")}, | {"heading": ("Request the saving of a software origin into the archive")}, | ||||
) | ) | ||||
def _visit_save_types_list(request): | def _visit_save_types_list(request) -> JsonResponse: | ||||
visit_types = get_savable_visit_types() | """Return the list of supported visit types as json response | ||||
""" | |||||
visit_types = get_savable_visit_types(privileged_user(request)) | |||||
anlambert: could be a one liner | |||||
return JsonResponse(visit_types, safe=False) | return JsonResponse(visit_types, safe=False) | ||||
def _origin_save_requests_list(request, status): | def _origin_save_requests_list(request, status): | ||||
if status != "all": | if status != "all": | ||||
save_requests = SaveOriginRequest.objects.filter(status=status) | save_requests = SaveOriginRequest.objects.filter(status=status) | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
could be a one liner