add custom datatype deliverable

This commit is contained in:
Alessio Fabrizio 2024-10-08 10:55:11 +02:00
parent ba8aab7c11
commit 8bff940ea8
2 changed files with 45 additions and 2 deletions

View File

@ -4,6 +4,7 @@ from ckan.views.resource import Blueprint
from ckanext.d4science import helpers
from ckanext.d4science.logic import action, auth
from ckanext.d4science.logic import validators
from ckan.model import Package
# import ckanext.d4science.cli as cli
@ -22,6 +23,7 @@ class D4SciencePlugin(plugins.SingletonPlugin):
# plugins.implements(plugins.IClick)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IValidators)
plugins.implements(plugins.IDatasetForm)
#ckan 2.10
plugins.implements(plugins.IBlueprint)
@ -45,6 +47,37 @@ class D4SciencePlugin(plugins.SingletonPlugin):
def get_actions(self):
return action.get_actions()
#IDataSetForm for custom datatype and dataset
def package_types(self):
# Aggiunta del tipo di dato personalizzato deliverable
return ['deliverable_type']
def is_fallback(self):
# Indica che questo plugin può essere usato come fallback se un tipo specifico non è specificato
return False
def create_package_schema(self):
schema = super(D4SciencePlugin, self).create_package_schema()
schema.update({
'deliverable_type': [ignore_missing, unicode],
})
return schema
def update_package_schema(self):
schema = super(D4SciencePlugin, self).update_package_schema()
schema.update({
'deliverable_type': [ignore_missing, unicode],
})
return schema
def show_package_schema(self):
schema = super(D4SciencePlugin, self).show_package_schema()
schema.update({
'deliverable_type': [ignore_missing, unicode],
})
return schema
# IBlueprint
# def get_blueprint(self):

View File

@ -1,7 +1,16 @@
# -*- coding: utf-8 -*-
from setuptools import setup
from setuptools import setup, find_packages
setup(
name='d4_science_plugin',
version='0.0.1',
description='custom theme and dataset type for D4Science',
packages=find_packages(),
install_requires=[],
entry_points='''
[ckan.plugins]
d4_science_plugin = d4_science_plugin.plugin:D4SciencePlugin
''',
# If you are changing from the default layout of your extension, you may
# have to change the message extractors, you can read more about babel
# message extraction at
@ -12,5 +21,6 @@ setup(
('**.js', 'javascript', None),
('**/templates/**.html', 'ckan', None),
],
}
},
)