diff --git a/import_padma.py b/import_padma.py index 93af787..eaf65a3 100755 --- a/import_padma.py +++ b/import_padma.py @@ -62,7 +62,7 @@ if longest_username > 255: print "import users" for u in users: - username = u['username'].strip().lower() + username = u['username'].strip() user, created = User.objects.get_or_create(username=username) user.email = u['email'] if not '@' in user.email: @@ -71,6 +71,8 @@ for u in users: user.date_joined = datetime.strptime(u['created'], '%Y-%m-%dT%H:%M:%SZ') user.save() profile = user.get_profile() + if not user.email: + profile.newsletter = False if 'admin' in u['groups']: profile.set_level('admin') else: @@ -118,7 +120,7 @@ def import_layers(item, layers): annotation = Annotation(item=item, layer=layer_name) annotation.start = float(layer['time_in'])/1000 annotation.end = float(layer['time_out'])/1000 - username = layer['creator'].strip().lower() + username = layer['creator'].strip() annotation.user = User.objects.get(username=username) annotation.value = layer['value'] annotation.created = datetime.fromtimestamp(int(layer['created'])) @@ -137,7 +139,7 @@ for oldId in sorted(padma, key=lambda x: padma[x]['created']): #if True: data = padma_data[oldId] _data = item_data(data) - username = _data.pop('creator').strip().lower() + username = _data.pop('creator').strip() item.user = User.objects.get(username=username) for key in _data: item.data[key] = _data[key] @@ -183,9 +185,10 @@ for oldId in sorted(padma, key=lambda x: padma[x]['created']): alias.new = item.itemId alias.save() print item, item.itemId -#lists + +print "import lists" for l in lists: - l['user'] = User.objects.get(username=l['user'].strip().lower()) + l['user'] = User.objects.get(username=l['user'].strip()) p,c = List.objects.get_or_create(name=l['title'], user=l['user']) p.type = l['type'] == 'static' and 'static' or 'smart' p.status = l['public'] and 'featured' or 'private' @@ -210,10 +213,11 @@ for l in lists: alias.save() #Places +print "import places" for l in locations: oldId = l.pop('id') if 'user' in l: - l['user'] = User.objects.get(username=l['user'].strip().lower()) + l['user'] = User.objects.get(username=l['user'].strip()) else: l['user'] = User.objects.all().order_by('id')[0] l['created'] = datetime.fromtimestamp(int(l['created']))