Exemplo n.º 1
0
    def get_models(self, include_auto_created=False, include_swapped=False):
        """
        Returns an iterable of models except ['Image', 'Rendition']
        when User customize WAGTAILIMAGES_IMAGE_MODEL

        By default, the following models aren't included:

        - auto-created models for many-to-many relations without
          an explicit intermediate table,
        - models that have been swapped out.

        Set the corresponding keyword argument to True to include such models.
        Keyword arguments aren't documented; they're a private API.
        """
        self.apps.check_models_ready()
        for model in self.models.values():
            if get_image_model_string() != 'wagtailimages.Image' \
                and model.__name__ in ['Image', 'Rendition']:
                continue
            if model._meta.auto_created and not include_auto_created:
                continue
            if model._meta.swapped and not include_swapped:
                continue
            yield model
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
 def test_custom_get_image_model_string(self):
     """Test get_image_model_string with a custom image model"""
     self.assertEqual(get_image_model_string(), 'tests.CustomImage')
 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')
 def test_custom_get_image_model_string(self):
     """Test get_image_model_string with a custom image model"""
     self.assertEqual(get_image_model_string(), 'tests.CustomImage')
Exemplo n.º 6
0
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, InlinePanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailimages import get_image_model, get_image_model_string
from wagtail.wagtailsearch import index

from modelcluster.fields import ParentalKey
from modelcluster.tags import ClusterTaggableManager

from taggit.models import TaggedItemBase

from wapps.utils import get_image_url

ImageModel = get_image_model_string()


class Gallery(Page):
    intro = RichTextField(_('Introduction'),
                          blank=True,
                          help_text=_('A text to be displayed before albums'))

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
    ]

    feed_image = models.ForeignKey(ImageModel,
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
Exemplo n.º 7
0
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, InlinePanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailimages import get_image_model, get_image_model_string
from wagtail.wagtailsearch import index

from modelcluster.fields import ParentalKey
from modelcluster.tags import ClusterTaggableManager

from taggit.models import TaggedItemBase

from wapps.utils import get_image_url

ImageModel = get_image_model_string()


class Gallery(Page):
    intro = RichTextField(_('Introduction'), blank=True,
                          help_text=_('A text to be displayed before albums'))

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
    ]

    feed_image = models.ForeignKey(
        ImageModel,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,