Skip to content

Commit

Permalink
[#2939] Get user id helper added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 2, 2012
1 parent 7328414 commit 3c3ce44
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ckan/logic/action/get.py
Expand Up @@ -4,6 +4,7 @@

from pylons import config
from pylons.i18n import _
from pylons import c
import sqlalchemy

import ckan.authz
Expand Down Expand Up @@ -48,6 +49,13 @@ def _package_list_with_resources(context, package_revision_list):
package_list.append(result_dict)
return package_list

def _get_user_id_for_username(user_name):
''' Helper function toget user id '''
# FIXME needs completing
if c.userobj and c.userobj.name == user_name:
return c.userobj.id
raise Exception('Not logged in user')

def site_read(context,data_dict=None):
'''Return ``True``.
Expand Down Expand Up @@ -417,7 +425,7 @@ def organization_list_for_user(context, data_dict):

q = model.Session.query(model.Member) \
.filter(model.Member.table_name == 'user') \
.filter(model.Member.table_id == get_user_id_for_username(user))
.filter(model.Member.table_id == _get_user_id_for_username(user))
group_ids = []
for row in q.all():
group_ids.append(row.group_id)
Expand Down

0 comments on commit 3c3ce44

Please sign in to comment.