diff options
author | Leif Johansson <leifj@sunet.se> | 2011-06-13 15:35:18 +0200 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2011-06-13 15:35:27 +0200 |
commit | 324a47f0455931a4b405385e2679ae267517914f (patch) | |
tree | e8df14abc3af5c1d740ca3d415202a3243334903 /src/meetingtools/apps | |
parent | 803ce0671b6a197235679d5874179522f267aac8 (diff) |
call _import_room at each tag view
Diffstat (limited to 'src/meetingtools/apps')
-rw-r--r-- | src/meetingtools/apps/room/views.py | 16 |
1 files changed, 13 insertions, 3 deletions
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', |