Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
Open-Data
ckanext-odsh
Commits
f9c6cb96
Commit
f9c6cb96
authored
2 years ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused IRoutes code
parent
d3dff802
No related branches found
No related tags found
2 merge requests
!41
Version 2.0.0
,
!38
Merge py3 into dev
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/controller.py
+0
-64
0 additions, 64 deletions
ckanext/odsh/controller.py
ckanext/odsh/plugin.py
+3
-58
3 additions, 58 deletions
ckanext/odsh/plugin.py
with
3 additions
and
122 deletions
ckanext/odsh/controller.py
+
0
−
64
View file @
f9c6cb96
...
@@ -2,79 +2,15 @@ from types import FunctionType
...
@@ -2,79 +2,15 @@ from types import FunctionType
import
ckan.lib.base
as
base
import
ckan.lib.base
as
base
import
decorator
import
decorator
from
ckanext.harvest.controllers.view
import
ViewController
as
HarvestController
from
ckanext.harvest.controllers.view
import
ViewController
as
HarvestController
from
ckan.controllers.feed
import
FeedController
from
ckan.controllers.feed
import
FeedController
,
ITEMS_LIMIT
,
_package_search
,
_create_atom_id
import
ckan.lib.helpers
as
h
import
ckan.authz
as
authz
import
ckan.authz
as
authz
import
logging
import
logging
import
ckan.logic
as
logic
import
ckan.logic
as
logic
from
ckan.common
import
request
,
config
abort
=
base
.
abort
abort
=
base
.
abort
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
render
=
base
.
render
render
=
base
.
render
get_action
=
logic
.
get_action
get_action
=
logic
.
get_action
class
OdshFeedController
(
FeedController
):
def
custom
(
self
):
extra_fields
=
[
'
ext_startdate
'
,
'
ext_enddate
'
,
'
ext_bbox
'
,
'
ext_prev_extent
'
]
q
=
request
.
params
.
get
(
'
q
'
,
''
)
fq
=
''
search_params
=
{}
extras
=
{}
for
(
param
,
value
)
in
list
(
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
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
}
item_count
,
results
=
_package_search
(
data_dict
)
navigation_urls
=
self
.
_navigation_urls
(
request
.
params
,
item_count
=
item_count
,
limit
=
data_dict
[
'
rows
'
],
controller
=
'
feeds
'
,
action
=
'
custom
'
)
feed_url
=
self
.
_feed_url
(
request
.
params
,
controller
=
'
feed
'
,
action
=
'
custom
'
)
atom_url
=
h
.
_url_with_params
(
'
/feeds/custom.atom
'
,
list
(
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
=
'
%s - Custom query
'
%
site_title
,
feed_description
=
'
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
)
def
only_admin
(
func
,
*
args
,
**
kwargs
):
def
only_admin
(
func
,
*
args
,
**
kwargs
):
if
not
authz
.
is_sysadmin
(
c
.
user
):
if
not
authz
.
is_sysadmin
(
c
.
user
):
abort
(
404
)
abort
(
404
)
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
3
−
58
View file @
f9c6cb96
...
@@ -2,20 +2,13 @@
...
@@ -2,20 +2,13 @@
from
dateutil.parser
import
parse
from
dateutil.parser
import
parse
import
json
import
json
import
logging
import
logging
from
multiline_formatter.formatter
import
MultilineMessagesFormatter
import
os
from
routes.mapper
import
SubMapper
import
sys
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
flask
import
Blueprint
# imports from ckan
# imports from ckan
import
ckan.lib.helpers
as
helpers
from
ckan.lib.plugins
import
DefaultTranslation
,
DefaultDatasetForm
from
ckan.lib.plugins
import
DefaultTranslation
,
DefaultDatasetForm
from
ckan.logic.validators
import
tag_string_convert
from
ckan.logic.validators
import
tag_string_convert
import
ckan.plugins
as
plugins
import
ckan.plugins
as
plugins
import
ckan.plugins.toolkit
as
toolkit
import
ckan.plugins.toolkit
as
toolkit
import
ckan.model
as
model
# imports from this extension
# imports from this extension
import
ckanext.odsh.helpers
as
odsh_helpers
import
ckanext.odsh.helpers
as
odsh_helpers
...
@@ -25,14 +18,13 @@ from .helper_pkg_dict import HelperPgkDict
...
@@ -25,14 +18,13 @@ from .helper_pkg_dict import HelperPgkDict
import
ckanext.odsh.logic.action
as
action
import
ckanext.odsh.logic.action
as
action
import
ckanext.odsh.validation
as
validation
import
ckanext.odsh.validation
as
validation
import
ckanext.odsh.search
as
search
import
ckanext.odsh.search
as
search
from
ckanext.odsh.odsh_logger
import
OdshLogger
import
ckanext.odsh.tools
as
tools
import
ckanext.odsh.tools
as
tools
from
ckanext.odsh.views
import
default
from
ckanext.odsh.views
import
default
from
ckanext.odsh.views
import
package
from
ckanext.odsh.views
import
package
from
ckanext.odsh.views
import
user
from
ckanext.odsh.views
import
user
from
ckanext.odsh.views
import
dashboard
from
ckanext.odsh.views
import
dashboard
from
ckanext.odsh.views
import
harvest
from
ckanext.odsh.views
import
harvest
from
ckanext.dcat
import
blueprints
as
dcat_view
#
from ckanext.dcat import blueprints as dcat_view
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -45,7 +37,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -45,7 +37,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
plugins
.
implements
(
plugins
.
IDatasetForm
)
plugins
.
implements
(
plugins
.
IDatasetForm
)
plugins
.
implements
(
plugins
.
IFacets
)
plugins
.
implements
(
plugins
.
IFacets
)
plugins
.
implements
(
plugins
.
IPackageController
,
inherit
=
True
)
plugins
.
implements
(
plugins
.
IPackageController
,
inherit
=
True
)
plugins
.
implements
(
plugins
.
IRoutes
,
inherit
=
True
)
plugins
.
implements
(
plugins
.
ITemplateHelpers
)
plugins
.
implements
(
plugins
.
ITemplateHelpers
)
plugins
.
implements
(
plugins
.
ITranslation
)
plugins
.
implements
(
plugins
.
ITranslation
)
plugins
.
implements
(
plugins
.
IValidators
)
plugins
.
implements
(
plugins
.
IValidators
)
...
@@ -118,8 +109,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -118,8 +109,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
toolkit
.
add_public_directory
(
config_
,
'
public
'
)
toolkit
.
add_public_directory
(
config_
,
'
public
'
)
toolkit
.
add_resource
(
'
fanstatic
'
,
'
ckanext-odsh
'
)
toolkit
.
add_resource
(
'
fanstatic
'
,
'
ckanext-odsh
'
)
# IDatasetForm
def
after_map
(
self
,
map
):
return
map
def
package_types
(
self
):
def
package_types
(
self
):
# This plugin doesn't handle any special package types, it just
# This plugin doesn't handle any special package types, it just
# registers itself as the default (above).
# registers itself as the default (above).
...
@@ -296,52 +287,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -296,52 +287,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
return
dict_pkg
return
dict_pkg
# IRoutes
map
.
redirect
(
'
/dataset/{id}/resource/{resource_id}
'
,
'
/dataset/{id}
'
)
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
m
.
connect
(
'
/feeds/custom.atom
'
,
action
=
'
custom
'
)
# redirect all user routes to custom controller
# with SubMapper(map, controller='ckanext.odsh.controller:OdshUserController') as m:
# m.connect('/user/edit', action='edit')
# m.connect(
# 'user_edit', '/user/edit/{id:.*}', action='edit', ckan_icon='cog')
# m.connect('user_delete', '/user/delete/{id}', action='delete')
# m.connect('/user/reset/{id:.*}', action='perform_reset')
# m.connect('/user/reset', action='request_reset')
# m.connect('register', '/user/register', action='register')
# m.connect('login', '/user/login', action='login')
# m.connect('/user/_logout', action='logout')
# m.connect('/user/logged_in', action='logged_in')
# m.connect('/user/logged_out', action='logged_out')
# m.connect('/user/logged_out_redirect', action='logged_out_page')
# m.connect('user_datasets', '/user/{id:(?!(generate_key|activity)).*}', action='read',
# ckan_icon='sitemap')
map
.
connect
(
'
comment_datarequest
'
,
'
/datarequest/new
'
,
controller
=
'
ckanext.datarequests.controllers.ui_controller:DataRequestsUI
'
,
action
=
'
new
'
,
conditions
=
dict
(
method
=
[
'
GET
'
,
'
POST
'
]),
ckan_icon
=
'
comment
'
)
map
.
connect
(
'
comment_datarequest
'
,
'
/datarequest/{id}
'
,
controller
=
'
ckanext.datarequests.controllers.ui_controller:DataRequestsUI
'
,
action
=
'
comment
'
,
conditions
=
dict
(
method
=
[
'
GET
'
,
'
POST
'
]),
ckan_icon
=
'
comment
'
)
return
map
def
after_map
(
self
,
map
):
return
map
# ITemplateHelpers
# ITemplateHelpers
def
get_helpers
(
self
):
def
get_helpers
(
self
):
...
...
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