2016-04-01 10:37:01 +00:00
|
|
|
from cms.plugin_base import CMSPluginBase
|
|
|
|
from cms.plugin_pool import plugin_pool
|
|
|
|
from .models import DGGalleryPlugin, DGSupportersPlugin, Supporter
|
|
|
|
from django.utils.translation import ugettext as _
|
2017-06-29 14:34:40 +00:00
|
|
|
|
|
|
|
|
2016-04-01 10:37:01 +00:00
|
|
|
class CMSGalleryPlugin(CMSPluginBase):
|
|
|
|
model = DGGalleryPlugin
|
|
|
|
name = _("Digital Glarus Gallery")
|
|
|
|
render_template = "gallery.html"
|
2016-02-08 08:42:26 +00:00
|
|
|
|
2016-04-01 10:37:01 +00:00
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context.update({
|
2017-06-29 14:34:40 +00:00
|
|
|
'gallery': instance.dgGallery,
|
|
|
|
'object': instance,
|
|
|
|
'placeholder': placeholder
|
2016-04-01 10:37:01 +00:00
|
|
|
})
|
|
|
|
return context
|
2016-02-08 08:42:26 +00:00
|
|
|
|
2017-06-29 14:34:40 +00:00
|
|
|
|
2016-04-01 10:37:01 +00:00
|
|
|
class CMSSupportersPlugin(CMSPluginBase):
|
|
|
|
name = _("Digital Glarus Supporters")
|
|
|
|
model = DGSupportersPlugin
|
|
|
|
render_template = "supporters_plugin.html"
|
2016-02-13 20:28:46 +00:00
|
|
|
|
2016-04-01 10:37:01 +00:00
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context.update({
|
|
|
|
'supporters': Supporter.objects.all().order_by('name'),
|
|
|
|
'object': instance,
|
2017-06-29 14:34:40 +00:00
|
|
|
'placeholder': placeholder
|
2016-04-01 10:37:01 +00:00
|
|
|
})
|
|
|
|
return context
|
2017-06-29 14:34:40 +00:00
|
|
|
|
|
|
|
|
2016-04-01 10:37:01 +00:00
|
|
|
plugin_pool.register_plugin(CMSGalleryPlugin)
|
|
|
|
plugin_pool.register_plugin(CMSSupportersPlugin)
|