Skip to content

Commit

Permalink
develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Jun 4, 2012
2 parents d998f37 + c35d980 commit 6b0b5f7
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 87 deletions.
24 changes: 24 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion cmsplugin_blog/__init__.py
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
11 changes: 10 additions & 1 deletion cmsplugin_blog/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
107 changes: 107 additions & 0 deletions cmsplugin_blog/migrations/0015_auto__add_field_latestentriesplug.py
Original file line number Diff line number Diff line change
@@ -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']
2 changes: 2 additions & 0 deletions cmsplugin_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class EntryTitle(AbstractEntryTitle):
class Meta:
verbose_name = _('blogentry')
verbose_name_plural = _('blogentries')
unique_together = ('language', 'slug')

class LatestEntriesPlugin(CMSPlugin):
"""
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if use_missing %}
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11ndata.js"></script>
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11n.js"></script>
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/urlify2.js"></script>
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{% extends "admin/change_form.html" %}

{% block extrahead %}
{% load cmsplugin_blog_tags %}
{{ block.super }}
{% if not add %}
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}cmsplugin_blog/change_form.js"></script>
{% endif %}
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11ndata.js"></script>
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11n.js"></script>
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/urlify2.js"></script>
{% admin_helpers %}
{% endblock %}
20 changes: 7 additions & 13 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_archive.html
Original file line number Diff line number Diff line change
@@ -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 }}

<h1>{% trans "Latest entries" %}</h1>

{% for entry in latest|annotate_with_translations %}
{% with entry|get_preferred_translation_from_request:request as title %}
{% with entry.placeholders|choose_placeholder:"excerpt" as excerpt %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}
{% with latest as object_list %}
{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries" %}</p>
{% endfor %}

{% endif %}
{% endwith %}

{% endblock %}

Expand Down
18 changes: 6 additions & 12 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_archive_day.html
Original file line number Diff line number Diff line change
@@ -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 }}

<h1>{% trans "Entries for" %} {{ day|date:"d F Y" }}</h1>
{% 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 %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}

{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries for this day" %}</p>
{% endfor %}
{% endif %}

{% endblock %}

Expand Down
17 changes: 5 additions & 12 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_archive_month.html
Original file line number Diff line number Diff line change
@@ -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 }}

<h1>{% trans "Entries for" %} {{ month|date:"F Y" }}</h1>

{% 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 %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}
{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries for this month" %}</p>
{% endfor %}
{% endif %}

{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ <h1>{% trans "Entries for" %} {{ year }}</h1>

{% endblock %}



{% block right-col %}

{% render_author_links %}
Expand Down
18 changes: 5 additions & 13 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_author_list.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -12,19 +12,11 @@

<h1>{% trans "Entries by" %} {{ author }}</h1>

{% 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 %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}
{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries by" %} {{ author }}</p>
{% endfor %}

{% endif %}

{% endblock %}

Expand Down
17 changes: 5 additions & 12 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_list.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -12,18 +12,11 @@

<h1>{% trans "Entries tagged" %} "{{ tag }}"</h1>

{% 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 %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}
{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries tagged" %} "{{ tag }}"</p>
{% endfor %}
{% endif %}

{% endblock %}

Expand Down
11 changes: 11 additions & 0 deletions cmsplugin_blog/templates/cmsplugin_blog/entry_list_include.html
Original file line number Diff line number Diff line change
@@ -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 %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% endfor %}
17 changes: 5 additions & 12 deletions cmsplugin_blog/templates/cmsplugin_blog/latest_entries.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{% load i18n placeholder_tags simple_translation_tags djangocms_utils_tags %}
{% for entry in latest|annotate_with_translations %}
{% with entry|get_preferred_translation_from_request:request as title %}
{% with entry.placeholders|choose_placeholder:"excerpt" as excerpt %}
<p>{{ entry.pub_date|date:"d b Y" }}<br/><a href="{{ title.get_absolute_url }}">{{ title }}</a>
{{ entry|render_language_choices:request|safe }}
</p>
{% render_placeholder excerpt %}
{% endwith %}
{% endwith %}
{% empty %}
{% load i18n %}
{% if object_list %}
{% include "cmsplugin_blog/entry_list_include.html" %}
{% else %}
<p>{% trans "No entries" %}</p>
{% endfor %}
{% endif %}
Loading

0 comments on commit 6b0b5f7

Please sign in to comment.