diff options
author | Leif Johansson <leifj@sunet.se> | 2011-02-10 09:23:59 +0100 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2011-02-10 09:23:59 +0100 |
commit | fa2e40e9fcdb30c245b140a00ba6f05af7b786e6 (patch) | |
tree | 0569032455a747e3baef379cbbc0b2a1169c9387 /src/meetingtools/apps/room | |
parent | eaef5163d53e07151f0fa9dd752798cec041a0cd (diff) |
fix for create room bug
Diffstat (limited to 'src/meetingtools/apps/room')
-rw-r--r-- | src/meetingtools/apps/room/models.py | 2 | ||||
-rw-r--r-- | src/meetingtools/apps/room/views.py | 30 |
2 files changed, 22 insertions, 10 deletions
diff --git a/src/meetingtools/apps/room/models.py b/src/meetingtools/apps/room/models.py index 8167839..d69ee93 100644 --- a/src/meetingtools/apps/room/models.py +++ b/src/meetingtools/apps/room/models.py @@ -27,7 +27,7 @@ class Room(models.Model): lastvisited = models.DateTimeField(blank=True,null=True) def __unicode__(self): - return "%s (sco_id=%d,source_sco_id=%d)" % (self.name,self.sco_id,self.source_sco_id) + return "%s (sco_id=%s,source_sco_id=%s,folder_sco_id=%s,urlpath=%s)" % (self.name,self.sco_id,self.source_sco_id,self.folder_sco_id,self.urlpath) def lastvisit(self): if not self.lastvisited: diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py index 6ef3aa1..2921489 100644 --- a/src/meetingtools/apps/room/views.py +++ b/src/meetingtools/apps/room/views.py @@ -158,8 +158,8 @@ def update(request,id=None): form = UpdateRoomForm(request.POST,instance=room) _init_update_form(request, form, acc, room.folder_sco_id) if form.is_valid(): - room = form.save() room = _update_room(request, room) + room = form.save() return redirect_to("/rooms#%d" % room.id) else: form = UpdateRoomForm(instance=room) @@ -173,11 +173,14 @@ def _import_room(request,acc,sco_id,source_sco_id,folder_sco_id,name,urlpath): modified = False room,created = Room.objects.get_or_create(sco_id=sco_id,acc=acc,creator=request.user,folder_sco_id=folder_sco_id) - if room.name != name: + logging.debug(pformat(room)) + logging.debug(room.id) + + if room.name != name and name: room.name = name modified = True - if room.sco_id != sco_id: + if room.sco_id != sco_id and sco_id: room.sco_id = sco_id modified = True @@ -185,17 +188,25 @@ def _import_room(request,acc,sco_id,source_sco_id,folder_sco_id,name,urlpath): room.source_sco_id = source_sco_id modified = True - if room.urlpath != urlpath: - room.urlpath = urlpath.strip('/') - modified = True + if urlpath: + urlpath = urlpath.strip('/') - if '/' in room.urlpath: - room.urlpath = urlpath.strip('/') + if room.urlpath != urlpath and urlpath: + room.urlpath = urlpath modified = True + #if '/' in room.urlpath: + # room.urlpath = urlpath.strip('/') + # modified = True + + logging.debug(pformat(room)) + if modified: + logging.debug(room.id) room.save() + + return room @login_required @@ -206,6 +217,7 @@ def list(request): ar = [] for (sco_id,name,source_sco_id,urlpath) in user_rooms: + logging.debug("%s %s %s %s" % (sco_id,name,source_sco_id,urlpath)) room = _import_room(request,acc,sco_id,source_sco_id,my_meetings_sco_id,name,urlpath) ar.append(int(sco_id)) @@ -253,7 +265,7 @@ def goto(request,room): now = time.time() if room.self_cleaning: if (_nusers(session_info) == 0) and (abs(room.lastvisit() - now) > GRACE): - room = _clean(request,room) + room = _clean(request,room) room.lastvisited = datetime.now() room.save() |