def create_initial_crops(photo): crop1 = CropSettings.query.filter_by(name="thumb200").first() crop2 = CropSettings.query.filter_by(name="display_c").first() #TODO - This is a hack to make gallery thumbnails work. crop3 = CropSettings.query.filter_by(name="thumb400").first() cropTypes = (crop1,crop2,crop3) for cropType in cropTypes: thumbnail = make_crop(photo.image, cropType.name, cropType.height, cropType.width) crop = Crop(name=cropType.name, file=thumbnail['filename'], height=thumbnail['height'], width=thumbnail['width']) crop.save() photo.crops.append(crop) photo.save()
def create_crops(photo): """ Used when a Photo object is saved. Any crops in the Crops Settings table that don't exist will be created. """ cropTypes = CropSettings.query.all() for cropType in cropTypes: #TODO - Make this smarter #search = photo.crops.filter_by(name=cropType.name).first() #if search is None: thumbnail = make_crop(photo.image, cropType.name, cropType.height, cropType.width) crop = Crop(name=cropType.name, file=thumbnail['filename'], height=thumbnail['height'], width=thumbnail['width']) crop.save() photo.crops.append(crop) photo.save()