Skip to content

Commit

Permalink
Merge branch '1281-default-organization-form' of git://github.com/war…
Browse files Browse the repository at this point in the history
…di/ckan into wardi-1281-default-organization-form
  • Loading branch information
amercader committed Oct 29, 2013
2 parents e4fc2fa + 05c27ce commit 6a779f3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
7 changes: 6 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -344,6 +344,9 @@ def pager_url(q=None, page=None):
c.facets = {}
c.page = h.Page(collection=[])

self._setup_template_variables(context, {'id':id},
group_type=group_type)

def bulk_process(self, id):
''' Allow bulk processing of datasets for an organization. Make
private/public or delete. For organization admins.'''
Expand Down Expand Up @@ -828,7 +831,9 @@ def admins(self, id):

def about(self, id):
c.group_dict = self._get_group_dict(id)
return render(self._about_template(c.group_dict['type']))
group_type = c.group_dict['type']
self._setup_template_variables({}, {'id': id}, group_type=group_type)
return render(self._about_template(group_type))

def _get_group_dict(self, id):
''' returns the result of group_show action or aborts if there is a
Expand Down
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 6a779f3

Please sign in to comment.