From 324a47f0455931a4b405385e2679ae267517914f Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Mon, 13 Jun 2011 15:35:18 +0200 Subject: call _import_room at each tag view --- src/meetingtools/apps/room/views.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/meetingtools') diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py index 247568b..41254c6 100644 --- a/src/meetingtools/apps/room/views.py +++ b/src/meetingtools/apps/room/views.py @@ -239,16 +239,24 @@ def _import_room(request,acc,r): if not room: return None - logging.debug(pformat(room)) + api = ac_api_client(request,acc) + userlist = api.request('meeting-usermanager-user-list',{'sco-id': room.sco_id},False) + r['user_count'] = 0 + r['host_count'] = 0 + if userlist.status_code() == 'ok': + r['user_count'] = int(userlist.et.xpath("count(.//userdetails)")) + r['host_count'] = int(userlist.et.xpath("count(.//userdetails/role[text() = 'host'])")) + + #logging.debug(pformat(room)) - for key in ('sco_id','name','source_sco_id','urlpath','description'): + for key in ('sco_id','name','source_sco_id','urlpath','description','user_count','host_count'): if r.has_key(key) and hasattr(room,key): rv = getattr(room,key) if rv != r[key] and r[key]: setattr(room,key,r[key]) modified = True - logging.debug(pformat(room)) + #logging.debug(pformat(room)) if modified: logging.debug("saving ... %s" % pformat(room)) @@ -388,6 +396,8 @@ def _room2dict(room): def list_by_tag(request,tn): tags = tn.split('+') rooms = TaggedItem.objects.get_by_model(Room, tags).all() + for room in rooms: + _import_room(request,room.acc,{'sco_id': room.sco_id}) title = 'Rooms tagged with %s' % " and ".join(tags) return respond_to(request, {'text/html':'apps/room/list.html', -- cgit v1.1