Skip to content

Commit

Permalink
[#1281] DefaultOrganizationForm instead of hard-coded values in contr…
Browse files Browse the repository at this point in the history
…oller
  • Loading branch information
wardi committed Oct 21, 2013
1 parent ace4ca9 commit 48f5eeb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 42 deletions.
41 changes: 0 additions & 41 deletions ckan/controllers/organization.py
Expand Up @@ -15,46 +15,5 @@ class OrganizationController(group.GroupController):
# this makes us use organization actions
group_type = 'organization'

def _group_form(self, group_type=None):
return 'organization/new_organization_form.html'

def _form_to_db_schema(self, group_type=None):
return group.lookup_group_plugin(group_type).form_to_db_schema()

def _db_to_form_schema(self, group_type=None):
'''This is an interface to manipulate data from the database
into a format suitable for the form (optional)'''
pass

def _setup_template_variables(self, context, data_dict, group_type=None):
pass

def _new_template(self, group_type):
return 'organization/new.html'

def _about_template(self, group_type):
return 'organization/about.html'

def _index_template(self, group_type):
return 'organization/index.html'

def _admins_template(self, group_type):
return 'organization/admins.html'

def _bulk_process_template(self, group_type):
return 'organization/bulk_process.html'

def _read_template(self, group_type):
return 'organization/read.html'

def _history_template(self, group_type):
return group.lookup_group_plugin(group_type).history_template()

def _edit_template(self, group_type):
return 'organization/edit.html'

def _activity_template(self, group_type):
return 'organization/activity_stream.html'

def _guess_group_type(self, expecting_name=False):
return 'organization'
39 changes: 38 additions & 1 deletion ckan/lib/plugins.py
Expand Up @@ -53,7 +53,8 @@ def lookup_group_plugin(group_type=None):
"""
if group_type is None:
return _default_group_plugin
return _group_plugins.get(group_type, _default_group_plugin)
return _group_plugins.get(group_type, _default_organization_plugin
if group_type == 'organization' else _default_group_plugin)


def register_package_plugins(map):
Expand Down Expand Up @@ -418,3 +419,39 @@ def setup_template_variables(self, context, data_dict):
c.auth_for_change_state = True
except logic.NotAuthorized:
c.auth_for_change_state = False


class DefaultOrganizationForm(DefaultGroupForm):
def group_form(self):
return 'organization/new_organization_form.html'

def setup_template_variables(self, context, data_dict):
pass

def new_template(self):
return 'organization/new.html'

def about_template(self):
return 'organization/about.html'

def index_template(self):
return 'organization/index.html'

def admins_template(self):
return 'organization/admins.html'

def bulk_process_template(self):
return 'organization/bulk_process.html'

def read_template(self):
return 'organization/read.html'

# don't override history_template - use group template for history

def edit_template(self):
return 'organization/edit.html'

def activity_template(self):
return 'organization/activity_stream.html'

_default_organization_plugin = DefaultOrganizationForm()

0 comments on commit 48f5eeb

Please sign in to comment.