<s> from __future__ import unicode_literals <EOL> from django . apps import apps as django_apps <EOL> from django . conf import settings <EOL> from django . db import models , migrations , transaction <EOL> from django . db . utils import ProgrammingError , OperationalError <EOL> def noop ( apps , schema_editor ) : <EOL> pass <EOL> def get_config_count_count ( model_class ) : <EOL> with transaction . atomic ( ) : <EOL> count = model_class . objects . count ( ) <EOL> return count <EOL> def create_default_newsblog_config ( apps , schema_editor ) : <EOL> import cms . models . fields <EOL> from cms . models import Placeholder <EOL> NewsBlogConfig = apps . get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> try : <EOL> count = get_config_count_count ( NewsBlogConfig ) <EOL> except ( ProgrammingError , OperationalError ) : <EOL> NewsBlogConfig = django_apps . get_model ( '<STR_LIT>' ) <EOL> count = get_config_count_count ( NewsBlogConfig ) <EOL> if not count == <NUM_LIT:0> : <EOL> return <EOL> app_config = NewsBlogConfig ( namespace = '<STR_LIT>' ) <EOL> app_config . type = '<STR_LIT>' <EOL> app_config . pk = <NUM_LIT:1> <EOL> for field in app_config . _meta . fields : <EOL> if not field . __class__ == cms . models . fields . PlaceholderField : <EOL> continue <EOL> placeholder_name = field . name <EOL> placeholder_id_name = '<STR_LIT>' . format ( placeholder_name ) <EOL> placeholder_id = getattr ( app_config , placeholder_id_name , None ) <EOL> if placeholder_id is not None : <EOL> continue <EOL> new_placeholder = Placeholder . objects . create ( <EOL> slot = placeholder_name ) <EOL> setattr ( app_config , placeholder_id_name , new_placeholder . pk ) <EOL> app_config . save ( ) <EOL> app_config_translation = app_config . translations . create ( ) <EOL> app_config_translation . language_code = settings . LANGUAGES [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> app_config_translation . app_title = '<STR_LIT>' <EOL> app_config_translation . save ( ) <EOL> class Migration ( migrations . Migration ) : <EOL> dependencies = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> operations = [ <EOL> migrations . RunPython ( create_default_newsblog_config , noop ) <EOL> ] </s>
