diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..abae970 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,24 @@ +Copyright (c) 2011, Øyvind Saltvik +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Djeese Factory GmbH nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL DJEESE FACTORY GMBH BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/cmsplugin_blog/__init__.py b/cmsplugin_blog/__init__.py index 61eb96b..eb5db86 100644 --- a/cmsplugin_blog/__init__.py +++ b/cmsplugin_blog/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -VERSION = (1, 1, 1, 'final', 0) +VERSION = (1, 1, 2, 'final', 0) def get_version(): # pragma: no cover version = '%s.%s' % (VERSION[0], VERSION[1]) diff --git a/cmsplugin_blog/cms_plugins.py b/cmsplugin_blog/cms_plugins.py index f227e17..5c69482 100644 --- a/cmsplugin_blog/cms_plugins.py +++ b/cmsplugin_blog/cms_plugins.py @@ -1,5 +1,8 @@ from django.utils.translation import ugettext_lazy as _ +from tagging.models import TaggedItem +from tagging.utils import get_tag_list + from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.utils import get_language_from_request @@ -27,11 +30,17 @@ def render(self, context, instance, placeholder): kw = get_translation_filter_language(Entry, language) qs = qs.filter(**kw) + if instance.tagged: + tags = get_tag_list(instance.tagged) + qs = TaggedItem.objects.get_by_model(qs , tags) + latest = qs[:instance.limit] + context.update({ 'instance': instance, 'latest': latest, - 'placeholder': placeholder, + 'object_list': latest, + 'placeholder': placeholder }) return context diff --git a/cmsplugin_blog/migrations/0015_auto__add_field_latestentriesplug.py b/cmsplugin_blog/migrations/0015_auto__add_field_latestentriesplug.py new file mode 100644 index 0000000..ecac5f5 --- /dev/null +++ b/cmsplugin_blog/migrations/0015_auto__add_field_latestentriesplug.py @@ -0,0 +1,107 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding field 'LatestEntriesPlugin.tagged' + db.add_column('cmsplugin_latestentriesplugin', 'tagged', self.gf('django.db.models.fields.CharField')(default='', max_length=255, blank=True), keep_default=False) + + + def backwards(self, orm): + + # Removing unique constraint on 'EntryTitle', fields ['slug', 'language'] + db.delete_unique('cmsplugin_blog_entrytitle', ['slug', 'language']) + + # Deleting field 'LatestEntriesPlugin.tagged' + db.delete_column('cmsplugin_latestentriesplugin', 'tagged') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'cms.cmsplugin': { + 'Meta': {'object_name': 'CMSPlugin'}, + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), + 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), + 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + }, + 'cms.placeholder': { + 'Meta': {'object_name': 'Placeholder'}, + 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) + }, + 'cmsplugin_blog.entry': { + 'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Entry'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'placeholders': ('djangocms_utils.fields.M2MPlaceholderField', [], {'to': "orm['cms.Placeholder']", 'symmetrical': 'False'}), + 'pub_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'tags': ('tagging.fields.TagField', [], {}) + }, + 'cmsplugin_blog.entrytitle': { + 'Meta': {'unique_together': "(('language', 'slug'),)", 'object_name': 'EntryTitle'}, + 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}), + 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_blog.Entry']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'max_length': '15'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'cmsplugin_blog.latestentriesplugin': { + 'Meta': {'object_name': 'LatestEntriesPlugin', 'db_table': "'cmsplugin_latestentriesplugin'", '_ormbases': ['cms.CMSPlugin']}, + 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), + 'current_language_only': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'limit': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'tagged': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['cmsplugin_blog'] diff --git a/cmsplugin_blog/models.py b/cmsplugin_blog/models.py index b72386b..740c54c 100644 --- a/cmsplugin_blog/models.py +++ b/cmsplugin_blog/models.py @@ -121,6 +121,7 @@ class EntryTitle(AbstractEntryTitle): class Meta: verbose_name = _('blogentry') verbose_name_plural = _('blogentries') + unique_together = ('language', 'slug') class LatestEntriesPlugin(CMSPlugin): """ @@ -130,3 +131,4 @@ class LatestEntriesPlugin(CMSPlugin): help_text=_('Limits the number of items that will be displayed')) current_language_only = models.BooleanField(_('Only show entries for the current language')) + tagged = models.CharField(max_length=255, blank=True) diff --git a/cmsplugin_blog/templates/admin/cmsplugin_blog/admin_helpers.html b/cmsplugin_blog/templates/admin/cmsplugin_blog/admin_helpers.html new file mode 100644 index 0000000..0fc1c00 --- /dev/null +++ b/cmsplugin_blog/templates/admin/cmsplugin_blog/admin_helpers.html @@ -0,0 +1,5 @@ +{% if use_missing %} + + + +{% endif %} diff --git a/cmsplugin_blog/templates/admin/cmsplugin_blog/change_form.html b/cmsplugin_blog/templates/admin/cmsplugin_blog/change_form.html index b71ac7d..7157b3d 100644 --- a/cmsplugin_blog/templates/admin/cmsplugin_blog/change_form.html +++ b/cmsplugin_blog/templates/admin/cmsplugin_blog/change_form.html @@ -1,11 +1,10 @@ {% extends "admin/change_form.html" %} {% block extrahead %} +{% load cmsplugin_blog_tags %} {{ block.super }} {% if not add %} {% endif %} - - - + {% admin_helpers %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive.html index a762306..4ba62cc 100644 --- a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive.html +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive.html @@ -1,24 +1,18 @@ {% extends "cmsplugin_blog/cmsplugin_blog_base.html" %} -{% load i18n placeholder_tags cmsplugin_blog_tags simple_translation_tags %} +{% load i18n cmsplugin_blog_tags %} {% block left-col %} {{ block.super }}
{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries" %}
-{% endfor %} - +{% endif %} +{% endwith %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_day.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_day.html index e1bacb4..3f7d853 100644 --- a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_day.html +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_day.html @@ -1,22 +1,16 @@ {% extends "cmsplugin_blog/cmsplugin_blog_base.html" %} -{% load i18n placeholder_tags cmsplugin_blog_tags simple_translation_tags %} +{% load i18n cmsplugin_blog_tags %} {% block left-col %} {{ block.super }}{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries for this day" %}
-{% endfor %} +{% endif %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_month.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_month.html index cbbca58..740e274 100644 --- a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_month.html +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_month.html @@ -1,23 +1,16 @@ {% extends "cmsplugin_blog/cmsplugin_blog_base.html" %} -{% load i18n placeholder_tags cmsplugin_blog_tags simple_translation_tags %} +{% load i18n cmsplugin_blog_tags %} {% block left-col %} {{ block.super }}{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries for this month" %}
-{% endfor %} +{% endif %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_year.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_year.html index 548725a..899219d 100644 --- a/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_year.html +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_archive_year.html @@ -16,8 +16,6 @@{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries by" %} {{ author }}
-{% endfor %} - +{% endif %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_list.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_list.html index 4d1f4ad..5c3f6f4 100644 --- a/cmsplugin_blog/templates/cmsplugin_blog/entry_list.html +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_list.html @@ -1,5 +1,5 @@ {% extends "cmsplugin_blog/cmsplugin_blog_base.html" %} -{% load i18n placeholder_tags cmsplugin_blog_tags simple_translation_tags %} +{% load i18n cmsplugin_blog_tags %} {% block extrahead %} {{ block.super }} @@ -12,18 +12,11 @@{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries tagged" %} "{{ tag }}"
-{% endfor %} +{% endif %} {% endblock %} diff --git a/cmsplugin_blog/templates/cmsplugin_blog/entry_list_include.html b/cmsplugin_blog/templates/cmsplugin_blog/entry_list_include.html new file mode 100644 index 0000000..2076156 --- /dev/null +++ b/cmsplugin_blog/templates/cmsplugin_blog/entry_list_include.html @@ -0,0 +1,11 @@ +{% load i18n placeholder_tags cmsplugin_blog_tags simple_translation_tags %} +{% for entry in object_list|annotate_with_translations %} + {% with entry|get_preferred_translation_from_request:request as title %} + {% with entry.placeholders|choose_placeholder:"excerpt" as excerpt %} +{{ entry.pub_date|date:"d b Y" }}
{{ title }}
+ {{ entry|render_language_choices:request|safe }}
+
{{ entry.pub_date|date:"d b Y" }}
{{ title }}
- {{ entry|render_language_choices:request|safe }}
-
{% trans "No entries" %}
-{% endfor %} +{% endif %} diff --git a/cmsplugin_blog/templatetags/cmsplugin_blog_tags.py b/cmsplugin_blog/templatetags/cmsplugin_blog_tags.py index 17b50fb..3c60b22 100644 --- a/cmsplugin_blog/templatetags/cmsplugin_blog_tags.py +++ b/cmsplugin_blog/templatetags/cmsplugin_blog_tags.py @@ -1,4 +1,5 @@ import datetime +from django.conf import settings from django import template from django.contrib.auth import models as auth_models @@ -53,4 +54,10 @@ def choose_placeholder(placeholders, placeholder): return placeholders.get(slot=placeholder) except Placeholder.DoesNotExist: return None - + + +@register.inclusion_tag('admin/cmsplugin_blog/admin_helpers.html') +def admin_helpers(): + return { + 'use_missing': 'missing' in settings.INSTALLED_APPS, + } diff --git a/djeese.ini b/djeese.ini new file mode 100644 index 0000000..4cac9ea --- /dev/null +++ b/djeese.ini @@ -0,0 +1,22 @@ +[app] +name = cmsplugin-blog2 +author = Øyvind Saltvik +version = 1.1.2 +packagename = cmsplugin-blog +installed-apps = + cmsplugin_blog + simple_translation + djangocms_utils + tagging + missing +description = A blog application +license = BSD +license-text = https://raw.github.com/fivethreeo/cmsplugin-blog/develop/LICENSE.txt +url = https://github.com/fivethreeo/cmsplugin-blog +settings = + placeholders + +[placeholders] +name = CMSPLUGIN_BLOG_PLACEHOLDERS +verbose-name = Placeholders for cmsplugin-blog +type = stringlist \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index ba80618..f979b58 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,11 +15,11 @@ Requirements * `simple-translation`_ 0.8.5+ * `jQuery`_ 1.4.4+ * `jQuery UI`_ 1.8.1+ -* `django-missing`_ (optional) +* `django-tagging`_ 0.3+ +* `django-missing`_ * `django-guardian`_ (optional) On Django 1.2.7: -* `django-tagging`_ 0.3+ * `django-cbv`_ .. note :: jQuery can be provided either by locally or linking to a public server, like Google's or Microsoft's CDN. @@ -42,7 +42,7 @@ Install ``cmsplugin-blog`` from pypi: :: pip install cmsplugin-blog -.. note :: When installing the cmsplugin-blog using pip `django-tagging`_, `djangocms-utils`_, and `simple-translation`_ will be installed automatically. +.. note :: When installing the cmsplugin-blog using pip `django-tagging`_, `django-missing`_, `djangocms-utils`_, and `simple-translation`_ will be installed automatically. *********************** Configuration and setup @@ -70,7 +70,7 @@ Add required settings:: 'simple_translation', 'tagging', 'staticfiles', - 'missing', # optional + 'missing', 'guardian', # optional ... ) diff --git a/setup.py b/setup.py index 609a3c0..a041367 100644 --- a/setup.py +++ b/setup.py @@ -32,5 +32,5 @@ test_suite = "cmsplugin_blog.test.run_tests.run_tests", include_package_data=True, zip_safe=False, - install_requires=['django-cms', 'simple-translation', 'djangocms-utils', 'django-tagging'], + install_requires=['django-cms', 'simple-translation', 'djangocms-utils', 'django-tagging', 'django-missing'], )