Allow the home page to include quickie search
make it easier for any "non-master" view to do so
This commit is contained in:
parent
4c3b189108
commit
3a6ced388a
|
@ -65,7 +65,16 @@ class CommonView(View):
|
||||||
image_url = self.rattail_config.get(
|
image_url = self.rattail_config.get(
|
||||||
'tailbone', 'main_image_url',
|
'tailbone', 'main_image_url',
|
||||||
default=self.request.static_url('tailbone:static/img/home_logo.png'))
|
default=self.request.static_url('tailbone:static/img/home_logo.png'))
|
||||||
return {'image_url': image_url, 'use_buefy': self.get_use_buefy()}
|
|
||||||
|
context = {
|
||||||
|
'image_url': image_url,
|
||||||
|
'use_buefy': self.get_use_buefy(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.expose_quickie_search:
|
||||||
|
context['quickie'] = self.get_quickie_context()
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
def robots_txt(self):
|
def robots_txt(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -31,6 +31,7 @@ import os
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
|
from rattail.core import Object
|
||||||
from rattail.util import progress_loop
|
from rattail.util import progress_loop
|
||||||
|
|
||||||
from pyramid import httpexceptions
|
from pyramid import httpexceptions
|
||||||
|
@ -48,6 +49,8 @@ class View(object):
|
||||||
"""
|
"""
|
||||||
Base class for all class-based views.
|
Base class for all class-based views.
|
||||||
"""
|
"""
|
||||||
|
# quickie (search)
|
||||||
|
expose_quickie_search = False
|
||||||
|
|
||||||
def __init__(self, request, context=None):
|
def __init__(self, request, context=None):
|
||||||
self.request = request
|
self.request = request
|
||||||
|
@ -154,3 +157,18 @@ class View(object):
|
||||||
filename = filename.encode('ascii', 'replace')
|
filename = filename.encode('ascii', 'replace')
|
||||||
response.content_disposition = str('attachment; filename="{}"'.format(filename))
|
response.content_disposition = str('attachment; filename="{}"'.format(filename))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def get_quickie_context(self):
|
||||||
|
return Object(
|
||||||
|
url=self.get_quickie_url(),
|
||||||
|
perm=self.get_quickie_perm(),
|
||||||
|
placeholder=self.get_quickie_placeholder())
|
||||||
|
|
||||||
|
def get_quickie_url(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_quickie_perm(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_quickie_placeholder(self):
|
||||||
|
pass
|
||||||
|
|
|
@ -41,7 +41,6 @@ from sqlalchemy_utils.functions import get_primary_keys, get_columns
|
||||||
|
|
||||||
from rattail.db import model, Session as RattailSession
|
from rattail.db import model, Session as RattailSession
|
||||||
from rattail.db.continuum import model_transaction_query
|
from rattail.db.continuum import model_transaction_query
|
||||||
from rattail.core import Object
|
|
||||||
from rattail.util import prettify, OrderedDict, simple_error
|
from rattail.util import prettify, OrderedDict, simple_error
|
||||||
from rattail.time import localtime
|
from rattail.time import localtime
|
||||||
from rattail.threads import Thread
|
from rattail.threads import Thread
|
||||||
|
@ -105,7 +104,6 @@ class MasterView(View):
|
||||||
|
|
||||||
# quickie (search)
|
# quickie (search)
|
||||||
supports_quickie_search = False
|
supports_quickie_search = False
|
||||||
expose_quickie_search = False
|
|
||||||
|
|
||||||
# set to True to declare model as "contact"
|
# set to True to declare model as "contact"
|
||||||
is_contact = False
|
is_contact = False
|
||||||
|
@ -2327,11 +2325,7 @@ class MasterView(View):
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.expose_quickie_search:
|
if self.expose_quickie_search:
|
||||||
context['quickie'] = Object(
|
context['quickie'] = self.get_quickie_context()
|
||||||
url=self.get_quickie_url(),
|
|
||||||
perm=self.get_quickie_perm(),
|
|
||||||
placeholder=self.get_quickie_placeholder(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.grid_index:
|
if self.grid_index:
|
||||||
context['grid_count'] = self.grid_count
|
context['grid_count'] = self.grid_count
|
||||||
|
|
Loading…
Reference in a new issue