parent
8e08cab3c4
commit
910d3b4beb
15 changed files with 310 additions and 36 deletions
|
@ -3,11 +3,13 @@ from django.conf.urls import url, include
|
|||
from rest_framework import routers
|
||||
|
||||
from . import views as api_v
|
||||
from ..utils import viewsets as utils_viewsets
|
||||
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
|
||||
router.register(r'administrative-urls', api_v.AdminURLs, base_name='adminurls')
|
||||
router.register(r'admin-sections', utils_viewsets.AdminSectionViewSet)
|
||||
router.register(r'admin-entries', utils_viewsets.AdminEntryViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^auth/login/', api_v.Login.as_view()),
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from django.contrib.auth import user_logged_in
|
||||
|
||||
from rest_framework import status
|
||||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.viewsets import ViewSet
|
||||
|
||||
from djoser.views import (LoginView, PasswordResetView,
|
||||
PasswordResetConfirmView)
|
||||
|
@ -39,31 +35,3 @@ class PasswordResetConfirm(PasswordResetConfirmView):
|
|||
response = super(PasswordResetConfirm, self).action(serializer)
|
||||
response.data = {}
|
||||
return response
|
||||
|
||||
|
||||
class AdminURLs(ViewSet):
|
||||
def get_view_name(self):
|
||||
return 'Admin URLs List'
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
urls = OrderedDict([
|
||||
('projects', [
|
||||
['project', 'projects', 'project'],
|
||||
['grant', 'projects', 'grant'],
|
||||
['grant-report', 'projects', 'grantreport'],
|
||||
]),
|
||||
|
||||
('collections', [
|
||||
['collection-type', 'collections_ccdb', 'collectiontype'],
|
||||
]),
|
||||
])
|
||||
|
||||
data = OrderedDict()
|
||||
for category, group in urls.items():
|
||||
paths = []
|
||||
for url in group:
|
||||
lookup = 'admin:{}_{}_changelist'.format(url[1], url[2])
|
||||
path = reverse(lookup, request=request)
|
||||
paths.append({'id': url[0], 'url': path})
|
||||
data[category] = paths
|
||||
return Response(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue