Basic Index and Search endpoints

Index at /index/
Search at /search/
Search view accepts POST requests with search data
This commit is contained in:
Oliver 2018-05-08 23:44:51 +10:00
parent c821d22b87
commit 8000affeee
5 changed files with 38 additions and 8 deletions

View File

@ -21,6 +21,8 @@ from django.conf.urls.static import static
from django.views.generic.base import RedirectView
from rest_framework.documentation import include_docs_urls
from .views import IndexView, SearchView
from users.urls import user_urls
admin.site.site_header = "InvenTree Admin"
@ -50,6 +52,9 @@ urlpatterns = [
url(r'^logout/', auth_views.logout, {'template_name': 'registration/logout.html'}, name='logout'),
url(r'^admin/', admin.site.urls, name='inventree-admin'),
url(r'^index/', IndexView.as_view(), name='index'),
url(r'^search/', SearchView.as_view(), name='search'),
url(r'^api/', include(apipatterns)),
url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
]
@ -62,4 +67,4 @@ if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Send any unknown URLs to the parts page
urlpatterns += [url(r'^.*$', RedirectView.as_view(url='/part/', permanent=False), name='part-index')]
urlpatterns += [url(r'^.*$', RedirectView.as_view(url='/index/', permanent=False), name='index')]

View File

@ -6,6 +6,8 @@ from django.http import JsonResponse
from django.views import View
from django.views.generic import UpdateView, CreateView, DeleteView
from django.views.generic.base import TemplateView
from rest_framework import views
from django.http import JsonResponse
@ -207,3 +209,19 @@ class AjaxDeleteView(AjaxMixin, DeleteView):
else:
return response
class IndexView(TemplateView):
template_name = 'InvenTree/index.html'
class SearchView(TemplateView):
template_name = 'InvenTree/search.html'
def post(self, request, *args, **kwargs):
context = self.get_context_data()
return super(TemplateView, self).render_to_response(context)

View File

@ -1,10 +1,11 @@
{% extends "base.html" %}
{% block content %}
<h3>InvenTree</h3>
<p>Index!</p>
{% endblock %}
{% block js_load %}
{{ block.super }}
{% endblock %}

View File

@ -1,10 +1,15 @@
{% extends "base.html"% }
{% extends "base.html" %}
{% block content %}
<h3>InvenTree Search</h3>
<p>
Search stuff goes here.
</p>
{% endblock %}
{% block js_load %}
{{ block.super }}
{% endblock %}

View File

@ -12,11 +12,12 @@
<li><a href="{% url 'company-index' %}">Companies</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<form class="navbar-form navbar-left" action="/action_page.php">
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
{% csrf_token %}
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
<input type="text" name='search' class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
</form>
{% if user.is_authenticated %}
<li class='dropdown'>