def decompress(self, value): if value: if is_file(value): return [value, None] return [None, value] return [None, None]
def save(self, commit=True): instance = super(StoryAggregatorModelFormBase, self).save(commit) through_field_name = self._meta.model._meta.object_name.lower() for user in self.cleaned_data.get('members'): through_kwargs = { 'user': user, through_field_name: instance, 'member_type': 'member', } self._meta.model.members.through.objects.create(**through_kwargs) image_asset = None img_val = self.cleaned_data.get('image', None) if img_val: if is_file(img_val): image_asset = create_local_image_asset('image', img_val, img_val.name) else: image_asset = create_external_asset('image', url=img_val) instance.featured_assets.add(image_asset) return instance
def save(self, commit=True): instance = super(StoryAggregatorModelFormBase, self).save(commit) through_field_name = self._meta.model._meta.object_name.lower() for user in self.cleaned_data.get('members'): through_kwargs = { 'user': user, through_field_name: instance, 'member_type': 'member', } self._meta.model.members.through.objects.create( **through_kwargs) image_asset = None img_val = self.cleaned_data.get('image', None) if img_val: if is_file(img_val): image_asset = create_local_image_asset('image', img_val, img_val.name) else: image_asset = create_external_asset('image', url=img_val) instance.featured_assets.add(image_asset) return instance
def test_is_file_false(self): s = u"This is a string, not a file" self.assertFalse(is_file(s))
def test_is_file_true(self): f = File(sys.stdout) self.assertTrue(is_file(f))