def _importer_bilder_fra_webside(websak, story, autocrop):
    """ Import all images connected to a single story. """
    for bilde in websak.bilde_set.all():
        # Prepare the caption.
        try:
            caption = bilde.bildetekst.tekst
            caption = _clean_up_html(caption)
            caption = re.sub(r'^@[^:]+: ?', '', caption)  # strip tag.
        except (Bildetekst.DoesNotExist, AttributeError):
            caption = ''

        # Make the ImageFile object.
        image_file = _create_image_file(
            filepath=bilde.path,
            publication_date=websak.dato,
            pk=bilde.id_bilde,
        )

        # Make the StoryImage object.
        if image_file:
            published = bool(bilde.size)
            story_image = StoryImage(
                parent_story=story,
                imagefile=image_file,
                index=0 if published else None,
                size=bilde.size or 0,
                creditline='',
                caption=caption[:1000],
            )
            story_image.save()
            if autocrop:
                image_file.autocrop()
def _importer_bilder_fra_prodsys(prodsak, story, autocrop):
    """ Import all images connected to a single story. """
    prod_bilder = Prodbilde.objects.filter(prodsak_id=prodsak.prodsak_id)

    for bilde in prod_bilder:
        story_image = None
        # Prepare the image caption.
        caption = bilde.bildetekst or ''
        caption = _clean_up_html(caption)
        caption = re.sub(r'^@[^:]+: ?', '', caption)  # strip xtag.

        # Make the ImageFile and StoryImage objects.
        image_file = _create_image_file(filepath=bilde.bildefil, prodsys=True)

        if image_file:
            published = bool(bilde.prioritet)
            story_image = StoryImage(
                parent_story=story,
                imagefile=image_file,
                index=0 if published else None,
                size=bilde.prioritet or 0,
                creditline='',
                caption=caption[:1000],
            )
            story_image.save()
            if autocrop:
                image_file.autocrop()
Пример #3
0
def _importer_bilder_fra_webside(websak, story, autocrop):
    """ Import all images connected to a single story. """
    for bilde in websak.bilde_set.all():
        # Prepare the caption.
        try:
            caption = bilde.bildetekst.tekst
            caption = _clean_up_html(caption)
            caption = re.sub(r'^@[^:]+: ?', '', caption)  # strip tag.
        except (Bildetekst.DoesNotExist, AttributeError):
            caption = ''

        # Make the ImageFile object.
        image_file = _create_image_file(
            filepath=bilde.path,
            publication_date=websak.dato,
            pk=bilde.id_bilde,
        )

        # Make the StoryImage object.
        if image_file:
            published = bool(bilde.size)
            story_image = StoryImage(
                parent_story=story,
                imagefile=image_file,
                index=0 if published else None,
                size=bilde.size or 0,
                creditline='',
                caption=caption[:1000],
            )
            story_image.save()
            if autocrop:
                image_file.autocrop()
Пример #4
0
def _importer_bilder_fra_prodsys(prodsak, story, autocrop):
    """ Import all images connected to a single story. """
    prod_bilder = Prodbilde.objects.filter(prodsak_id=prodsak.prodsak_id)

    for bilde in prod_bilder:
        story_image = None
        # Prepare the image caption.
        caption = bilde.bildetekst or ''
        caption = _clean_up_html(caption)
        caption = re.sub(r'^@[^:]+: ?', '', caption)  # strip xtag.

        # Make the ImageFile and StoryImage objects.
        image_file = _create_image_file(filepath=bilde.bildefil, prodsys=True)

        if image_file:
            published = bool(bilde.prioritet)
            story_image = StoryImage(
                parent_story=story,
                imagefile=image_file,
                index=0 if published else None,
                size=bilde.prioritet or 0,
                creditline='',
                caption=caption[:1000],
            )
            story_image.save()
            if autocrop:
                image_file.autocrop()
def fake_story_image(story, byline):
    imagefile = fake_imagefile(contributor=byline)
    instance = StoryImage(
        parent_story=story,
        caption='foobar',
        imagefile=imagefile,
    )
    instance.save()
    return instance
Пример #6
0
def fake_story_image(story, byline):
    imagefile = fake_imagefile(contributor=byline)
    instance = StoryImage(
        parent_story=story,
        caption='foobar',
        imagefile=imagefile,
    )
    instance.save()
    return instance