paperless-ngx/src/paperless/urls.py

76 lines
2.5 KiB
Python
Raw Normal View History

2020-11-17 22:31:43 +01:00
from django.conf.urls import include
2015-12-20 19:23:33 +00:00
from django.contrib import admin
from django.contrib.auth.decorators import login_required
2020-11-17 22:31:43 +01:00
from django.urls import path, re_path
2020-11-03 14:47:42 +01:00
from django.views.decorators.csrf import csrf_exempt
2020-10-29 00:36:39 +01:00
from django.views.generic import RedirectView
2016-02-16 09:28:34 +00:00
from rest_framework.routers import DefaultRouter
from documents.views import (
2018-01-06 18:51:10 +00:00
CorrespondentViewSet,
DocumentViewSet,
LogViewSet,
2018-09-05 15:25:14 +02:00
TagViewSet,
DocumentTypeViewSet,
SearchView,
2020-10-27 17:07:13 +01:00
IndexView,
2020-10-31 00:56:20 +01:00
SearchAutoCompleteView,
StatisticsView
2018-09-25 16:09:33 +02:00
)
2020-11-12 21:09:45 +01:00
from paperless.views import FaviconView
2016-02-16 09:28:34 +00:00
api_router = DefaultRouter()
api_router.register(r"correspondents", CorrespondentViewSet)
api_router.register(r"document_types", DocumentTypeViewSet)
api_router.register(r"documents", DocumentViewSet)
api_router.register(r"logs", LogViewSet)
api_router.register(r"tags", TagViewSet)
2016-01-01 16:13:59 +00:00
2015-12-20 19:23:33 +00:00
urlpatterns = [
2016-02-21 00:14:50 +00:00
# API
2020-11-17 22:31:43 +01:00
re_path(r"^api/auth/", include(('rest_framework.urls', 'rest_framework'), namespace="rest_framework")),
re_path(r"^api/search/autocomplete/", SearchAutoCompleteView.as_view(), name="autocomplete"),
re_path(r"^api/search/", SearchView.as_view(), name="search"),
re_path(r"^api/statistics/", StatisticsView.as_view(), name="statistics"),
re_path(r"^api/", include((api_router.urls, 'drf'), namespace="drf")),
# Favicon
2020-11-17 22:31:43 +01:00
re_path(r"^favicon.ico$", FaviconView.as_view(), name="favicon"),
2016-02-21 00:14:50 +00:00
# The Django admin
2020-11-17 22:31:43 +01:00
re_path(r"admin/", admin.site.urls),
2018-01-06 18:51:16 +00:00
2020-11-03 14:47:42 +01:00
# These redirects are here to support clients that use the old FetchView.
2020-11-17 22:31:43 +01:00
re_path(
2020-11-03 14:47:42 +01:00
r"^fetch/doc/(?P<pk>\d+)$",
RedirectView.as_view(url='/api/documents/%(pk)s/download/'),
),
2020-11-17 22:31:43 +01:00
re_path(
2020-11-03 14:47:42 +01:00
r"^fetch/thumb/(?P<pk>\d+)$",
RedirectView.as_view(url='/api/documents/%(pk)s/thumb/'),
),
2020-11-17 22:31:43 +01:00
re_path(
2020-11-03 14:47:42 +01:00
r"^fetch/preview/(?P<pk>\d+)$",
RedirectView.as_view(url='/api/documents/%(pk)s/preview/'),
),
2020-11-17 22:31:43 +01:00
re_path(r"^push$", csrf_exempt(RedirectView.as_view(url='/api/documents/post_document/'))),
2020-11-03 14:47:42 +01:00
2020-10-29 00:36:39 +01:00
# Frontend assets TODO: this is pretty bad.
path('assets/<path:path>', RedirectView.as_view(url='/static/frontend/assets/%(path)s')),
path('accounts/', include('django.contrib.auth.urls')),
2020-10-29 00:36:39 +01:00
# Root of the Frontent
2020-11-17 22:31:43 +01:00
re_path(r".*", login_required(IndexView.as_view())),
2016-02-21 00:14:50 +00:00
2020-10-26 00:35:24 +01:00
]
2016-02-08 23:46:16 +00:00
# Text in each page's <h1> (and above login form).
2020-11-13 22:06:09 +01:00
admin.site.site_header = 'Paperless-ng'
# Text at the end of each page's <title>.
2020-11-13 22:06:09 +01:00
admin.site.site_title = 'Paperless-ng'
# Text at the top of the admin index page.
2020-11-13 22:06:09 +01:00
admin.site.index_title = 'Paperless-ng administration'