Skip to content

Instantly share code, notes, and snippets.

@lucemia
Created April 20, 2015 04:07
Show Gist options
  • Select an option

  • Save lucemia/0cadcf5f65306059f07b to your computer and use it in GitHub Desktop.

Select an option

Save lucemia/0cadcf5f65306059f07b to your computer and use it in GitHub Desktop.
fix_creative.py
from console.models import *
cs = Creative.objects.all()
keys = [
'css:.img_footer_body ul .img_footer_page img:width',
'css:.img_footer_body ul .img_footer_page img:height',
'css:.thumb:width',
'css:.thumb:height'
]
for c in cs:
for k in keys:
m = c.settings.get(k)
try:
m = int(m)
c.settings[k] = str(m) + 'px'
#print 'fix px', c, k
#c.save()
except Exception as e:
#print e
pass
if 'css:.item_img:width' in c.settings:
c.settings['css:.thumb:width'] = c.settings['css:.item_img:width']
if 'css:.item_img:height' in c.settings:
c.settings['css:.thumb:height'] = c.settings['css:.item_img:height']
if 'css:.item_img:overflow' in c.settings:
c.settings['css:.item_img:overflow'] = 'hidden'
print c
c.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment