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
404ddfde
Commit
404ddfde
authored
5 years ago
by
Benjamin Becker
Browse files
Options
Downloads
Patches
Plain Diff
uses context=None
parent
b2b35296
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/pdf_to_thumbnail/plugin.py
+2
-2
2 additions, 2 deletions
ckanext/odsh/pdf_to_thumbnail/plugin.py
ckanext/odsh/pdf_to_thumbnail/thumbnail.py
+9
-11
9 additions, 11 deletions
ckanext/odsh/pdf_to_thumbnail/thumbnail.py
with
11 additions
and
13 deletions
ckanext/odsh/pdf_to_thumbnail/plugin.py
+
2
−
2
View file @
404ddfde
...
@@ -21,11 +21,11 @@ class ThumbnailPlugin(plugins.SingletonPlugin):
...
@@ -21,11 +21,11 @@ class ThumbnailPlugin(plugins.SingletonPlugin):
#IResourceController
#IResourceController
def
after_create
(
self
,
context
,
resource
):
def
after_create
(
self
,
context
,
resource
):
resources
=
thumbnail
.
resources_of_containing_package
(
context
,
resource
)
resources
=
thumbnail
.
resources_of_containing_package
(
resource
)
thumbnail
.
create_thumbnail_if_none_in_package
(
context
,
resources
)
thumbnail
.
create_thumbnail_if_none_in_package
(
context
,
resources
)
def
after_update
(
self
,
context
,
resource
):
def
after_update
(
self
,
context
,
resource
):
resources
=
thumbnail
.
resources_of_containing_package
(
context
,
resource
)
resources
=
thumbnail
.
resources_of_containing_package
(
resource
)
thumbnail
.
create_thumbnail_if_none_in_package
(
context
,
resources
)
thumbnail
.
create_thumbnail_if_none_in_package
(
context
,
resources
)
def
after_delete
(
self
,
context
,
resources
):
def
after_delete
(
self
,
context
,
resources
):
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/pdf_to_thumbnail/thumbnail.py
+
9
−
11
View file @
404ddfde
...
@@ -33,7 +33,7 @@ def create_thumbnail(context, resource):
...
@@ -33,7 +33,7 @@ def create_thumbnail(context, resource):
def
_get_filename_from_context
(
context
):
def
_get_filename_from_context
(
context
):
package
=
context
.
get
(
'
package
'
)
package
=
context
.
get
(
'
package
'
)
package_id
=
package
.
id
package_id
=
package
.
id
package
=
toolkit
.
get_action
(
'
package_show
'
)(
c
on
text
,
{
'
id
'
:
package_id
})
package
=
toolkit
.
get_action
(
'
package_show
'
)(
N
on
e
,
{
'
id
'
:
package_id
})
thumbnail
=
package
.
get
(
'
thumbnail
'
)
thumbnail
=
package
.
get
(
'
thumbnail
'
)
return
thumbnail
return
thumbnail
...
@@ -116,13 +116,13 @@ def remove_thumbnail(context):
...
@@ -116,13 +116,13 @@ def remove_thumbnail(context):
ThumbnailPath
.
from_filename_with_extension
(
old_filename
).
remove
()
ThumbnailPath
.
from_filename_with_extension
(
old_filename
).
remove
()
def
resources_of_containing_package
(
resource
,
context
):
def
resources_of_containing_package
(
resource
):
#todo: change arg order
#todo: change arg order
'''
'''
used by pdf_to_thumbnail.plugin
used by pdf_to_thumbnail.plugin
'''
'''
package_id
=
resource
.
get
(
'
package
'
).
id
package_id
=
resource
.
get
(
'
package
_id
'
)
package
=
toolkit
.
get_action
(
'
package_show
'
)(
c
on
text
,
{
'
id
'
:
package_id
})
package
=
toolkit
.
get_action
(
'
package_show
'
)(
N
on
e
,
{
'
id
'
:
package_id
})
resources
=
package
.
get
(
'
resources
'
)
resources
=
package
.
get
(
'
resources
'
)
return
resources
return
resources
...
@@ -140,8 +140,8 @@ def create_thumbnail_if_none_in_package(context, resources):
...
@@ -140,8 +140,8 @@ def create_thumbnail_if_none_in_package(context, resources):
def
_get_package_dict_from_context
(
context
):
def
_get_package_dict_from_context
(
context
):
package
=
context
.
get
(
'
package
'
)
package
_id
=
context
.
get
(
'
package
'
)
.
as_dict
().
get
(
'
id
'
)
package_dict
=
toolkit
.
get_action
(
'
package_show
'
)(
c
on
text
,
{
'
id
'
:
package
.
id
})
package_dict
=
toolkit
.
get_action
(
'
package_show
'
)(
N
on
e
,
{
'
id
'
:
package
_
id
})
return
package_dict
return
package_dict
...
@@ -159,12 +159,10 @@ def _try_create_thumbnail(context, resource):
...
@@ -159,12 +159,10 @@ def _try_create_thumbnail(context, resource):
def
_write_thumbnail_into_package
(
context
,
filename
):
def
_write_thumbnail_into_package
(
context
,
filename
):
package
=
context
.
get
(
'
package
'
)
package_dict
=
_get_package_dict_from_context
(
context
)
package_id
=
package
.
id
package
=
toolkit
.
get_action
(
'
package_show
'
)(
context
,
{
'
id
'
:
package_id
})
if
filename
:
if
filename
:
package
.
update
({
'
thumbnail
'
:
filename
})
package
_dict
.
update
({
'
thumbnail
'
:
filename
})
toolkit
.
get_action
(
'
package_update
'
)(
c
on
text
,
package
)
toolkit
.
get_action
(
'
package_update
'
)(
N
on
e
,
package
_dict
)
class
ThumbnailPath
(
object
):
class
ThumbnailPath
(
object
):
...
...
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