From 30b1e5f9c364fd0d4f92d425d1647c82807b00cb Mon Sep 17 00:00:00 2001 From: rscnt Date: Sat, 13 Feb 2016 14:28:46 -0600 Subject: [PATCH 1/2] added supporters plugin Signed-off-by: rscnt --- digitalglarus/cms_plugins.py | 15 ++++++++++++++- .../digitalglarus/supporters_plugin.html | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 digitalglarus/templates/digitalglarus/supporters_plugin.html diff --git a/digitalglarus/cms_plugins.py b/digitalglarus/cms_plugins.py index db317a67..03c54cae 100644 --- a/digitalglarus/cms_plugins.py +++ b/digitalglarus/cms_plugins.py @@ -1,6 +1,6 @@ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool -from .models import DGGalleryPlugin +from .models import DGGalleryPlugin, Supporter from django.utils.translation import ugettext as _ class CMSGalleryPlugin(CMSPluginBase): @@ -16,4 +16,17 @@ class CMSGalleryPlugin(CMSPluginBase): }) return context +class CMSSupportersPlugin(CMSPluginBase): + name = _("Digital Glarus Supporters") + render_template = "digitalglarus/supporters_plugin.html" + + def render(self, context, instance, placeholder): + context.update({ + 'supporters': Supporter.objects.all(), + 'object': instance, + 'placeholder':placeholder + }) + return context + plugin_pool.register_plugin(CMSGalleryPlugin) +plugin_pool.register_plugin(CMSSupportersPlugin) diff --git a/digitalglarus/templates/digitalglarus/supporters_plugin.html b/digitalglarus/templates/digitalglarus/supporters_plugin.html new file mode 100644 index 00000000..f4fbd349 --- /dev/null +++ b/digitalglarus/templates/digitalglarus/supporters_plugin.html @@ -0,0 +1,14 @@ +
+ {{placeholder}} +

WILLIWILLIWANKA

+{% for supporter in supporters %} +
+
+
+

{{supporter.name}}

+

{{supporter.description}}

+
+
+
+{% endfor %} +
From d6ddbc31ceadb7efd7aa4499b89132744292d3e8 Mon Sep 17 00:00:00 2001 From: rscnt Date: Sun, 14 Feb 2016 09:47:07 -0600 Subject: [PATCH 2/2] added supporters plugin Signed-off-by: rscnt --- digitalglarus/cms_plugins.py | 5 ++-- .../migrations/0008_dgsupportersplugin.py | 26 +++++++++++++++++++ ..._remove_dgsupportersplugin_dgsupporters.py | 18 +++++++++++++ digitalglarus/models.py | 6 +++++ .../digitalglarus/supporters_plugin.html | 16 ++++-------- .../cms/digitalglarus/partials/menu.html | 3 --- templates/cms/digitalglarus/two_columns.html | 21 +++++++++++++++ 7 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 digitalglarus/migrations/0008_dgsupportersplugin.py create mode 100644 digitalglarus/migrations/0009_remove_dgsupportersplugin_dgsupporters.py create mode 100644 templates/cms/digitalglarus/two_columns.html diff --git a/digitalglarus/cms_plugins.py b/digitalglarus/cms_plugins.py index 03c54cae..703176a2 100644 --- a/digitalglarus/cms_plugins.py +++ b/digitalglarus/cms_plugins.py @@ -1,6 +1,6 @@ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool -from .models import DGGalleryPlugin, Supporter +from .models import DGGalleryPlugin, DGSupportersPlugin, Supporter from django.utils.translation import ugettext as _ class CMSGalleryPlugin(CMSPluginBase): @@ -18,11 +18,12 @@ class CMSGalleryPlugin(CMSPluginBase): class CMSSupportersPlugin(CMSPluginBase): name = _("Digital Glarus Supporters") + model = DGSupportersPlugin render_template = "digitalglarus/supporters_plugin.html" def render(self, context, instance, placeholder): context.update({ - 'supporters': Supporter.objects.all(), + 'supporters': Supporter.objects.all().order_by('name'), 'object': instance, 'placeholder':placeholder }) diff --git a/digitalglarus/migrations/0008_dgsupportersplugin.py b/digitalglarus/migrations/0008_dgsupportersplugin.py new file mode 100644 index 00000000..c7855bca --- /dev/null +++ b/digitalglarus/migrations/0008_dgsupportersplugin.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0012_auto_20150607_2207'), + ('digitalglarus', '0007_auto_20160208_1031'), + ] + + operations = [ + migrations.CreateModel( + name='DGSupportersPlugin', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(primary_key=True, auto_created=True, parent_link=True, to='cms.CMSPlugin', serialize=False)), + ('dgSupporters', models.ManyToManyField(to='digitalglarus.Supporter')), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/digitalglarus/migrations/0009_remove_dgsupportersplugin_dgsupporters.py b/digitalglarus/migrations/0009_remove_dgsupportersplugin_dgsupporters.py new file mode 100644 index 00000000..39ee3969 --- /dev/null +++ b/digitalglarus/migrations/0009_remove_dgsupportersplugin_dgsupporters.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('digitalglarus', '0008_dgsupportersplugin'), + ] + + operations = [ + migrations.RemoveField( + model_name='dgsupportersplugin', + name='dgSupporters', + ), + ] diff --git a/digitalglarus/models.py b/digitalglarus/models.py index b70c00fd..0f6742c3 100644 --- a/digitalglarus/models.py +++ b/digitalglarus/models.py @@ -22,6 +22,9 @@ class Supporter(models.Model): def __str__(self): return "%s" % (self.name) + def get_absolute_url(self): + return reverse('dgSupporters_view', args=[self.pk]) + class DGGallery(models.Model): parent = models.ForeignKey('self', blank=True, null=True) @@ -46,3 +49,6 @@ class DGPicture(models.Model): class DGGalleryPlugin(CMSPlugin): dgGallery = models.ForeignKey(DGGallery) + +class DGSupportersPlugin(CMSPlugin): + pass diff --git a/digitalglarus/templates/digitalglarus/supporters_plugin.html b/digitalglarus/templates/digitalglarus/supporters_plugin.html index f4fbd349..b037e99f 100644 --- a/digitalglarus/templates/digitalglarus/supporters_plugin.html +++ b/digitalglarus/templates/digitalglarus/supporters_plugin.html @@ -1,14 +1,8 @@ -
- {{placeholder}} -

WILLIWILLIWANKA

-{% for supporter in supporters %} +
+ {% for supporter in supporters.all %}
-
-
-

{{supporter.name}}

-

{{supporter.description}}

-
-
+

{{supporter.name}}

+

{{supporter.description}}

-{% endfor %} + {% endfor %}
diff --git a/templates/cms/digitalglarus/partials/menu.html b/templates/cms/digitalglarus/partials/menu.html index 68bcd326..7223713f 100644 --- a/templates/cms/digitalglarus/partials/menu.html +++ b/templates/cms/digitalglarus/partials/menu.html @@ -18,9 +18,6 @@
+ + +{% endblock %}