summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-03-14 22:06:05 +0100
committerLeif Johansson <leifj@sunet.se>2011-03-14 22:06:05 +0100
commit6c14fdb4f3c21ab474d8cc3a7dbaefadfadd8454 (patch)
treed1c7a6f2522d476bd19808bed6b47381720bab53 /src
parentf1d504e7ff495b2ab6d41ba061f8ab0256765f4d (diff)
try to avoid duplicates
Diffstat (limited to 'src')
-rw-r--r--src/meetingtools/apps/room/views.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py
index 85b44e2..b423d42 100644
--- a/src/meetingtools/apps/room/views.py
+++ b/src/meetingtools/apps/room/views.py
@@ -19,6 +19,7 @@ import time
from meetingtools.settings import GRACE
from django.utils.datetime_safe import datetime
from django.http import HttpResponseRedirect
+from django.core.exceptions import ObjectDoesNotExist
def _acc_for_user(user):
(local,domain) = user.username.split('@')
@@ -171,10 +172,12 @@ def update(request,id=None):
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)
-
+ try:
+ room = Room.objects.get(sco_id=sco_id,acc=acc)
+ except ObjectDoesNotExist:
+ room = Room.objects.create(sco_id=sco_id,acc=acc,creator=request.user,folder_sco_id=folder_sco_id)
+
logging.debug(pformat(room))
- logging.debug(room.id)
if room.name != name and name:
room.name = name
@@ -202,7 +205,7 @@ def _import_room(request,acc,sco_id,source_sco_id,folder_sco_id,name,urlpath):
logging.debug(pformat(room))
if modified:
- logging.debug(room.id)
+ logging.debug("saving ... %s" % pformat(room))
room.save()
return room