From 7532175aa361b5c8e6c9f28e82acfa705f325aee Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Mon, 4 Mar 2013 06:57:42 +0100 Subject: handle differences between report-bulk-objects and sco-contents --- meetingtools/apps/room/tasks.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'meetingtools') diff --git a/meetingtools/apps/room/tasks.py b/meetingtools/apps/room/tasks.py index ecf6ee3..92d1cc7 100644 --- a/meetingtools/apps/room/tasks.py +++ b/meetingtools/apps/room/tasks.py @@ -96,15 +96,23 @@ def _import_one_room(acc,api,row): #logging.debug("last %s" % last) #logging.debug("lastupdated %s" % lastupdated) if not room or lastupdated < last: - (r,username) = _extended_info(api, acc, sco_id) + (r, username) = _extended_info(api, acc, sco_id) logging.debug("found room owned by %s. Time for an update" % username) if username is None: logging.warning("username not found for sco-id=%s while importing" % sco_id) return + def _ft(t,*exprs): + for e in exprs: + v = t.findtext(exprs) + if v is not None: + return v + return None + logging.debug(etree.tostring(row)) logging.debug(etree.tostring(r)) - urlpath = row.findtext("url[0]").strip("/") + urlpath = _ft(row, "url[0]", "url-path[0]").strip("/") + name = row.findtext('name[0]') description = row.findtext('description[0]') date_created = None @@ -130,7 +138,7 @@ def _import_one_room(acc,api,row): if room is None: if folder_sco_id: - user,created = User.objects.get_or_create(username=username) + user, created = User.objects.get_or_create(username=username) if created: user.set_unusable_password() room = Room.objects.create(sco=get_sco(acc,sco_id), -- cgit v1.1