Changeset View
Changeset View
Standalone View
Standalone View
swh/web/admin/deposit.py
# Copyright (C) 2018-2019 The Software Heritage developers | # Copyright (C) 2018-2019 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 | ||||
import json | import json | ||||
import requests | import requests | ||||
from django.core.cache import cache | from django.core.cache import cache | ||||
from django.conf import settings | from django.conf import settings | ||||
from django.contrib.admin.views.decorators import staff_member_required | from django.contrib.admin.views.decorators import staff_member_required | ||||
from django.core.paginator import Paginator | from django.core.paginator import Paginator | ||||
from django.http import HttpResponse | from django.http import HttpResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from requests.auth import HTTPBasicAuth | from requests.auth import HTTPBasicAuth | ||||
import sentry_sdk | |||||
from swh.web.admin.adminurls import admin_route | from swh.web.admin.adminurls import admin_route | ||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
config = get_config()['deposit'] | config = get_config()['deposit'] | ||||
@admin_route(r'deposit/', view_name='admin-deposit') | @admin_route(r'deposit/', view_name='admin-deposit') | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | try: | ||||
'status': d['status'], | 'status': d['status'], | ||||
'status_detail': d['status_detail'], | 'status_detail': d['status_detail'], | ||||
'swh_anchor_id': d['swh_anchor_id'], | 'swh_anchor_id': d['swh_anchor_id'], | ||||
'swh_anchor_id_context': d['swh_anchor_id_context'], | 'swh_anchor_id_context': d['swh_anchor_id_context'], | ||||
'swh_id': d['swh_id'], | 'swh_id': d['swh_id'], | ||||
'swh_id_context': d['swh_id_context'] | 'swh_id_context': d['swh_id_context'] | ||||
} for d in data] | } for d in data] | ||||
except Exception: | except Exception as exc: | ||||
sentry_sdk.capture_exception(exc) | |||||
table_data['error'] = ('An error occurred while retrieving ' | table_data['error'] = ('An error occurred while retrieving ' | ||||
'the list of deposits !') | 'the list of deposits !') | ||||
return HttpResponse(json.dumps(table_data), | return HttpResponse(json.dumps(table_data), | ||||
content_type='application/json') | content_type='application/json') |