Skip to content

Commit

Permalink
Refactor DefaultGroupForm's form_to_db_schema_options()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sean Hammond committed Aug 1, 2012
1 parent 6a48063 commit 3ed510b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ckan/lib/plugins.py
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3ed510b

Please sign in to comment.