[ckan-changes] [okfn/ckan] 8c4715: Merge branch 'master' of https://github.com/okfn/c...

GitHub noreply at github.com
Tue May 1 13:25:50 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: 8c4715c4b37da8a71a24319e353c29ce97a657b2
      https://github.com/okfn/ckan/commit/8c4715c4b37da8a71a24319e353c29ce97a657b2
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-05-01 (Tue, 01 May 2012)

  Changed paths:
    A ckanext/multilingual/__init__.py

  Log Message:
  -----------
  Merge branch 'master' of https://github.com/okfn/ckan


diff --git a/ckanext/multilingual/__init__.py b/ckanext/multilingual/__init__.py
new file mode 100644
index 0000000..e69de29


================================================================
  Commit: ea19469809efa739d9c8bce21bc7dec8df4ea9ab
      https://github.com/okfn/ckan/commit/ea19469809efa739d9c8bce21bc7dec8df4ea9ab
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-05-01 (Tue, 01 May 2012)

  Changed paths:
    M ckan/controllers/group.py
    M ckan/controllers/home.py
    M ckan/lib/dictization/model_dictize.py
    M ckan/logic/action/get.py
    M ckan/model/group.py

  Log Message:
  -----------
  Fix counts that are including private datasets


diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py
index 95a4597..30e4825 100644
--- a/ckan/controllers/group.py
+++ b/ckan/controllers/group.py
@@ -72,7 +72,8 @@ def index(self):
         group_type = self._guess_group_type()
 
         context = {'model': model, 'session': model.Session,
-                   'user': c.user or c.author, 'for_view': True}
+                   'user': c.user or c.author, 'for_view': True,
+                   'with_private': False}
 
         data_dict = {'all_fields': True}
 
diff --git a/ckan/controllers/home.py b/ckan/controllers/home.py
index a675826..cfa139c 100644
--- a/ckan/controllers/home.py
+++ b/ckan/controllers/home.py
@@ -31,7 +31,7 @@ def __before__(self, action, **env):
                 # TODO: send an email to the admin person (#1285)
             else:
                 raise
-            
+
 
     def index(self):
         try:
@@ -43,6 +43,7 @@ def index(self):
                 'facet.field':g.facets,
                 'rows':0,
                 'start':0,
+                'fq': 'capacity:"public"'
             }
             query = ckan.logic.get_action('package_search')(context,data_dict)
             c.package_count = query['count']
diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_dictize.py
index 75fe85e..74aa8b7 100644
--- a/ckan/lib/dictization/model_dictize.py
+++ b/ckan/lib/dictization/model_dictize.py
@@ -15,7 +15,7 @@ def group_list_dictize(obj_list, context,
                        sort_key=lambda x:x['display_name'], reverse=False):
 
     active = context.get('active', True)
-
+    with_private = context.get('include_private_packages', False)
     result_list = []
 
     for obj in obj_list:
@@ -30,7 +30,8 @@ def group_list_dictize(obj_list, context,
 
         group_dict['display_name'] = obj.display_name
 
-        group_dict['packages'] = len(obj.active_packages().all())
+        group_dict['packages'] = \
+                len(obj.active_packages(with_private=with_private).all())
 
         if context.get('for_view'):
             for item in plugins.PluginImplementations(
diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py
index fd0ce25..b2afe94 100644
--- a/ckan/logic/action/get.py
+++ b/ckan/logic/action/get.py
@@ -491,9 +491,9 @@ def resource_status_show(context, data_dict):
     check_access('resource_status_show', context, data_dict)
 
     # needs to be text query as celery tables are not in our model
-    q = text("""select status, date_done, traceback, task_status.* 
-                from task_status left join celery_taskmeta 
-                on task_status.value = celery_taskmeta.task_id and key = 'celery_task_id' 
+    q = text("""select status, date_done, traceback, task_status.*
+                from task_status left join celery_taskmeta
+                on task_status.value = celery_taskmeta.task_id and key = 'celery_task_id'
                 where entity_id = :entity_id """)
 
     result = model.Session.connection().execute(q, entity_id=id)
diff --git a/ckan/model/group.py b/ckan/model/group.py
index f622a7a..de2e4cd 100644
--- a/ckan/model/group.py
+++ b/ckan/model/group.py
@@ -166,13 +166,18 @@ def get_children_groups(self, type='group'):
                 from_statement(HIERARCHY_CTE).params(id=self.id, type=type).all()
         return [ { "id":idf, "name": name, "title": title } for idf,name,title in results ]
 
-    def active_packages(self, load_eager=True):
+    def active_packages(self, load_eager=True, with_private=False):
         query = Session.query(Package).\
                filter_by(state=vdm.sqlalchemy.State.ACTIVE).\
                filter(group_table.c.id == self.id).\
-               filter(member_table.c.state == 'active').\
-               join(member_table, member_table.c.table_id == Package.id).\
+               filter(member_table.c.state == 'active')
+
+        if not with_private:
+               query = query.filter(member_table.c.capacity == 'public')
+
+        query = query.join(member_table, member_table.c.table_id == Package.id).\
                join(group_table, group_table.c.id == member_table.c.group_id)
+
         return query
 
     @classmethod


================================================================
Compare: https://github.com/okfn/ckan/compare/5638aed...ea19469


More information about the ckan-changes mailing list