Source

cmsplugin-photologue / cmsplugin_photologue / cms_plugins.py

The cms-2.X branch has multiple heads

tehfink ad35c19 

tehfink 4940ca6 
tehfink ad35c19 
tehfink 4940ca6 
tehfink ad35c19 





tehfink 6c343e8 
tehfink ad35c19 

tehfink 4940ca6 



tehfink 7db6fda 

tehfink 4940ca6 







tehfink 7db6fda 
tehfink 4940ca6 
tehfink ad35c19 







tehfink 6c343e8 
tehfink 2064ac3 
tehfink ad35c19 
tehfink 4940ca6 



tehfink 7db6fda 

tehfink 4940ca6 






tehfink 7db6fda 
tehfink 4940ca6 
tehfink ad35c19 

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cmsplugin_photologue.models import PhotologueGalleryPlugin, PhotologuePhotoPlugin
from django.utils.translation import ugettext as _
from photologue.models import Gallery, Photo
from django.conf import settings


class CMSPhotologueGalleryPlugin(CMSPluginBase):
    model = PhotologueGalleryPlugin
    name = _("Photologue Gallery")
    text_enabled = True

    def render(self, context, instance, placeholder):

        #set plugin template from plugin model
        self.render_template = "plugins/cmsplugin_photologue/%s" % instance.get_template_display()

        inline = True if instance.parent else False

        context.update({
            'gallery':      instance.gallery,
            'placeholder':  placeholder,
            'queryset':     Gallery.objects.filter(is_public=True),
            'allow_empty':  True,
            'paginate_by':  5,
            'sample_size':  ":%s" % instance.sample_size,
            'css':          instance.get_css_display(),
            'inline':       inline,
        })
        return context

plugin_pool.register_plugin(CMSPhotologueGalleryPlugin)


class CMSPhotologuePhotoPlugin(CMSPluginBase):
    model = PhotologuePhotoPlugin
    name = _("Photologue Photo")
    text_enabled = True

    def render(self, context, instance, placeholder):

        #set plugin template from plugin model
        self.render_template = "plugins/cmsplugin_photologue/%s" % instance.get_template_display()

        inline = True if instance.parent else False

        context.update({
            'photo':        instance.photo,
            'placeholder':  placeholder,
            'slug_field':   'title_slug',
            'queryset':     Photo.objects.filter(is_public=True),
            'is_thumb':     instance.is_thumb,
            'css':          instance.get_css_display(),
            'inline':       inline,
        })
        return context

plugin_pool.register_plugin(CMSPhotologuePhotoPlugin)