From 8bff940ea8e3d4214841856dde7e2f9c72d0d2f4 Mon Sep 17 00:00:00 2001 From: Alessio Fabrizio Date: Tue, 8 Oct 2024 10:55:11 +0200 Subject: [PATCH] add custom datatype deliverable --- ckanext/d4science/plugin.py | 33 +++++++++++++++++++++++++++++++++ setup.py | 14 ++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ckanext/d4science/plugin.py b/ckanext/d4science/plugin.py index 06eb5a5..1d886d8 100644 --- a/ckanext/d4science/plugin.py +++ b/ckanext/d4science/plugin.py @@ -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): diff --git a/setup.py b/setup.py index 4d26df7..7eda550 100644 --- a/setup.py +++ b/setup.py @@ -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), ], - } + }, ) +