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
|
2020-11-09 15:28:12 +01:00
|
|
|
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
|
2020-12-03 18:36:23 +01:00
|
|
|
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 _
|
|
|
|
|
|
2021-05-14 14:22:35 +09:00
|
|
|
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,
|
2021-03-07 13:16:23 +01:00
|
|
|
UnifiedSearchViewSet,
|
2018-01-06 18:51:10 +00:00
|
|
|
LogViewSet,
|
2018-09-05 15:25:14 +02:00
|
|
|
TagViewSet,
|
2020-10-25 23:03:02 +01:00
|
|
|
DocumentTypeViewSet,
|
2020-10-27 17:07:13 +01:00
|
|
|
IndexView,
|
2020-10-31 00:56:20 +01:00
|
|
|
SearchAutoCompleteView,
|
2020-12-03 18:36:23 +01:00
|
|
|
StatisticsView,
|
2020-12-11 14:30:18 +01:00
|
|
|
PostDocumentView,
|
2020-12-15 03:13:22 +01:00
|
|
|
SavedViewViewSet,
|
2020-12-27 12:43:05 +01:00
|
|
|
BulkEditView,
|
2021-02-20 16:09:29 +01:00
|
|
|
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
|
|
|
|
2020-10-25 23:03:02 +01:00
|
|
|
api_router = DefaultRouter()
|
|
|
|
|
api_router.register(r"correspondents", CorrespondentViewSet)
|
|
|
|
|
api_router.register(r"document_types", DocumentTypeViewSet)
|
2021-03-07 13:16:23 +01:00
|
|
|
api_router.register(r"documents", UnifiedSearchViewSet)
|
2021-02-06 17:02:00 +01:00
|
|
|
api_router.register(r"logs", LogViewSet, basename="logs")
|
2020-10-25 23:03:02 +01:00
|
|
|
api_router.register(r"tags", TagViewSet)
|
2020-12-12 15:46:56 +01:00
|
|
|
api_router.register(r"saved_views", SavedViewViewSet)
|
2020-10-25 23:03:02 +01:00
|
|
|
|
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"
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-12-30 00:26:06 +01:00
|
|
|
# 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")),
|
2020-10-25 23:03:02 +01:00
|
|
|
# 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
|
|
|
]
|
|
|
|
|
|
2017-05-25 20:16:59 +10: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"
|
2017-05-25 20:16:59 +10:00
|
|
|
# Text at the end of each page's <title>.
|
2022-03-02 11:05:34 -08:00
|
|
|
admin.site.site_title = "Paperless-ngx"
|
2017-05-25 20:16:59 +10:00
|
|
|
# Text at the top of the admin index page.
|
2022-03-02 11:05:34 -08:00
|
|
|
admin.site.index_title = _("Paperless-ngx administration")
|