Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
bookshare
Commits
113e6c9e
Commit
113e6c9e
authored
Jan 04, 2017
by
Daniel W Bond
Browse files
added new listingsearchform to searchform in site-wide urls
parent
2c49520c
Changes
2
Hide whitespace changes
Inline
Side-by-side
bookshare/settings/urls.py
View file @
113e6c9e
...
...
@@ -10,6 +10,7 @@ from django.contrib.auth.decorators import login_required
from
haystack.views
import
SearchView
# imports from your apps
from
.views
import
HomepageView
,
ChartsView
from
trades.forms
import
ListingSearchForm
admin
.
autodiscover
()
...
...
@@ -26,7 +27,8 @@ urlpatterns = patterns('',
url
(
r
'^mod/'
,
include
(
'mod.urls'
)),
# search
url
(
r
'^search/'
,
login_required
(
SearchView
(),
login_url
=
'login'
),
name
=
'search'
),
url
(
r
'^search/'
,
login_required
(
SearchView
(
form_class
=
ListingSearchForm
),
login_url
=
'login'
),
name
=
'search'
),
# site-wide pages
# homepage is weird for cacheing... no special url, but different content
...
...
bookshare/trades/forms.py
View file @
113e6c9e
# core django imports
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
# third party imports
from
crispy_forms.helper
import
FormHelper
from
crispy_forms.layout
import
Button
,
Submit
,
Layout
,
Fieldset
,
HTML
,
Field
from
crispy_forms.bootstrap
import
AppendedPrependedText
,
FormActions
from
haystack.forms
import
SearchForm
# imports from your apps
from
.models
import
Listing
,
Bid
,
Flag
,
BidFlag
,
Rating
...
...
@@ -239,3 +241,10 @@ class RatingForm(forms.ModelForm):
class
Meta
:
model
=
Rating
# overwrites the search form to include bootstrap css classes and autofocus
class
ListingSearchForm
(
SearchForm
):
q
=
forms
.
CharField
(
required
=
False
,
label
=
_
(
'Search'
),
widget
=
forms
.
TextInput
(
attrs
=
{
'type'
:
'search'
,
# default
'class'
:
'form-control'
,
# bootstrap
'autofocus'
:
'autofocus'
}))
# field already selected
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment