Skip to content

Instantly share code, notes, and snippets.

@bhagany
Created May 17, 2014 15:47
Show Gist options
  • Save bhagany/1e1df6e6cebe05ece7c6 to your computer and use it in GitHub Desktop.
Save bhagany/1e1df6e6cebe05ece7c6 to your computer and use it in GitHub Desktop.
]
corrected_rules = {
'.st-module-checkout-custom-form': 18,
'.st-module-checkout-custom-form-field': 19,
'.st-module-checkout-paragraph': 20,
}
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
for s in orm['stores.Store'].objects.filter(layout_set__pk__isnull=False).only('pk', 'editing').distinct().iterator():
for view_type in ['web', 'mobile', 'facebook']:
for rule in existing_rules:
try:
r = s.designrule_set.get(
store=s,
view_type=view_type,
what_cascade_order=rule['cascade_order'],
selector=rule['selector'],
rule=rule['existing'],
)
r.rule = ';'.join([rule['existing'], rule['rules']])
r.save()
except:
pass
if s.editing:
try:
r = s.editdesignrule_set.get(
store=s,
view_type=view_type,
what_cascade_order=rule['cascade_order'],
selector=rule['selector'],
rule=rule['existing'],
)
r.rule = ';'.join([rule['existing'], rule['rules']])
r.save()
except:
pass
for rule in new_rules:
rule_parts = []
if rule.get('copy_from', ''):
try:
rule_parts.append(orm['stores.DesignRule'].objects.get(selector=rule['copy_from'], store=s, view_type=view_type).rule)
except:
pass
if rule.get('rules', ''):
rule_parts.append(rule['rules'])
s.designrule_set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment