Skip to content

Commit

Permalink
add stats and make homepage_style config option
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Sep 5, 2013
1 parent 6b1b6f0 commit bf28f1a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
5 changes: 5 additions & 0 deletions ckan/controllers/admin.py
Expand Up @@ -31,6 +31,10 @@ def _get_config_form_items(self):
{'text': 'Green', 'value': '/base/css/green.css'},
{'text': 'Maroon', 'value': '/base/css/maroon.css'},
{'text': 'Fuchsia', 'value': '/base/css/fuchsia.css'}]

homepages = [{'value': '1', 'text': 'Introductory area, search, featured group and featured organization'},
{'value': '2', 'text': 'Search, featured dataset, stats and featured organization'}]

items = [
{'name': 'ckan.site_title', 'control': 'input', 'label': _('Site Title'), 'placeholder': ''},
{'name': 'ckan.main_css', 'control': 'select', 'options': styles, 'label': _('Style'), 'placeholder': ''},
Expand All @@ -39,6 +43,7 @@ def _get_config_form_items(self):
{'name': 'ckan.site_about', 'control': 'markdown', 'label': _('About'), 'placeholder': _('About page text')},
{'name': 'ckan.site_intro_text', 'control': 'markdown', 'label': _('Intro Text'), 'placeholder': _('Text on home page')},
{'name': 'ckan.site_custom_css', 'control': 'textarea', 'label': _('Custom CSS'), 'placeholder': _('Customisable css inserted into the page header')},
{'name': 'ckan.homepage_style', 'control': 'select', 'options': homepages, 'label': _('Homepage'), 'placeholder': ''},
]
return items

Expand Down
1 change: 1 addition & 0 deletions ckan/lib/app_globals.py
Expand Up @@ -46,6 +46,7 @@
'ckan.dumps_format': {},
'ckan.api_url': {},
'ofs.impl': {'name': 'ofs_impl'},
'ckan.homepage_style': {'default': '1'},

# split string
'search.facets': {'default': 'organization groups tags res_format license_id',
Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/admin/config.html
Expand Up @@ -41,6 +41,8 @@ <h2 class="module-heading">
<code>&lt;head&gt;</code> tag of every page. If you wish to customize
the templates more fully we recommend
<a href="{{ docs_url }}" target="_blank">reading the documentation</a>.</p>
<p><strong>Homepage:</strong> This is for choosing a predefined layout for
the modules that appear on your homepage.</p>
{% endtrans %}
{% endblock %}
</div>
Expand Down
15 changes: 15 additions & 0 deletions ckanext/homepage/plugin.py
@@ -1,6 +1,7 @@
import logging

import ckan.plugins as p
import ckan.model as model

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,8 +73,22 @@ def get_group(id):

return groups_data

def get_site_statistics(self):
stats = {}
stats['dataset_count'] = p.toolkit.get_action('package_search')({}, {"rows": 1})['count']
stats['group_count'] = len(p.toolkit.get_action('group_list')({}, {}))
stats['organization_count'] = len(p.toolkit.get_action('organization_list')({}, {}))
result =model.Session.execute(
'''select count(*) from related r
left join related_dataset rd on r.id = rd.related_id
where rd.status = 'active' or rd.id is null''').first()[0]
stats['related_count'] = len(p.toolkit.get_action('organization_list')({}, {}))

return stats

def get_helpers(self):
return {
'get_featured_organizations': self.get_featured_organizations,
'get_featured_groups': self.get_featured_groups,
'get_site_statistics': self.get_site_statistics,
}
19 changes: 0 additions & 19 deletions ckanext/homepage/theme/templates/admin/config.html

This file was deleted.

0 comments on commit bf28f1a

Please sign in to comment.