Skip to content
This repository has been archived by the owner on Nov 3, 2019. It is now read-only.

Commit

Permalink
migrate also new habits without legacy ID
Browse files Browse the repository at this point in the history
  • Loading branch information
passuf committed Jul 7, 2016
1 parent a0f3550 commit 4c48e1a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions wunderhabit/management/commands/migratehabits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Command(BaseCommand):

def handle(self, *args, **options):
users = User.objects.all()
users = User.objects.filter(email='passuf@gmail.com')
active_connections = Connection.objects.filter(is_active=True).count()
modified_connections = 0
disabled_connections = 0
Expand All @@ -33,12 +32,14 @@ def handle(self, *args, **options):

# Iterate over all connections
for connection in connections:
habit_id = None
habit_title = None
for habit in habits:
if '_legacyId' not in habit:
continue
habit_id = None
habit_title = None
if connection.habit_id == str(habit['_legacyId']):
if '_legacyId' in habit and connection.habit_id == str(habit['_legacyId']):
habit_id = habit['id']
habit_title = habit['text']
break
elif 'text' in habit and connection.habit_id == habit['text']:
habit_id = habit['id']
habit_title = habit['text']
break
Expand Down

0 comments on commit 4c48e1a

Please sign in to comment.