From c7877c67ff89f506c6cb3b76d53caa2496881cb8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 24 Jun 2019 23:51:46 +1000 Subject: [PATCH] Add a simple endpoint with server information --- InvenTree/InvenTree/urls.py | 4 ++++ InvenTree/InvenTree/views.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 716ff25767..f88609bd81 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -31,6 +31,7 @@ from django.views.generic.base import RedirectView from rest_framework.documentation import include_docs_urls from .views import IndexView, SearchView, SettingsView, EditUserView, SetPasswordView +from .views import InfoView from users.urls import user_urls @@ -45,6 +46,9 @@ apipatterns = [ # User URLs url(r'^user/', include(user_urls)), + + # InvenTree information endpoint + url(r'^$', InfoView.as_view(), name='inventree-info'), ] urlpatterns = [ diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index a564705ac2..610f3c0c00 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -19,6 +19,7 @@ from part.models import Part from .forms import DeleteForm, EditUserForm, SetPasswordForm from .helpers import str2bool +from .version import inventreeVersion from rest_framework import views @@ -392,6 +393,21 @@ class AjaxDeleteView(AjaxMixin, UpdateView): return self.renderJsonResponse(request, form, data=data, context=context) +class InfoView(AjaxView): + """ Simple JSON endpoint for InvenTree information. + Use to confirm that the server is running, etc. + """ + + def get(self, request, *args, **kwargs): + + data = { + 'server': 'InvenTree', + 'version': inventreeVersion() + } + + return JsonResponse(data) + + class EditUserView(AjaxUpdateView): """ View for editing user information """