Commit 31895980 authored by thepaeth's avatar thepaeth
Browse files

update logic action

parent 15706ace
......@@ -3,6 +3,7 @@ import logging
import ckan.plugins as p
import ckan.logic as logic
from ckanext.hierarchy.model import GroupTreeNode
import ckan.model as model
log = logging.getLogger(__name__)
_get_or_bust = logic.get_or_bust
......@@ -60,6 +61,23 @@ def group_tree_section(context, data_dict):
group.get_parent_group_hierarchy(type=group_type),
section_subtree)
def _group_user(group_id):
group = model.Group.get(group_id)
q = model.Session.query(model.Member).\
filter(model.Member.group_id == group.id).\
filter(model.Member.state == "active").\
filter(model.Member.table_name == 'user')
def user_displayname(user_id):
try:
user = model.User.get(user_id)
return user.display_name
except:
return user_id
return [(m.table_id, user_displayname(m.table_id), m.capacity)
for m in q.all()]
def _nest_group_tree_list(group_tree_list, group_tree_leaf):
'''Returns a tree branch composed by nesting the groups in the list.
......@@ -73,7 +91,8 @@ def _nest_group_tree_list(group_tree_list, group_tree_leaf):
node = GroupTreeNode(
{'id': group.id,
'name': group.name,
'title': group.title})
'title': group.title,
'users': _group_user(group.id)})
if not root_node:
root_node = last_node = node
else:
......@@ -94,7 +113,8 @@ def _group_tree_branch(root_group, highlight_group_name=None, type='group'):
root_node = nodes[root_group.id] = GroupTreeNode(
{'id': root_group.id,
'name': root_group.name,
'title': root_group.title})
'title': root_group.title,
'users': _group_user(root_group.id)})
if root_group.name == highlight_group_name:
nodes[root_group.id].highlight()
highlight_group_name = None
......@@ -102,7 +122,8 @@ def _group_tree_branch(root_group, highlight_group_name=None, type='group'):
root_group.get_children_group_hierarchy(type=type):
node = GroupTreeNode({'id': group_id,
'name': group_name,
'title': group_title})
'title': group_title,
'users': _group_user(group_id)})
nodes[parent_id].add_child_node(node)
if highlight_group_name and group_name == highlight_group_name:
node.highlight()
......
......@@ -12,13 +12,13 @@
{% endfor %}
<li>{% link_for organization|truncate(30), controller='organization', action='read', id=pkg.organization.name %}</li>
{% else %}
<li>{% link_for _('Datasets'), controller='package', action='search' %}</li>
<li>{% link_for _('Datasets'), controller='dataset' if h.ckan_version().split('.')[1] | int >= 9 else 'package', action='search' %}</li>
{% endif %}
<li{{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), controller='package', action='read', id=pkg.name %}</li>
<li{{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), controller='dataset' if h.ckan_version().split('.')[1] | int >= 9 else 'package', action='read', id=pkg.name %}</li>
{% else %}
<li>{% link_for _('Datasets'), controller='dataset' if h.ckan_version() > '2.9' else 'package', action='search' %}</li>
<li>{% link_for _('Datasets'), controller='dataset' if h.ckan_version().split('.')[1] | int >= 9 else 'package', action='search' %}</li>
<li class="active"><a href="">{{ _('Create Dataset') }}</a></li>
{% endif %}
{% endblock %}
{% endblock %}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment