Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88427105
websearch_admin_blueprint.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, Oct 18, 18:07
Size
3 KB
Mime Type
text/x-python
Expires
Sun, Oct 20, 18:07 (2 d)
Engine
blob
Format
Raw Data
Handle
21769510
Attached To
R3600 invenio-infoscience
websearch_admin_blueprint.py
View Options
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2012 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.
"""WebSearch Admin Flask Blueprint"""
import
pprint
from
string
import
rfind
,
strip
from
datetime
import
datetime
from
hashlib
import
md5
from
flask
import
Blueprint
,
session
,
make_response
,
g
,
render_template
,
\
request
,
flash
,
jsonify
,
redirect
,
url_for
,
current_app
from
invenio.cache
import
cache
from
invenio.intbitset
import
intbitset
as
HitSet
from
invenio.sqlalchemyutils
import
db
from
invenio.websearch_model
import
Collection
,
CollectionCollection
from
invenio.websession_model
import
User
from
invenio.webinterface_handler_flask_utils
import
_
,
InvenioBlueprint
from
invenio.webuser_flask
import
current_user
from
invenio.bibformat
import
format_record
from
invenio.search_engine
import
search_pattern_parenthesised
,
\
get_creation_date
,
\
perform_request_search
,
\
search_pattern
from
sqlalchemy.sql
import
operators
not_guest
=
lambda
:
not
current_user
.
is_guest
()
blueprint
=
InvenioBlueprint
(
'websearch_admin'
,
__name__
,
url_prefix
=
"/admin/websearch"
,
config
=
[],
breadcrumbs
=
[],
menubuilder
=
[(
'main.admin.websearch'
,
_
(
'Configure WebSearch'
),
'websearch_admin.index'
,
50
)])
""" Previous inputs calculations not processed """
@cache.memoize
(
3600
)
@blueprint.route
(
'/'
,
methods
=
[
'GET'
,
'POST'
])
@blueprint.route
(
'/index'
,
methods
=
[
'GET'
,
'POST'
])
@blueprint.invenio_authenticated
#@blueprint.invenio_authorized('usemessages')
@blueprint.invenio_templated
(
'websearch_admin_index.html'
)
def
index
():
collection
=
Collection
.
query
.
get_or_404
(
1
)
orphans
=
Collection
.
query
.
filter
(
Collection
.
id
!=
CollectionCollection
.
id_dad
,
id
!=
CollectionCollection
.
id_son
)
.
get_or_404
(
1
)
return
dict
(
collection
=
collection
,
orphans
=
orphans
)
@blueprint.route
(
'/modifycollectiontree'
,
methods
=
[
'GET'
,
'POST'
])
#@blueprint.invenio_wash_urlargd({'id': (int, 0), 'id_dad': (int, 0), 'score': (int, 0)})
@blueprint.invenio_authenticated
@blueprint.invenio_templated
(
'websearch_admin_index.html'
)
def
modifycollectiontree
():
id
=
request
.
args
.
get
(
'id'
,
0
,
type
=
int
)
id_dad
=
request
.
args
.
get
(
'id_dad'
,
0
,
type
=
int
)
score
=
request
.
args
.
get
(
'score'
,
0
,
type
=
int
)
flash
(
_
(
"id =
%d
id_dad =
%d
score =
%d
"
)
%
(
id
,
id_dad
,
score
),
"info"
)
collection
=
Collection
.
query
.
get_or_404
(
id
)
# check to see if it is only one dad
if
len
(
collection
.
dads
)
>
1
:
return
"multiple dads"
# get the dad
olddad
=
collection
.
dads
.
pop
()
db
.
session
.
delete
(
olddad
)
newdad
=
Collection
.
query
.
get_or_404
(
id_dad
)
newdad
.
_collection_children
.
set
(
CollectionCollection
(
id_son
=
collection
.
id
,
type
=
collection
.
type
),
score
)
db
.
session
.
commit
()
return
dict
()
#redirect(url_for('.index'))
#@blueprint.route('/managecollectiontree')
#@blueprint.invenio_authenticated
Event Timeline
Log In to Comment