Skip to content
Snippets Groups Projects
Verified Commit 1f07d0b1 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

views: Use class-based view to serve query

parent a1ea2baa
No related branches found
No related tags found
No related merge requests found
......@@ -21,12 +21,12 @@ Including another URLconf
from django.conf.urls import url
from django.contrib import admin
from swh.deposit.views import index, clients, client, SWHDepositAPI
from swh.deposit.views import index, clients, client, SWHServiceDocument
urlpatterns = [
url(r'^admin', admin.site.urls),
url(r'^deposit[/]+$', index),
url(r'^deposit/clients[/]+$', clients),
url(r'^deposit/client/(?P<client_id>[0-9]+)', client),
url(r'^deposit/sd', SWHDepositAPI().service_document)
url(r'^deposit/sd', SWHServiceDocument.as_view())
]
......@@ -6,6 +6,7 @@
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.views import View
from swh.core.config import SWHConfig
from .auth import login_required
......@@ -35,6 +36,7 @@ def client(request, client_id):
class SWHDepositAPI(SWHConfig):
class SWHServiceDocument(SWHConfig, View):
CONFIG_BASE_FILENAME = 'deposit/server'
DEFAULT_CONFIG = {
......@@ -47,7 +49,7 @@ class SWHDepositAPI(SWHConfig):
self.config = self.parse_config_file()
self.config.update(config)
def service_document(self, request):
def get(self, request):
context = {
'max_upload_size': self.config['max_upload_size'],
'verbose': self.config['verbose'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment