Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Transparenzportal
ckanext-odsh
Commits
dbf31141
Commit
dbf31141
authored
6 years ago
by
chbaeh
Browse files
Options
Downloads
Patches
Plain Diff
ODPSH-32: custom feed controler for seach params
parent
65708f21
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ckanext/odsh/controller.py
+64
-2
64 additions, 2 deletions
ckanext/odsh/controller.py
ckanext/odsh/plugin.py
+9
-0
9 additions, 0 deletions
ckanext/odsh/plugin.py
ckanext/odsh/templates/snippets/search_result_text.html
+1
-1
1 addition, 1 deletion
ckanext/odsh/templates/snippets/search_result_text.html
with
74 additions
and
3 deletions
ckanext/odsh/controller.py
+
64
−
2
View file @
dbf31141
...
@@ -2,9 +2,10 @@ import ckan.lib.base as base
...
@@ -2,9 +2,10 @@ import ckan.lib.base as base
from
ckan.controllers.home
import
HomeController
from
ckan.controllers.home
import
HomeController
from
ckan.controllers.user
import
UserController
from
ckan.controllers.user
import
UserController
from
ckan.controllers.package
import
PackageController
from
ckan.controllers.package
import
PackageController
from
ckan.controllers.feed
import
FeedController
,
ITEMS_LIMIT
,
_package_search
,
_create_atom_id
import
ckan.lib.helpers
as
h
import
ckan.lib.helpers
as
h
import
ckan.authz
as
authz
import
ckan.authz
as
authz
from
ckan.common
import
c
from
ckan.common
import
c
,
request
,
config
abort
=
base
.
abort
abort
=
base
.
abort
...
@@ -55,3 +56,64 @@ class OdshUserController(UserController):
...
@@ -55,3 +56,64 @@ class OdshUserController(UserController):
class
OdshPackageController
(
PackageController
):
class
OdshPackageController
(
PackageController
):
pass
pass
class
OdshFeedController
(
FeedController
):
def
custom
(
self
):
extra_fields
=
[
'
ext_startdate
'
,
'
ext_enddate
'
,
'
ext_bbox
'
,
'
ext_prev_extent
'
]
q
=
request
.
params
.
get
(
'
q
'
,
u
''
)
fq
=
''
search_params
=
{}
extras
=
{}
for
(
param
,
value
)
in
request
.
params
.
items
():
if
param
not
in
[
'
q
'
,
'
page
'
,
'
sort
'
]
+
extra_fields
\
and
len
(
value
)
and
not
param
.
startswith
(
'
_
'
):
search_params
[
param
]
=
value
fq
+=
'
%s:
"
%s
"'
%
(
param
,
value
)
if
param
in
extra_fields
:
extras
[
param
]
=
value
search_params
[
'
extras
'
]
=
extras
print
(
'
EXTRAS
'
)
print
(
search_params
)
page
=
h
.
get_page_number
(
request
.
params
)
limit
=
ITEMS_LIMIT
data_dict
=
{
'
q
'
:
q
,
'
fq
'
:
fq
,
'
start
'
:
(
page
-
1
)
*
limit
,
'
rows
'
:
limit
,
'
sort
'
:
request
.
params
.
get
(
'
sort
'
,
None
),
'
extras
'
:
extras
}
print
(
'
DATA
'
)
print
(
data_dict
)
item_count
,
results
=
_package_search
(
data_dict
)
navigation_urls
=
self
.
_navigation_urls
(
request
.
params
,
item_count
=
item_count
,
limit
=
data_dict
[
'
rows
'
],
controller
=
'
feed
'
,
action
=
'
custom
'
)
feed_url
=
self
.
_feed_url
(
request
.
params
,
controller
=
'
feed
'
,
action
=
'
custom
'
)
atom_url
=
h
.
_url_with_params
(
'
/feeds/custom.atom
'
,
search_params
.
items
())
alternate_url
=
self
.
_alternate_url
(
request
.
params
)
site_title
=
config
.
get
(
'
ckan.site_title
'
,
'
CKAN
'
)
return
self
.
output_feed
(
results
,
feed_title
=
u
'
%s - Custom query
'
%
site_title
,
feed_description
=
u
'
Recently created or updated
'
'
datasets on %s. Custom query:
\'
%s
\'
'
%
(
site_title
,
q
),
feed_link
=
alternate_url
,
feed_guid
=
_create_atom_id
(
atom_url
),
feed_url
=
feed_url
,
navigation_urls
=
navigation_urls
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
9
−
0
View file @
dbf31141
...
@@ -125,6 +125,13 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -125,6 +125,13 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
map
.
redirect
(
'
/dataset/{id}/resource/{resource_id}
'
,
'
/dataset/{id}
'
)
map
.
redirect
(
'
/dataset/{id}/resource/{resource_id}
'
,
'
/dataset/{id}
'
)
# /api ver 3 or none with matomo
GET_POST
=
dict
(
method
=
[
'
GET
'
,
'
POST
'
])
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:MamotoApiController
'
,
path_prefix
=
'
/api{ver:/3|}
'
,
ver
=
'
/3
'
)
as
m
:
m
.
connect
(
'
/action2/{logic_function}
'
,
action
=
'
action
'
,
conditions
=
GET_POST
)
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
m
.
connect
(
'
/feeds/custom.atom
'
,
action
=
'
custom
'
)
# redirect all user routes to custom controller
# redirect all user routes to custom controller
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshUserController
'
)
as
m
:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshUserController
'
)
as
m
:
...
@@ -218,6 +225,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -218,6 +225,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
# use several daterange queries agains temporal_start and temporal_end field
# use several daterange queries agains temporal_start and temporal_end field
# TODO: use field of type date_range in solr index instead
# TODO: use field of type date_range in solr index instead
def
before_search
(
self
,
search_params
):
def
before_search
(
self
,
search_params
):
print
(
'
BEFORE
'
)
print
(
search_params
)
extras
=
search_params
.
get
(
'
extras
'
)
extras
=
search_params
.
get
(
'
extras
'
)
if
not
extras
:
if
not
extras
:
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/templates/snippets/search_result_text.html
+
1
−
1
View file @
dbf31141
...
@@ -46,4 +46,4 @@ Example:
...
@@ -46,4 +46,4 @@ Example:
{{ text_no_query_none }}
{{ text_no_query_none }}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
<a
href=
{{h.remove_url_param('ext_prev_extent',
controller=
'feed'
,
action=
'custom'
)}}
>
<i
class=
"fa fa-medium fa-rss"
></i></a>
<a
href=
{{h.remove_url_param([''],
controller=
'feed'
,
action=
'custom'
)}}
>
<i
class=
"fa fa-medium fa-rss"
></i></a>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment