Commit 4d114980 authored by Michal Čihař's avatar Michal Čihař

Separate language preferences import

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent dd80709d
...@@ -46,6 +46,20 @@ class Command(BaseCommand): ...@@ -46,6 +46,20 @@ class Command(BaseCommand):
for field in Profile.SUBSCRIPTION_FIELDS: for field in Profile.SUBSCRIPTION_FIELDS:
setattr(profile, field, userprofile[field]) setattr(profile, field, userprofile[field])
def update_languages(self, profile, userprofile):
"""
Updates user language preferences.
"""
profile.language = userprofile['language']
for lang in userprofile['secondary_languages']:
profile.secondary_languages.add(
Language.objects.get(code=lang)
)
for lang in userprofile['languages']:
profile.languages.add(
Language.objects.get(code=lang)
)
def handle(self, *args, **options): def handle(self, *args, **options):
''' '''
Creates default set of groups and optionally updates them and moves Creates default set of groups and optionally updates them and moves
...@@ -79,15 +93,7 @@ class Command(BaseCommand): ...@@ -79,15 +93,7 @@ class Command(BaseCommand):
# Update fields if we should # Update fields if we should
if update: if update:
profile.language = userprofile['language'] self.update_languages(profile, userprofile)
for lang in userprofile['secondary_languages']:
profile.secondary_languages.add(
Language.objects.get(code=lang)
)
for lang in userprofile['languages']:
profile.languages.add(
Language.objects.get(code=lang)
)
# Add subscriptions # Add subscriptions
self.import_subscriptions(profile, userprofile) self.import_subscriptions(profile, userprofile)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment