|
|
|
|
@ -3,10 +3,11 @@ from south.utils import datetime_utils as datetime |
|
|
|
|
from south.db import db |
|
|
|
|
from south.v2 import DataMigration |
|
|
|
|
from django.db import models, transaction |
|
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
|
|
from city.models import City |
|
|
|
|
from country.models import Country |
|
|
|
|
# from emencia.django.newsletter.models import Contact |
|
|
|
|
from emencia.django.newsletter.models import Contact |
|
|
|
|
# from theme.models import Theme |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -17,9 +18,9 @@ class Migration(DataMigration): |
|
|
|
|
# Note: Don't use "from appname.models import ModelName". |
|
|
|
|
# Use orm.ModelName to refer to models in this application, |
|
|
|
|
# and orm['appname.ModelName'] for models in other applications. |
|
|
|
|
Contact = orm['newsletter.Contact'] |
|
|
|
|
moscow = City.objects.language('ru').get(name=u'Москва').pk |
|
|
|
|
russia = Country.objects.language('ru').get(name=u'Россия').pk |
|
|
|
|
# Contact = orm['newsletter.Contact'] |
|
|
|
|
moscow = settings.MOSCOW_PK |
|
|
|
|
russia = settings.RUSSIA_PK |
|
|
|
|
r_cities = set(City.objects.filter(country_id=russia).values_list('pk', flat=True)) |
|
|
|
|
# with transaction.commit_manually(): |
|
|
|
|
for contact in Contact.objects.prefetch_related('contactsettings').all(): |
|
|
|
|
|