Skip to content

Commit

Permalink
[bug] For new/search/index determine the group/package type from the url
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Mar 15, 2012
1 parent 0c07d3b commit 9491210
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 9 additions & 10 deletions ckan/controllers/group.py
Expand Up @@ -36,17 +36,13 @@ def _db_to_form_schema(self, group_type=None):
def _setup_template_variables(self, context, data_dict, group_type=None):
return lookup_group_plugin(group_type).setup_template_variables(context,data_dict)

def _new_template(self):
def _new_template(self,group_type):
from ckan.lib.helpers import default_group_type
return lookup_group_plugin(default_group_type()).new_template()
return lookup_group_plugin(group_type).new_template()

def _index_template(self):
def _index_template(self,group_type):
from ckan.lib.helpers import default_group_type
return lookup_group_plugin(default_group_type()).index_template()

def _search_template(self):
from ckan.lib.helpers import default_group_type
return lookup_group_plugin(default_group_type()).search_template()
return lookup_group_plugin(group_type).index_template()

def _read_template(self, group_type):
return lookup_group_plugin(group_type).read_template()
Expand All @@ -57,6 +53,9 @@ def _history_template(self, group_type):
## end hooks

def index(self):
group_type = request.path.strip('/').split('/')[0]
if group_type == 'group':
group_type = None

context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
Expand All @@ -76,7 +75,7 @@ def index(self):
url=h.pager_url,
items_per_page=20
)
return render( self._index_template() )
return render( self._index_template(group_type) )


def read(self, id):
Expand Down Expand Up @@ -216,7 +215,7 @@ def new(self, data=None, errors=None, error_summary=None):

self._setup_template_variables(context,data)
c.form = render(self._group_form(group_type=group_type), extra_vars=vars)
return render(self._new_template())
return render(self._new_template(group_type))

def edit(self, id, data=None, errors=None, error_summary=None):
group_type = self._get_group_type(id.split('@')[0])
Expand Down
7 changes: 6 additions & 1 deletion ckan/controllers/package.py
Expand Up @@ -83,6 +83,11 @@ def _history_template(self, package_type):

def search(self):
from ckan.lib.search import SearchError

package_type = request.path.strip('/').split('/')[0]
if package_type == 'group':
package_type = None

try:
context = {'model':model,'user': c.user or c.author}
check_access('site_read',context)
Expand Down Expand Up @@ -161,7 +166,7 @@ def pager_url(q=None, page=None):
c.facets = {}
c.page = h.Page(collection=[])

return render( self._search_template('') )
return render( self._search_template(package_type) )


def read(self, id):
Expand Down

0 comments on commit 9491210

Please sign in to comment.