Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101333708
websearch_forms.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 7, 20:59
Size
2 KB
Mime Type
text/x-python
Expires
Sun, Feb 9, 20:59 (2 d)
Engine
blob
Format
Raw Data
Handle
24136557
Attached To
R3600 invenio-infoscience
websearch_forms.py
View Options
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2011 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""WebMessage Forms"""
from
flask
import
url_for
from
invenio.webinterface_handler_flask_utils
import
_
from
invenio.bibknowledge
import
get_kb_mappings
from
invenio.wtforms_utils
import
InvenioBaseForm
,
AutocompleteField
,
\
RowWidget
from
wtforms
import
TextField
from
wtforms
import
FormField
,
SelectField
from
wtforms
import
Form
as
WTFormDefault
from
wtforms.ext.sqlalchemy.fields
import
QuerySelectField
class
JournalForm
(
WTFormDefault
):
name
=
QuerySelectField
(
''
,
get_pk
=
lambda
i
:
i
[
'key'
],
get_label
=
lambda
i
:
i
[
'value'
],
query_factory
=
lambda
:
[{
'key'
:
''
,
'value'
:
_
(
'Any journal'
)}]
+
get_kb_mappings
(
'EJOURNALS'
))
vol
=
TextField
(
_
(
'Vol'
))
page
=
TextField
(
_
(
'Pg'
))
class
EasySearchForm
(
InvenioBaseForm
):
"""Defines form for easy seach popup."""
author
=
AutocompleteField
(
_
(
'Author'
),
data_provide
=
"typeahead-url"
,
data_source
=
lambda
:
url_for
(
'search.autocomplete'
,
field
=
'exactauthor'
))
title
=
TextField
(
_
(
'Title'
))
rn
=
AutocompleteField
(
_
(
'Report number'
),
data_provide
=
"typeahead-url"
,
data_source
=
lambda
:
url_for
(
'search.autocomplete'
,
field
=
'reportnumber'
))
aff
=
AutocompleteField
(
_
(
'Affiliation'
),
data_provide
=
"typeahead-url"
,
data_source
=
lambda
:
url_for
(
'search.autocomplete'
,
field
=
'affiliation'
))
cn
=
AutocompleteField
(
_
(
'Collaboration'
),
data_provide
=
"typeahead-url"
,
data_source
=
lambda
:
url_for
(
'search.autocomplete'
,
field
=
'collaboration'
))
k
=
AutocompleteField
(
_
(
'Keywords'
),
data_provide
=
"typeahead-url"
,
data_source
=
lambda
:
url_for
(
'search.autocomplete'
,
field
=
'keyword'
))
journal
=
FormField
(
JournalForm
,
widget
=
RowWidget
())
class
WebSearchUserSettingsForm
(
InvenioBaseForm
):
of
=
SelectField
(
_
(
'Results per page'
),
choices
=
[(
'10'
,
'10'
),
(
'25'
,
'25'
),
(
'50'
,
'50'
),
(
'100'
,
'100'
)])
websearch_hotkeys
=
SelectField
(
_
(
'Hotkeys'
),
choices
=
[(
'0'
,
_
(
'Disable'
)),
(
'1'
,
_
(
'Enable'
))])
Event Timeline
Log In to Comment