From 3ed510b2da164e566fc2c23eee84a495f6800cb3 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Thu, 19 Jul 2012 19:48:39 +0200 Subject: [PATCH] Refactor DefaultGroupForm's form_to_db_schema_options() The form_to_db_schema() methods of IGroupForm plugins were not being called if those plugins inherited from DefaultGroupForm. Refactor it in the same way as DefaultDatasetForm's form_to_db_schema_options() method was recently refactored. Make it call self.form_to_db_schema so that the form_to_db_schema() methods of IGroupForm extensions get called. Also make it call new form_to_db_schema_api_create() and form_to_db_schema_api_update() methods which could potentially be overridden by extensions also. --- ckan/lib/plugins.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ckan/lib/plugins.py b/ckan/lib/plugins.py index 2fccd93ec03..20910fb6aeb 100644 --- a/ckan/lib/plugins.py +++ b/ckan/lib/plugins.py @@ -349,9 +349,6 @@ def history_template(self): def group_form(self): return 'group/new_group_form.html' - def form_to_db_schema(self): - return logic.schema.group_form_schema() - def form_to_db_schema_options(self, options): ''' This allows us to select different schemas for different purpose eg via the web interface or via the api or creation vs @@ -366,11 +363,20 @@ def form_to_db_schema_options(self, options): if options.get('api'): if options.get('type') == 'create': - return logic.schema.default_group_schema() + return self.form_to_db_schema_api_create() else: - return logic.schema.default_update_group_schema() + return self.form_to_db_schema_api_update() else: - return logic.schema.group_form_schema() + return self.form_to_db_schema() + + def form_to_db_schema_api_create(self): + return logic.schema.default_group_schema() + + def form_to_db_schema_api_update(self): + return logic.schema.default_update_group_schema() + + def form_to_db_schema(self): + return logic.schema.group_form_schema() def db_to_form_schema(self): '''This is an interface to manipulate data from the database