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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
897bc6ed
Commit
897bc6ed
authored
6 years ago
by
chbaeh
Browse files
Options
Downloads
Patches
Plain Diff
ODPSH-281: extend search for orgs
parent
f22be2fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ckanext/odsh/controller.py
+21
-75
21 additions, 75 deletions
ckanext/odsh/controller.py
ckanext/odsh/plugin.py
+2
-5
2 additions, 5 deletions
ckanext/odsh/plugin.py
ckanext/odsh/validation.py
+0
-1
0 additions, 1 deletion
ckanext/odsh/validation.py
with
23 additions
and
81 deletions
ckanext/odsh/controller.py
+
21
−
75
View file @
897bc6ed
...
@@ -4,7 +4,7 @@ import decorator
...
@@ -4,7 +4,7 @@ import decorator
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.api
import
ApiController
from
ckan.controllers.api
import
ApiController
from
ckan.controllers.
group
import
Group
Controller
from
ckan.controllers.
organization
import
Organization
Controller
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
from
ckan.controllers.package
import
PackageController
from
ckan.controllers.package
import
PackageController
...
@@ -98,79 +98,24 @@ class OdshPackageController(PackageController):
...
@@ -98,79 +98,24 @@ class OdshPackageController(PackageController):
return
super
(
OdshPackageController
,
self
).
edit_view
(
id
,
resource_id
,
view_id
)
return
super
(
OdshPackageController
,
self
).
edit_view
(
id
,
resource_id
,
view_id
)
class
OdshGroupController
(
GroupController
):
class
OdshGroupController
(
OrganizationController
):
def
index
(
self
):
group_type
=
self
.
_guess_group_type
()
page
=
h
.
get_page_number
(
request
.
params
)
or
1
items_per_page
=
21
context
=
{
'
model
'
:
model
,
'
session
'
:
model
.
Session
,
def
_action
(
self
,
name
):
'
user
'
:
c
.
user
,
'
for_view
'
:
True
,
'
with_private
'
:
False
}
query
=
c
.
q
=
request
.
params
.
get
(
'
q
'
,
''
)
sort_by
=
c
.
sort_by_selected
=
request
.
params
.
get
(
'
sort
'
)
try
:
self
.
_check_access
(
'
site_read
'
,
context
)
self
.
_check_access
(
'
group_list
'
,
context
)
except
NotAuthorized
:
abort
(
403
,
_
(
'
Not authorized to see this page
'
))
# pass user info to context as needed to view private datasets of
action
=
super
(
OdshGroupController
,
self
).
_action
(
name
)
# orgs correctly
if
c
.
userobj
:
context
[
'
user_id
'
]
=
c
.
userobj
.
id
context
[
'
user_is_admin
'
]
=
c
.
userobj
.
sysadmin
def
custom_org_list
(
context
,
data_dict
):
query
=
data_dict
[
'
q
'
]
result
=
action
(
context
,
data_dict
)
for
q
in
query
.
split
(
'
'
):
for
q
in
query
.
split
(
'
'
):
try
:
data_dict
[
'
q
'
]
=
q
data_dict_global_results
=
{
result
+=
action
(
context
,
data_dict
)
'
all_fields
'
:
False
,
return
result
'
q
'
:
q
,
'
sort
'
:
sort_by
,
'
type
'
:
group_type
or
'
group
'
,
}
print
(
"
QUERY
"
)
print
(
group_type
)
print
(
q
)
global_results
=
self
.
_action
(
'
group_list
'
)(
context
,
data_dict_global_results
)
except
ValidationError
as
e
:
if
e
.
error_dict
and
e
.
error_dict
.
get
(
'
message
'
):
msg
=
e
.
error_dict
[
'
message
'
]
else
:
msg
=
str
(
e
)
h
.
flash_error
(
msg
)
c
.
page
=
h
.
Page
([],
0
)
return
render
(
self
.
_index_template
(
group_type
),
extra_vars
=
{
'
group_type
'
:
group_type
})
data_dict_page_results
=
{
'
all_fields
'
:
True
,
'
q
'
:
q
,
'
sort
'
:
sort_by
,
'
type
'
:
group_type
or
'
group
'
,
'
limit
'
:
items_per_page
,
'
offset
'
:
items_per_page
*
(
page
-
1
),
'
include_extras
'
:
True
}
page_results
=
self
.
_action
(
'
group_list
'
)(
context
,
data_dict_page_results
)
print
(
"
GROUPS
"
)
print
(
global_results
)
c
.
page
=
h
.
Page
(
collection
=
global_results
,
page
=
page
,
url
=
h
.
pager_url
,
items_per_page
=
items_per_page
,
)
c
.
page
.
items
=
page_results
return
render
(
self
.
_index_template
(
group_type
),
extra_vars
=
{
'
group_type
'
:
group_type
})
if
name
is
'
group_list
'
:
return
custom_org_list
else
:
return
super
(
OdshGroupController
,
self
).
_action
(
name
)
class
OdshApiController
(
ApiController
):
class
OdshApiController
(
ApiController
):
def
action
(
self
,
logic_function
,
ver
=
None
):
def
action
(
self
,
logic_function
,
ver
=
None
):
...
@@ -287,16 +232,17 @@ def only_admin(func, *args, **kwargs):
...
@@ -287,16 +232,17 @@ def only_admin(func, *args, **kwargs):
abort
(
404
)
abort
(
404
)
return
func
(
*
args
,
**
kwargs
)
return
func
(
*
args
,
**
kwargs
)
class
MetaClass
(
type
):
class
MetaClass
(
type
):
def
__new__
(
meta
,
classname
,
bases
,
classDict
):
def
__new__
(
meta
,
classname
,
bases
,
classDict
):
newClassDict
=
{}
newClassDict
=
{}
wdec
=
decorator
.
decorator
(
only_admin
)
wdec
=
decorator
.
decorator
(
only_admin
)
for
attributeName
,
attribute
in
bases
[
0
].
__dict__
.
items
():
for
attributeName
,
attribute
in
bases
[
0
].
__dict__
.
items
():
if
isinstance
(
attribute
,
FunctionType
)
and
not
attributeName
.
startswith
(
'
_
'
):
if
isinstance
(
attribute
,
FunctionType
)
and
not
attributeName
.
startswith
(
'
_
'
):
print
(
attribute
)
attribute
=
wdec
(
attribute
)
attribute
=
wdec
(
attribute
)
newClassDict
[
attributeName
]
=
attribute
newClassDict
[
attributeName
]
=
attribute
return
type
.
__new__
(
meta
,
classname
,
bases
,
newClassDict
)
return
type
.
__new__
(
meta
,
classname
,
bases
,
newClassDict
)
class
OdshHarvestController
(
HarvestController
):
class
OdshHarvestController
(
HarvestController
):
__metaclass__
=
MetaClass
# wrap all the methods
__metaclass__
=
MetaClass
# wrap all the methods
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
2
−
5
View file @
897bc6ed
...
@@ -206,14 +206,11 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
...
@@ -206,14 +206,11 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshFeedController
'
)
as
m
:
m
.
connect
(
'
/feeds/custom.atom
'
,
action
=
'
custom
'
)
m
.
connect
(
'
/feeds/custom.atom
'
,
action
=
'
custom
'
)
# with SubMapper(map, controller='ckanext.odsh.controller:OdshHarvestController') as m:
# m.connect('/harvest', action='index')
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshPackageController
'
)
as
m
:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshPackageController
'
)
as
m
:
m
.
connect
(
'
new_view
'
,
'
/dataset/{id}/resource/{resource_id}/new_view
'
,
action
=
'
edit_view
'
,
ckan_icon
=
'
pencil-square-o
'
)
m
.
connect
(
'
new_view
'
,
'
/dataset/{id}/resource/{resource_id}/new_view
'
,
action
=
'
edit_view
'
,
ckan_icon
=
'
pencil-square-o
'
)
#
with SubMapper(map, controller='ckanext.odsh.controller:OdshGroupController') as m:
with
SubMapper
(
map
,
controller
=
'
ckanext.odsh.controller:OdshGroupController
'
)
as
m
:
#
m.connect('organizations_index', '/organization', action='index')
m
.
connect
(
'
organizations_index
'
,
'
/organization
'
,
action
=
'
index
'
)
# 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
:
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/validation.py
+
0
−
1
View file @
897bc6ed
...
@@ -104,7 +104,6 @@ def validate_licenseAttributionByText(key, data, errors,context):
...
@@ -104,7 +104,6 @@ def validate_licenseAttributionByText(key, data, errors,context):
isByLicense
=
True
isByLicense
=
True
break
break
hasAttribution
=
False
hasAttribution
=
False
print
(
Missing
)
for
k
in
data
:
for
k
in
data
:
if
data
[
k
]
==
'
licenseAttributionByText
'
:
if
data
[
k
]
==
'
licenseAttributionByText
'
:
if
isinstance
(
data
[(
k
[
0
],
k
[
1
],
'
value
'
)],
Missing
)
or
(
k
[
0
],
k
[
1
],
'
value
'
)
not
in
data
:
if
isinstance
(
data
[(
k
[
0
],
k
[
1
],
'
value
'
)],
Missing
)
or
(
k
[
0
],
k
[
1
],
'
value
'
)
not
in
data
:
...
...
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