Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 3 commits
  • 5 files changed
  • 2 commit comments
  • 2 contributors
24 cmsplugin_zinnia/cms_plugins.py
View
@@ -15,6 +15,7 @@
from cmsplugin_zinnia.models import RandomEntriesPlugin
from cmsplugin_zinnia.models import LatestEntriesPlugin
from cmsplugin_zinnia.models import SelectedEntriesPlugin
+from cmsplugin_zinnia.models import CategoryEntriesPlugin
class CMSLatestEntriesPlugin(CMSPluginBase):
@@ -115,6 +116,28 @@ def icon_src(self, instance):
"""Icon source of the plugin"""
return settings.STATIC_URL + u'cmsplugin_zinnia/img/plugin.png'
+class CMSCategoryEntriesPlugin(CMSPluginBase):
+ """Django-cms plugin for random entries"""
+ module = _('entries')
+ model = CategoryEntriesPlugin
+ name = _('Category entries')
+ render_template = 'cmsplugin_zinnia/category_entries.html'
+ fields = ('category',)
+ text_enabled = True
+
+ def render(self, context, instance, placeholder):
+ """Update the context with plugin's data"""
+
+ entries = instance.category.entries_published()
+ context.update(
+ {'entries': entries
+ })
+ return context
+
+ def icon_src(self, instance):
+ """Icon source of the plugin"""
+ return settings.STATIC_URL + u'zinnia/img/plugin.png'
+
class CMSSearchPlugin(CMSPluginBase):
"""Plugins for including a Zinnia's search form"""
@@ -134,5 +157,6 @@ def icon_src(self, instance):
plugin_pool.register_plugin(CMSLatestEntriesPlugin)
plugin_pool.register_plugin(CMSSelectedEntriesPlugin)
+plugin_pool.register_plugin(CMSCategoryEntriesPlugin)
plugin_pool.register_plugin(CMSRandomEntriesPlugin)
plugin_pool.register_plugin(CMSSearchPlugin)
11 cmsplugin_zinnia/models.py
View
@@ -91,6 +91,17 @@ class RandomEntriesPlugin(CMSPlugin):
def __unicode__(self):
return _('%s entries') % self.number_of_entries
+class CategoryEntriesPlugin(CMSPlugin):
+ """CMS Plugin for displaying entries in a category"""
+
+ category = models.ForeignKey(Category, null=False)
+ number_of_entries = models.IntegerField(
+ _('number of entries'), default=5)
+
+ def __unicode__(self):
+ return _('%s entries') % self.number_of_entries
+
+
def invalidate_menu_cache(sender, **kwargs):
"""Signal receiver to invalidate the menu_pool
2  cmsplugin_zinnia/placeholder.py
View
@@ -14,6 +14,6 @@ def html_content(self):
"""No additional formatting is necessary"""
return self.content
- class Meta:
+ class Meta(EntryAbstractClass.Meta):
"""EntryPlaceholder's Meta"""
abstract = True
14 cmsplugin_zinnia/templates/cmsplugin_zinnia/category_entries.html
View
@@ -0,0 +1,14 @@
+{% load i18n zinnia_tags %}
+
+
+{% for object in entries %}
+<div id="entry-{{ object.pk }}" class="hentry{% if object.featured %} featured{% endif %} span-16 last">
+ {% with object.html_content|truncatewords_html:100|safe as object_content %}
+ {% include "zinnia/_entry_detail_for_list.html" %}
+ {% endwith %}
+</div>
+<hr />
+{% empty %}
+ {% trans "No entries yet." %}
+{% endfor %}
+
6 demo_cmsplugin_zinnia/settings.py
View
@@ -38,8 +38,12 @@
('it', gettext('Italian')),
('nl', gettext('Dutch')),
('hu', gettext('Hungarian')),
+ ('cs', gettext('Czech')),
+ ('sk', gettext('Slovak')),
('ru', gettext('Russian')),
('pl', gettext('Polish')),
+ ('eu', gettext('Basque')),
+ ('hr_HR', gettext('Croatian')),
('pt_BR', gettext('Brazilian Portuguese')),
('zh_CN', gettext('Simplified Chinese')),)
@@ -103,3 +107,5 @@
CMS_TEMPLATES = (
('cms/page.html', gettext('Default page')),
)
+
+ZINNIA_ENTRY_BASE_MODEL = 'cmsplugin_zinnia.placeholder.EntryPlaceholder'

Showing you all comments on commits in this comparison.

Julien Fache

Tell me if I have missed something but CMSCategoryEntriesPlugin seems to be a doublon of CMSLatestEntriesPlugin with less parameters no ?

Mauro Bianchi
Owner
Something went wrong with that request. Please try again.