def forwards(self, orm): "Write your forwards methods here." # 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. try: from drawquest.apps.palettes.models import legacy_purchasable_palettes except ImportError: from drawquest.apps.palettes.models import purchasable_palettes as legacy_purchasable_palettes legacy_palettes = legacy_purchasable_palettes(app_version='2.0.1') for palette in legacy_palettes: if orm.ColorPack.objects.filter(legacy_palette_name=palette.name).exists(): continue orm.ColorPack.objects.create( legacy_palette_name=palette.name, label=palette.human_readable_name, cost=palette.cost, is_for_sale=False, is_new=False, ordinal=0, ) for color in palette.colors: r, g, b = color.rgb try: orm.Color.objects.get(red=r, green=g, blue=b) except orm.Color.DoesNotExist: orm.Color.objects.create( red=r, green=g, blue=b, cost=10, label='TODO', ordinal=color.index, ) try: from drawquest.apps.palettes.models import legacy_purchasable_palettes except ImportError: from drawquest.apps.palettes.models import purchasable_palettes as legacy_purchasable_palettes legacy_palettes = legacy_purchasable_palettes(app_version='2.0.1') for palette in legacy_palettes: color_pack = orm.ColorPack.objects.get(legacy_palette_name=palette.name) color_pack.is_for_sale = True color_pack.save() for color in palette.colors: r, g, b = color.rgb color = orm.Color.objects.get(red=r, green=g, blue=b) color.is_for_sale = True color.save() color_pack.colors.add(color)
def forwards(self, orm): try: from drawquest.apps.palettes.models import legacy_purchasable_palettes except ImportError: from drawquest.apps.palettes.models import purchasable_palettes as legacy_purchasable_palettes legacy_palettes = legacy_purchasable_palettes(app_version='2.0.2') from drawquest.apps.palettes.models import DEFAULT_PALETTE for palette in legacy_palettes: for old_color in palette.colors: r, g, b = old_color.rgb new_color = orm.Color.objects.get(red=r, green=g, blue=b) new_color.ordinal = old_color.index new_color.save()
def forwards(self, orm): "Write your forwards methods here." # 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. try: from drawquest.apps.palettes.models import legacy_purchasable_palettes except ImportError: from drawquest.apps.palettes.models import purchasable_palettes as legacy_purchasable_palettes legacy_palettes = legacy_purchasable_palettes() for palette in legacy_palettes: color_pack = orm.ColorPack.objects.get(legacy_palette_name=palette.name) color_pack.is_for_sale = True color_pack.save() for color in palette.colors: r, g, b = color.rgb color = orm.Color.objects.get(red=r, green=g, blue=b) color.is_for_sale = True color.save() color_pack.colors.add(color)
def forwards(self, orm): "Write your forwards methods here." # 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. try: from drawquest.apps.palettes.models import legacy_purchasable_palettes except ImportError: from drawquest.apps.palettes.models import purchasable_palettes as legacy_purchasable_palettes legacy_palettes = legacy_purchasable_palettes() for palette in legacy_palettes: color_pack = orm.ColorPack.objects.get( legacy_palette_name=palette.name) color_pack.is_for_sale = True color_pack.save() for color in palette.colors: r, g, b = color.rgb color = orm.Color.objects.get(red=r, green=g, blue=b) color.is_for_sale = True color.save() color_pack.colors.add(color)
def purchasable_palettes(request): return {'palettes': models.legacy_purchasable_palettes(app_version=getattr(request, 'app_version', None))}
def purchasable_palettes(request): return { 'palettes': models.legacy_purchasable_palettes( app_version=getattr(request, 'app_version', None)) }