当前位置: 首页>>代码示例>>Python>>正文


Python models.Image方法代码示例

本文整理汇总了Python中wagtail.wagtailimages.models.Image方法的典型用法代码示例。如果您正苦于以下问题:Python models.Image方法的具体用法?Python models.Image怎么用?Python models.Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wagtail.wagtailimages.models的用法示例。


在下文中一共展示了models.Image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_run_test

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def make_run_test(cls, filter_spec, image_kwargs, expected_output):
        def test_run(self):
            image = Image(**image_kwargs)

            # Make operation
            operation = self.operation_class(*filter_spec.split('-'))

            # Make operation recorder
            operation_recorder = WillowOperationRecorder((image.width, image.height))

            # Run
            operation.run(operation_recorder, image, {})

            # Check
            self.assertEqual(operation_recorder.ran_operations, expected_output)

        test_run.__name__ = str('test_run_%s' % filter_spec)
        return test_run 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:20,代码来源:test_image_operations.py

示例2: test_runs_operations

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_runs_operations(self):
        run_mock = Mock()

        def run(willow, image, env):
            run_mock(willow, image, env)

        self.operation_instance.run = run

        fil = Filter(spec='operation1|operation2')
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file(),
        )
        fil.run(image, BytesIO())

        self.assertEqual(run_mock.call_count, 2) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:18,代码来源:test_image_operations.py

示例3: setUp

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def setUp(self):
        self.site = Site.objects.first()
        self.site.site_name = 'Example site'
        self.site.save()

        self.factory = RequestFactory()
        self.request = self.factory.get('/test/')
        self.request.site = self.site

        self.image = Image.objects.create(
            title='Test Image',
            file=get_test_image_file(),
        )
        self.page = self.site.root_page.add_child(instance=TestPage(
            title='Test Page',
            search_image=self.image,
            search_description='Some test content description',
        ))
        self.test_model = TestModel.objects.create() 
开发者ID:takeflight,项目名称:wagtail-metadata,代码行数:21,代码来源:test_templates.py

示例4: fetch_hut_images

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def fetch_hut_images():
    for hpage in HutPage.objects.all():
        if hpage.link_url:
            try:
                r = requests.get(hpage.link_url, timeout=settings.API_TIMEOUT)
            except requests.exceptions.RequestException as e:
                logger.exception(str(e))
            else:
                soup = BeautifulSoup(r.content, 'html5lib')
                a_tag = soup.find_all("a", {"class": "fancybox-gallery"})
                if a_tag:
                    img_tag = a_tag[0].find_all("img")
                    if img_tag:
                        img_url = 'http://www.doc.govt.nz/%s' % img_tag[0].get('src')
                        logger.debug("Hut %s using img %s from HTML body.", str(hpage.pk), img_url)
                else:
                    page = metadata_parser.MetadataParser(url=hpage.link_url)
                    img_url = page.get_metadata_link('image')
                    logger.debug("Hut %s using img %s from HTML meta", str(hpage.pk), img_url)
                if img_url:
                    try:
                        response = requests.get(img_url, timeout=settings.API_TIMEOUT)
                    except requests.exceptions.RequestException as e:
                        logger.exception(str(e))
                    image = Image(title=hpage.title, file=ImageFile(BytesIO(response.content), name=img_url.split('/')[-1]))
                    image.save()
                    hpage.meta_image = image
                    hpage.save()
                else:
                    logger.debug("No img found for hut %s", str(hpage.pk)) 
开发者ID:jordij,项目名称:nzhuts,代码行数:32,代码来源:tasks.py

示例5: default

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def default(self, obj):
        if isinstance(obj, Image):
            return image_ld(obj)
        if isinstance(obj, ThingLD):
            return obj.ld_nested_entity()
        return super(JSONLDEncoder, self).default(obj) 
开发者ID:takeflight,项目名称:wagtail-schema.org,代码行数:8,代码来源:encoder.py

示例6: test_feed_image

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_feed_image(self):
        field = BasicPage._meta.get_field('feed_image')
        self.assertModelPKField(field, Image, models.SET_NULL, True, True)

    # properties 
开发者ID:AccentDesign,项目名称:django_wagtail_boilerplate,代码行数:7,代码来源:test_basic.py

示例7: setUp

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def setUp(self):
        # Create an image for running tests on
        self.image = Image.objects.create(
            title="Test image",
            file=get_test_image_file(),
        ) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:8,代码来源:tests.py

示例8: test_fields

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_fields(self):
        form = get_image_form(Image)

        self.assertEqual(list(form.base_fields.keys()), [
            'title',
            'file',
            'collection',
            'tags',
            'focal_point_x',
            'focal_point_y',
            'focal_point_width',
            'focal_point_height',
        ]) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:15,代码来源:tests.py

示例9: test_normal_filter

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_normal_filter(self):
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file(filename='test_rf1.png'),
        )
        rendition = image.get_rendition('width-100')

        self.assertEqual(rendition.file.name, 'images/test_rf1.width-100.png') 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:10,代码来源:tests.py

示例10: test_fill_filter_with_focal_point

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_fill_filter_with_focal_point(self):
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file(filename='test_rf3.png'),
        )
        image.set_focal_point(Rect(100, 100, 200, 200))
        image.save()

        rendition = image.get_rendition('fill-100x100')

        self.assertEqual(rendition.file.name, 'images/test_rf3.15ee4958.fill-100x100.png') 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:13,代码来源:tests.py

示例11: test_filter_with_pipe_gets_dotted

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_filter_with_pipe_gets_dotted(self):
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file(filename='test_rf4.png'),
        )
        image.set_focal_point(Rect(100, 100, 200, 200))
        image.save()

        rendition = image.get_rendition('fill-200x200|height-150')

        self.assertEqual(rendition.file.name, 'images/test_rf4.15ee4958.fill-200x200.height-150.png') 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:13,代码来源:tests.py

示例12: test_upload_path

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_upload_path(self):
        image = CustomImageFilePath.objects.create(
            title="Test image",
            file=get_test_image_file(),
        )

        second_image = CustomImageFilePath.objects.create(
            title="Test Image",
            file=get_test_image_file(colour='black'),

        )

        # The files should be uploaded based on it's content, not just
        # it's filename
        self.assertFalse(image.file.url == second_image.file.url) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:17,代码来源:tests.py

示例13: test_standard_get_image_model

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_standard_get_image_model(self):
        """Test get_image_model with no WAGTAILIMAGES_IMAGE_MODEL"""
        del settings.WAGTAILIMAGES_IMAGE_MODEL
        from wagtail.wagtailimages.models import Image
        self.assertIs(get_image_model(), Image) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:7,代码来源:tests.py

示例14: test_standard_get_image_model_string

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_standard_get_image_model_string(self):
        """Test get_image_model_STRING with no WAGTAILIMAGES_IMAGE_MODEL"""
        del settings.WAGTAILIMAGES_IMAGE_MODEL
        self.assertEqual(get_image_model_string(), 'wagtailimages.Image') 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:6,代码来源:tests.py

示例15: test_cache_key

# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import Image [as 别名]
def test_cache_key(self):
        image = Image(width=1000, height=1000)
        fil = Filter(spec='max-100x100')
        cache_key = fil.get_cache_key(image)

        self.assertEqual(cache_key, '') 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:8,代码来源:test_image_operations.py


注:本文中的wagtail.wagtailimages.models.Image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。