Skip to content

Commit

Permalink
reformat /ckan/ckan/controllers/home.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jbspeakr authored and tobes committed Apr 11, 2013
1 parent a591c7d commit 1f2cbba
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions ckan/controllers/home.py
Expand Up @@ -14,6 +14,7 @@
# horrible hack
dirty_cached_group_stuff = None


class HomeController(base.BaseController):
repo = model.repo

Expand All @@ -32,7 +33,7 @@ def __before__(self, action, **env):
('no such table' in msg):
# table missing, major database problem
base.abort(503, _('This site is currently off-line. Database '
'is not initialised.'))
'is not initialised.'))
# TODO: send an email to the admin person (#1285)
else:
raise
Expand All @@ -58,24 +59,27 @@ def index(self):

c.facets = query['facets']
maintain.deprecate_context_item(
'facets',
'Use `c.search_facets` instead.')
'facets',
'Use `c.search_facets` instead.')

c.search_facets = query['search_facets']

c.facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('Licence'), }
c.facet_titles = {
'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('Licence'),
}

data_dict = {'sort': 'packages', 'all_fields': 1}
# only give the terms to group dictize that are returned in the
# facets as full results take a lot longer
if 'groups' in c.search_facets:
data_dict['groups'] = [ item['name'] for item in
c.search_facets['groups']['items'] ]
data_dict['groups'] = [
item['name'] for item in c.search_facets['groups']['items']
]
c.groups = logic.get_action('group_list')(context, data_dict)
except search.SearchError, se:
except search.SearchError:
c.package_count = 0
c.groups = []

Expand All @@ -90,8 +94,8 @@ def index(self):
msg = _(u'Please <a href="{link}">update your profile</a>'
u' and add your email address and your full name. '
u'{site} uses your email address'
u' if you need to reset your password.'.format(link=url,
site=g.site_title))
u' if you need to reset your password.'.format(
link=url, site=g.site_title))
elif not c.userobj.email:
msg = _('Please <a href="%s">update your profile</a>'
' and add your email address. ') % url + \
Expand Down Expand Up @@ -134,7 +138,7 @@ def db_to_form_schema(group_type=None):
except logic.NotFound:
return None

return {'group_dict' :group_dict}
return {'group_dict': group_dict}

global dirty_cached_group_stuff
if not dirty_cached_group_stuff:
Expand All @@ -160,14 +164,14 @@ def db_to_form_schema(group_type=None):
# We get all the packages or at least too many so
# limit it to just 2
for group in groups_data:
group['group_dict']['packages'] = group['group_dict']['packages'][:2]
group['group_dict']['packages'] = \
group['group_dict']['packages'][:2]
#now add blanks so we have two
while len(groups_data) < 2:
groups_data.append({'group_dict' :{}})
groups_data.append({'group_dict': {}})
# cache for later use
dirty_cached_group_stuff = groups_data


c.group_package_stuff = dirty_cached_group_stuff

# END OF DIRTYNESS
Expand Down

0 comments on commit 1f2cbba

Please sign in to comment.