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
e1ea89c6
Commit
e1ea89c6
authored
6 years ago
by
chbaeh
Browse files
Options
Downloads
Patches
Plain Diff
add catalog tracking
parent
f1ef81ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/controller.py
+9
-2
9 additions, 2 deletions
ckanext/odsh/controller.py
ckanext/odsh/plugin.py
+28
-2
28 additions, 2 deletions
ckanext/odsh/plugin.py
with
37 additions
and
4 deletions
ckanext/odsh/controller.py
+
9
−
2
View file @
e1ea89c6
...
@@ -13,6 +13,8 @@ import matomo
...
@@ -13,6 +13,8 @@ import matomo
import
ckan.logic
as
logic
import
ckan.logic
as
logic
from
ckan.common
import
c
,
request
,
config
from
ckan.common
import
c
,
request
,
config
import
hashlib
import
hashlib
import
ckan.plugins.toolkit
as
toolkit
from
ckanext.dcat.controllers
import
DCATController
abort
=
base
.
abort
abort
=
base
.
abort
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -64,7 +66,7 @@ class OdshUserController(UserController):
...
@@ -64,7 +66,7 @@ class OdshUserController(UserController):
class
OdshPackageController
(
PackageController
):
class
OdshPackageController
(
PackageController
):
pass
pass
class
Mamoto
ApiController
(
ApiController
):
class
Odsh
ApiController
(
ApiController
):
def
action
(
self
,
logic_function
,
ver
=
None
):
def
action
(
self
,
logic_function
,
ver
=
None
):
try
:
try
:
function
=
logic
.
get_action
(
logic_function
)
function
=
logic
.
get_action
(
logic_function
)
...
@@ -89,6 +91,11 @@ class MamotoApiController(ApiController):
...
@@ -89,6 +91,11 @@ class MamotoApiController(ApiController):
return
ApiController
.
action
(
self
,
logic_function
,
ver
)
return
ApiController
.
action
(
self
,
logic_function
,
ver
)
class
OdshDCATController
(
DCATController
):
def
read_catalog
(
self
,
_format
):
matomo
.
create_matomo_request
()
return
DCATController
.
read_catalog
(
self
,
_format
)
class
OdshFeedController
(
FeedController
):
class
OdshFeedController
(
FeedController
):
def
custom
(
self
):
def
custom
(
self
):
matomo
.
create_matomo_request
()
matomo
.
create_matomo_request
()
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
28
−
2
View file @
e1ea89c6
...
@@ -61,13 +61,27 @@ def odsh_group_id_selected(selected, group_id):
...
@@ -61,13 +61,27 @@ def odsh_group_id_selected(selected, group_id):
return
False
return
False
def
remove_route
(
map
,
routename
):
route
=
None
for
i
,
r
in
enumerate
(
map
.
matchlist
):
if
r
.
name
==
routename
:
route
=
r
break
if
route
is
not
None
:
map
.
matchlist
.
remove
(
route
)
for
key
in
map
.
maxkeys
:
if
key
==
route
.
maxkeys
:
map
.
maxkeys
.
pop
(
key
)
map
.
_routenames
.
pop
(
route
.
name
)
break
class
OdshIcapPlugin
(
plugins
.
SingletonPlugin
):
class
OdshIcapPlugin
(
plugins
.
SingletonPlugin
):
plugins
.
implements
(
plugins
.
IUploader
,
inherit
=
True
)
plugins
.
implements
(
plugins
.
IUploader
,
inherit
=
True
)
def
get_resource_uploader
(
self
,
data_dict
):
def
get_resource_uploader
(
self
,
data_dict
):
return
ODSHResourceUpload
(
data_dict
)
return
ODSHResourceUpload
(
data_dict
)
class
OdshPlugin
(
plugins
.
SingletonPlugin
,
DefaultTranslation
,
DefaultDatasetForm
):
class
OdshPlugin
(
plugins
.
SingletonPlugin
,
DefaultTranslation
,
DefaultDatasetForm
):
plugins
.
implements
(
plugins
.
IConfigurer
)
plugins
.
implements
(
plugins
.
IConfigurer
)
plugins
.
implements
(
plugins
.
ITemplateHelpers
)
plugins
.
implements
(
plugins
.
ITemplateHelpers
)
...
@@ -128,9 +142,21 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -128,9 +142,21 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
map
.
redirect
(
'
/dataset/{id}/resource/{resource_id}
'
,
'
/dataset/{id}
'
)
map
.
redirect
(
'
/dataset/{id}/resource/{resource_id}
'
,
'
/dataset/{id}
'
)
if
p
.
toolkit
.
asbool
(
config
.
get
(
'
ckanext.dcat.enable_rdf_endpoints
'
,
True
)):
remove_route
(
map
,
'
dcat_catalog
'
)
map
.
connect
(
'
dcat_catalog
'
,
config
.
get
(
'
ckanext.dcat.catalog_endpoint
'
,
'
/catalog.{_format}
'
),
controller
=
'
ckanext.odsh.controller:OdshDCATController
'
,
action
=
'
read_catalog
'
,
requirements
=
{
'
_format
'
:
'
xml|rdf|n3|ttl|jsonld
'
})
# with SubMapper(map, controller='ckanext.odsh.controller:OdshApiController') as m:
# m.connect('/catalog2', action='read_catalog')
# /api ver 3 or none with matomo
# /api ver 3 or none with matomo
GET_POST
=
dict
(
method
=
[
'
GET
'
,
'
POST
'
])
GET_POST
=
dict
(
method
=
[
'
GET
'
,
'
POST
'
])
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:
Mamoto
ApiController
'
,
path_prefix
=
'
/api{ver:/3|}
'
,
ver
=
'
/3
'
)
as
m
:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:
Odsh
ApiController
'
,
path_prefix
=
'
/api{ver:/3|}
'
,
ver
=
'
/3
'
)
as
m
:
m
.
connect
(
'
/action/{logic_function}
'
,
action
=
'
action
'
,
conditions
=
GET_POST
)
m
.
connect
(
'
/action/{logic_function}
'
,
action
=
'
action
'
,
conditions
=
GET_POST
)
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
...
...
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