Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit f55e135d9a08355494dbb78a6857e5d4d4e1a29f @Azd325 Azd325 committed Jul 18, 2012
@@ -0,0 +1,4 @@
+*.pyc
+build
+*.egg-info
+dist
27 LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2012, Tesobe
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. 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.
+3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement:
+ This product includes software developed by the Tesobe.
+4. Neither the name of the Tesobe 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 Tesobe ''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 Tesobe 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.
@@ -0,0 +1,4 @@
+include LICENSE
+include README.md
+include MANIFEST.in
+recursive-include cmsplugin_eviscape/templates *
No changes.
No changes.
@@ -0,0 +1,2 @@
+VERSION = (0, 8, 0)
+__version__ = "0.8.0"
@@ -0,0 +1,19 @@
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from models import EviscapeInstance
+from views import get_sent_evis
+from django.utils.translation import ugettext_lazy as _
+
+
+class EviscapePlugin(CMSPluginBase):
+ model = EviscapeInstance
+ name = _("Eviscape Plugin")
+ render_template = "cmsplugin_eviscape/eviscape_plugin.html"
+
+ def render(self, context, instance, placeholder):
+ extra_context = {'evis': get_sent_evis(instance.server, instance.nod_id, instance.limit, instance.evis_type),
+ 'title': instance.title}
+ context.update(extra_context)
+ return context
+
+plugin_pool.register_plugin(EviscapePlugin)
@@ -0,0 +1,54 @@
+# -*- coding: 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 model 'EviscapeInstance'
+ db.create_table('cmsplugin_eviscapeinstance', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('server', self.gf('django.db.models.fields.CharField')(default='api.eviscape.com', max_length=100)),
+ ('nod_id', self.gf('django.db.models.fields.PositiveIntegerField')()),
+ ))
+ db.send_create_signal('cmsplugin_eviscape', ['EviscapeInstance'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'EviscapeInstance'
+ db.delete_table('cmsplugin_eviscapeinstance')
+
+
+ models = {
+ '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_eviscape.eviscapeinstance': {
+ 'Meta': {'object_name': 'EviscapeInstance', 'db_table': "'cmsplugin_eviscapeinstance'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'nod_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'server': ('django.db.models.fields.CharField', [], {'default': "'api.eviscape.com'", 'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_eviscape']
@@ -0,0 +1,52 @@
+# -*- coding: 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 'EviscapeInstance.evis_type'
+ db.add_column('cmsplugin_eviscapeinstance', 'evis_type',
+ self.gf('django.db.models.fields.CharField')(default='blog', max_length=20),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'EviscapeInstance.evis_type'
+ db.delete_column('cmsplugin_eviscapeinstance', 'evis_type')
+
+
+ models = {
+ '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_eviscape.eviscapeinstance': {
+ 'Meta': {'object_name': 'EviscapeInstance', 'db_table': "'cmsplugin_eviscapeinstance'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'evis_type': ('django.db.models.fields.CharField', [], {'default': "'blog'", 'max_length': '20'}),
+ 'nod_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'server': ('django.db.models.fields.CharField', [], {'default': "'api.eviscape.com'", 'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_eviscape']
@@ -0,0 +1,53 @@
+# -*- coding: 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 'EviscapeInstance.limit'
+ db.add_column('cmsplugin_eviscapeinstance', 'limit',
+ self.gf('django.db.models.fields.PositiveIntegerField')(default=5),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'EviscapeInstance.limit'
+ db.delete_column('cmsplugin_eviscapeinstance', 'limit')
+
+
+ models = {
+ '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_eviscape.eviscapeinstance': {
+ 'Meta': {'object_name': 'EviscapeInstance', 'db_table': "'cmsplugin_eviscapeinstance'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'evis_type': ('django.db.models.fields.CharField', [], {'default': "'blog'", 'max_length': '20'}),
+ 'limit': ('django.db.models.fields.PositiveIntegerField', [], {'default': '5'}),
+ 'nod_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'server': ('django.db.models.fields.CharField', [], {'default': "'api.eviscape.com'", 'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_eviscape']
@@ -0,0 +1,54 @@
+# -*- coding: 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 'EviscapeInstance.title'
+ db.add_column('cmsplugin_eviscapeinstance', 'title',
+ self.gf('django.db.models.fields.CharField')(default='Blog', max_length=30),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'EviscapeInstance.title'
+ db.delete_column('cmsplugin_eviscapeinstance', 'title')
+
+
+ models = {
+ '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_eviscape.eviscapeinstance': {
+ 'Meta': {'object_name': 'EviscapeInstance', 'db_table': "'cmsplugin_eviscapeinstance'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'evis_type': ('django.db.models.fields.CharField', [], {'default': "'blog'", 'max_length': '20'}),
+ 'limit': ('django.db.models.fields.PositiveIntegerField', [], {'default': '5'}),
+ 'nod_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'server': ('django.db.models.fields.CharField', [], {'default': "'api.eviscape.com'", 'max_length': '100'}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "'Blog'", 'max_length': '30'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_eviscape']
No changes.
@@ -0,0 +1,11 @@
+from cms.models.pluginmodel import CMSPlugin
+
+from django.db import models
+
+
+class EviscapeInstance(CMSPlugin):
+ server = models.CharField(max_length=100, default='api.eviscape.com')
+ nod_id = models.PositiveIntegerField()
+ evis_type = models.CharField(max_length=20, default='blog', blank=True)
+ limit = models.PositiveIntegerField(default=5)
+ title = models.CharField(max_length=30, default='Blog', blank=True)
@@ -0,0 +1,10 @@
+{% if title %}
+ <h3 class="title">{{ title }}</h3>
+{% endif %}
+{% for item in evis %}
+ <div class="entry">
+ <div class="date">{{item.evis.evi_insert_date}}</div>
+ <h6><a target="_blank" href="{{item.ref}}">{{item.evis.evi_subject|striptags}}</a></h6>
+ {{item.evis.evi_body|striptags|truncatewords:20}}
+ </div>
+{% endfor %}
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
@@ -0,0 +1,27 @@
+import urllib2
+import json
+
+
+def get_sent_evis(server, nod_id, limit, evis_type):
+ """(Currently) returns a list of dictionaries with keys evis, ref and id.
+ Returns an empty list in case it could not fetch the data from eviscape."""
+
+ json_url = "http://%s/api/1.0/rest/?method=evis.sent&format=json&jsoncallback=?&nod_id=%s&per_page=%s" % (server, nod_id, limit)
+
+ # quick and dirty
+ try:
+ socket_file_obj = urllib2.urlopen(json_url)
+ # for the case we cannot get access to eviscape data
+ except urllib2.URLError, e:
+ print e
+ print 'ERROR in get_sent_evis'
+ return []
+
+ data = socket_file_obj.read()
+ # strip parentheses because jsoncallback=?, otherwise there would be a jsonEviscapeApi(...)
+ data = data.strip('()')
+ data = json.loads(data)
+
+ sent_evis = [e for e in data['objects'] if e['evis']['typ_value'] == evis_type]
+ print sent_evis
+ return sent_evis
@@ -0,0 +1,37 @@
+from setuptools import setup, find_packages
+
+version = __import__('cmsplugin_eviscape').__version__
+
+install_requires = [
+ 'setuptools',
+ 'django',
+ 'django-cms',
+]
+
+setup(
+ name = "cmsplugin_eviscape",
+ version = version,
+ url = '',
+ license = 'BSD',
+ platforms=['OS Independent'],
+ description = "An evsicape extension for Django CMS",
+ author = "Tim Kleinschmidt",
+ author_email = 'tim@tesobe.com',
+ packages=find_packages(),
+ install_requires = install_requires,
+ include_package_data=True,
+ zip_safe=False,
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+ ],
+ package_dir={
+ 'cmsplugin_eviscape': 'cmsplugin_eviscape',
+ },
+)

0 comments on commit f55e135

Please sign in to comment.