paperless-ngx/src/paperless/urls.py

140 lines
4.4 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-07 12:47:17 +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
from rest_framework.authtoken import views
2016-02-16 09:28:34 +00:00
from rest_framework.routers import DefaultRouter
2021-01-02 00:45:23 +01:00
from django.utils.translation import gettext_lazy as _
from django.conf import settings
2020-11-07 12:47:17 +01:00
from paperless.consumers import StatusConsumer
2016-02-16 09:28:34 +00:00
from documents.views import (
2018-01-06 18:51:10 +00:00
CorrespondentViewSet,
UnifiedSearchViewSet,
2018-01-06 18:51:10 +00:00
LogViewSet,
2018-09-05 15:25:14 +02:00
TagViewSet,
DocumentTypeViewSet,
2020-10-27 17:07:13 +01:00
IndexView,
2020-10-31 00:56:20 +01:00
SearchAutoCompleteView,
StatisticsView,
2020-12-11 14:30:18 +01:00
PostDocumentView,
SavedViewViewSet,
2020-12-27 12:43:05 +01:00
BulkEditView,
SelectionDataView,
2022-02-27 15:26:41 +01:00
BulkDownloadView,
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", UnifiedSearchViewSet)
2021-02-06 17:02:00 +01:00
api_router.register(r"logs", LogViewSet, basename="logs")
api_router.register(r"tags", TagViewSet)
2020-12-12 15:46:56 +01:00
api_router.register(r"saved_views", SavedViewViewSet)
2016-01-01 16:13:59 +00:00
2015-12-20 19:23:33 +00:00
urlpatterns = [
2022-02-27 15:26:41 +01:00
re_path(
r"^api/",
include(
[
re_path(
r"^auth/",
include(
("rest_framework.urls", "rest_framework"),
namespace="rest_framework",
),
),
re_path(
r"^search/autocomplete/",
SearchAutoCompleteView.as_view(),
name="autocomplete",
),
re_path(r"^statistics/", StatisticsView.as_view(), name="statistics"),
re_path(
r"^documents/post_document/",
PostDocumentView.as_view(),
name="post_document",
),
re_path(
r"^documents/bulk_edit/", BulkEditView.as_view(), name="bulk_edit"
),
re_path(
r"^documents/selection_data/",
SelectionDataView.as_view(),
name="selection_data",
),
re_path(
r"^documents/bulk_download/",
BulkDownloadView.as_view(),
name="bulk_download",
),
path("token/", views.obtain_auth_token),
]
+ api_router.urls
),
),
2020-11-17 22:31:43 +01:00
re_path(r"^favicon.ico$", FaviconView.as_view(), name="favicon"),
re_path(r"admin/", admin.site.urls),
2022-02-27 15:26:41 +01:00
re_path(
r"^fetch/",
include(
[
re_path(
r"^doc/(?P<pk>\d+)$",
RedirectView.as_view(
url=settings.BASE_URL + "api/documents/%(pk)s/download/"
),
),
re_path(
r"^thumb/(?P<pk>\d+)$",
RedirectView.as_view(
url=settings.BASE_URL + "api/documents/%(pk)s/thumb/"
),
),
re_path(
r"^preview/(?P<pk>\d+)$",
RedirectView.as_view(
url=settings.BASE_URL + "api/documents/%(pk)s/preview/"
),
),
]
2020-11-21 15:34:30 +01:00
),
2022-02-27 15:26:41 +01:00
),
re_path(
r"^push$",
csrf_exempt(
RedirectView.as_view(url=settings.BASE_URL + "api/documents/post_document/")
2020-11-21 15:34:30 +01:00
),
2022-02-27 15:26:41 +01:00
),
2020-11-21 15:34:30 +01:00
# Frontend assets TODO: this is pretty bad, but it works.
2022-02-27 15:26:41 +01:00
path(
"assets/<path:path>",
RedirectView.as_view(
url=settings.STATIC_URL + "frontend/en-US/assets/%(path)s"
),
),
# TODO: with localization, this is even worse! :/
2020-11-21 15:34:30 +01:00
# login, logout
2022-02-27 15:26:41 +01:00
path("accounts/", include("django.contrib.auth.urls")),
# Root of the Frontent
2022-02-27 15:26:41 +01:00
re_path(r".*", login_required(IndexView.as_view()), name="base"),
2020-10-26 00:35:24 +01:00
]
2016-02-08 23:46:16 +00:00
2020-11-07 12:47:17 +01:00
websocket_urlpatterns = [
2022-02-27 15:26:41 +01:00
re_path(r"ws/status/$", StatusConsumer.as_asgi()),
2020-11-07 12:47:17 +01:00
]
# Text in each page's <h1> (and above login form).
2022-03-02 11:05:34 -08:00
admin.site.site_header = "Paperless-ngx"
# Text at the end of each page's <title>.
2022-03-02 11:05:34 -08:00
admin.site.site_title = "Paperless-ngx"
# Text at the top of the admin index page.
2022-03-02 11:05:34 -08:00
admin.site.index_title = _("Paperless-ngx administration")