--- a/src/iconolab/search_indexes.py Mon Oct 10 12:38:03 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-import datetime
-from haystack import indexes
-from iconolab.models import Annotation
-
-
-class AnnotationIndex(indexes.SearchIndex, indexes.Indexable):
-
- ##indexed field
- text = indexes.CharField(document=True, use_template=True)
-
- title = indexes.CharField(model_attr='current_revision__title')
- description = indexes.CharField(model_attr='current_revision__description')
- tags = indexes.MultiValueField(model_attr='tags')
-
- ## tags
- def get_model(self):
- return Annotation
-
- def index_queryset(self, using=None):
- return self.get_model().objects.filter(created__lte=datetime.datetime.now())
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/search_indexes/urls.py Mon Oct 10 13:00:04 2016 +0200
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+
+from django.conf.urls import url
+from . import views
+
+urlpatterns = [
+ url(r'collection/(?P<collection_name>[a-z0-9\-]+)/model/(?P<model_type>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_with_model_search"),
+ url(r'collection/(?P<collection_name>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_haystack_search"),
+ url(r'^model/(?P<model_type>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="model_search"),
+ url(r'^global/$', views.IconolabSearchView.as_view(), name="haystack_search"),
+]
+
+
+
--- a/src/iconolab/search_indexes/views.py Mon Oct 10 12:38:03 2016 +0200
+++ b/src/iconolab/search_indexes/views.py Mon Oct 10 13:00:04 2016 +0200
@@ -46,10 +46,10 @@
if self.model_type is not None:
if collection_name is None:
#redirect to all_model_type
- redirect_url = reverse('model_search', kwargs={'model_type': self.model_type})
+ redirect_url = reverse('search_indexes:model_search', kwargs={'model_type': self.model_type})
return redirect(self.complete_url(redirect_url))
else:
- redirect_url = reverse('collection_with_model_search', kwargs={'collection_name': collection_name, 'model_type':self.model_type})
+ redirect_url = reverse('search_indexes:collection_with_model_search', kwargs={'collection_name': collection_name, 'model_type':self.model_type})
return redirect(self.complete_url(redirect_url))
else:
has_error, redirectView = self.check_kwargs(**kwargs)
--- a/src/iconolab/templates/partials/header_search_form.html Mon Oct 10 12:38:03 2016 +0200
+++ b/src/iconolab/templates/partials/header_search_form.html Mon Oct 10 13:00:04 2016 +0200
@@ -1,8 +1,8 @@
{% if collection_name %}
- <form method="GET" action="{% url 'collection_haystack_search' collection_name %}" class="navbar-form navbar-left" role="search">
+ <form method="GET" action="{% url 'search_indexes:collection_haystack_search' collection_name %}" class="navbar-form navbar-left" role="search">
{% else %}
- <form method="GET" action="{% url 'haystack_search' %}" class="navbar-form navbar-left" role="search">
+ <form method="GET" action="{% url 'search_indexes:haystack_search' %}" class="navbar-form navbar-left" role="search">
{% endif %}
<div class="form-group">
--- a/src/iconolab/urls.py Mon Oct 10 12:38:03 2016 +0200
+++ b/src/iconolab/urls.py Mon Oct 10 13:00:04 2016 +0200
@@ -19,7 +19,6 @@
from django.contrib import admin
from django import views as django_views
from iconolab import views
-from iconolab.search_indexes.views import IconolabSearchView
from django.conf import settings
from django.conf.urls.static import static
@@ -57,14 +56,10 @@
url(r'^legalmentions/', views.iconolab_misc.LegalMentionsView.as_view(), name="iconolab_legals"),
url(r'^account/', include('iconolab.auth.urls', namespace='account')),
+ url(r'^search/', include('iconolab.search_indexes.urls', namespace='search_indexes')),
url(r'^comments/', include('django_comments_xtd.urls')),
url(r'^comments/annotation/post', views.comments.post_comment_iconolab, name="post_comment"),
- url(r'collections/(?P<collection_name>[a-z0-9\-]+)/search/(?P<model_type>[a-z0-9\-]+)', IconolabSearchView.as_view(), name="collection_with_model_search"),
- url(r'^search/(?P<model_type>[a-z0-9\-]+)', IconolabSearchView.as_view(), name="model_search"),
- url(r'collections/(?P<collection_name>[a-z0-9\-]+)/search', IconolabSearchView.as_view(), name="collection_haystack_search"),
- url(r'^search/$', IconolabSearchView.as_view(), name="haystack_search"),
-
url(r'^compare/$', views.iconolab_objects.TestView.as_view(), name="compare_view")
#url(r'^search/', include('haystack.urls'), name="search_iconolab"),
]
@@ -74,5 +69,4 @@
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#static url
- print("wow runserver")
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)