Пример #1
0
    def decompress(self, value):
        if value:
            if is_file(value):
                return [value, None]

            return [None, value]

        return [None, None]
Пример #2
0
    def decompress(self, value):
        if value:
            if is_file(value):
                return [value, None]

            return [None, value]

        return [None, None]
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
 def test_is_file_false(self):
     s = u"This is a string, not a file"
     self.assertFalse(is_file(s))
Пример #6
0
 def test_is_file_true(self):
     f = File(sys.stdout)
     self.assertTrue(is_file(f))
Пример #7
0
 def test_is_file_false(self):
     s = u"This is a string, not a file"
     self.assertFalse(is_file(s))
Пример #8
0
 def test_is_file_true(self):
     f = File(sys.stdout)
     self.assertTrue(is_file(f))