gmh04 avatar gmh04 committed 904d252 Merge

merge with genbit fork

Comments (0)

Files changed (25)

__init__.py

-from forms import CommentFormWithCaptcha 
-
-def get_form():
-    return CommentFormWithCaptcha

admin.py

-from models import Discussion
-from django.contrib import admin
-
-class DiscussionAdmin(admin.ModelAdmin):
-    pass
-
-admin.site.register(Discussion, DiscussionAdmin)

cms_plugins.py

-from cms.plugin_base import CMSPluginBase
-from cms.plugin_pool import plugin_pool
-from models import DiscussionPlugin, Discussion
-from django.utils.translation import ugettext as _
-from django.contrib.comments.models import Comment
-from django.contrib.contenttypes.models import ContentType
-
-class CMSDiscussionPlugin(CMSPluginBase):
-        model = DiscussionPlugin
-        name = _("Comments")
-        render_template = "comments/list.html"
-
-        def render(self, context, instance, placeholder):
-            
-            comments = Comment.objects.filter (
-                content_type=ContentType.objects.get_for_model(Discussion),
-                object_pk = instance.discussion.id)
-            
-            context.update({'instance':instance.discussion,
-                            'placeholder':placeholder,
-                            'comments':comments})
-            return context
-
-plugin_pool.register_plugin(CMSDiscussionPlugin)

cmsplugin_comments/__init__.py

+from forms import CommentFormWithCaptcha 
+
+def get_form():
+    return CommentFormWithCaptcha

cmsplugin_comments/admin.py

+from models import Discussion
+from django.contrib import admin
+
+class DiscussionAdmin(admin.ModelAdmin):
+    pass
+
+admin.site.register(Discussion, DiscussionAdmin)

cmsplugin_comments/cms_plugins.py

+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from models import DiscussionPlugin, Discussion
+from django.utils.translation import ugettext as _
+from django.contrib.comments.models import Comment
+from django.contrib.contenttypes.models import ContentType
+
+class CMSDiscussionPlugin(CMSPluginBase):
+        model = DiscussionPlugin
+        name = _("Comments")
+        render_template = "comments/list.html"
+
+        def render(self, context, instance, placeholder):
+            
+            comments = Comment.objects.filter (
+                content_type=ContentType.objects.get_for_model(Discussion),
+                object_pk = instance.discussion.id)
+            
+            context.update({'instance':instance.discussion,
+                            'placeholder':placeholder,
+                            'comments':comments})
+            return context
+
+plugin_pool.register_plugin(CMSDiscussionPlugin)

cmsplugin_comments/forms.py

+from django import forms
+from django.contrib.comments.forms import CommentForm
+from captcha.fields import CaptchaField
+from django.utils.translation import ugettext as _
+
+class CommentFormWithCaptcha(CommentForm):
+    captcha = CaptchaField()
+
+    def get_comment_create_data(self):
+        return super(CommentFormWithCaptcha, self).get_comment_create_data()

cmsplugin_comments/migrations/0001_init.py

+
+from south.db import db
+from django.db import models
+from cmsplugin_comments.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        # Adding model 'DiscussionPlugin'
+        db.create_table('cmsplugin_discussionplugin', (
+            ('cmsplugin_ptr', orm['cmsplugin_comments.DiscussionPlugin:cmsplugin_ptr']),
+            ('discussion', orm['cmsplugin_comments.DiscussionPlugin:discussion']),
+        ))
+        db.send_create_signal('cmsplugin_comments', ['DiscussionPlugin'])
+        
+        # Adding model 'Discussion'
+        db.create_table('cmsplugin_comments_discussion', (
+            ('id', orm['cmsplugin_comments.Discussion:id']),
+            ('title', orm['cmsplugin_comments.Discussion:title']),
+        ))
+        db.send_create_signal('cmsplugin_comments', ['Discussion'])
+        
+    
+    
+    def backwards(self, orm):
+        
+        # Deleting model 'DiscussionPlugin'
+        db.delete_table('cmsplugin_discussionplugin')
+        
+        # Deleting model 'Discussion'
+        db.delete_table('cmsplugin_comments_discussion')
+        
+    
+    
+    models = {
+        'cms.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': '5', 'db_index': 'True'}),
+            'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']"}),
+            'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
+            'placeholder': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+            'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+            'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.CMSPlugin']"}),
+            'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}),
+            'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'cms.page': {
+            'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+            'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+            'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'menu_login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'moderator_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'blank': 'True'}),
+            'navigation_extenders': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
+            'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['cms.Page']"}),
+            'publication_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+            'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.Page']"}),
+            'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}),
+            'reverse_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}),
+            'soft_root': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
+            'template': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'cmsplugin_comments.discussion': {
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'cmsplugin_comments.discussionplugin': {
+            'Meta': {'db_table': "'cmsplugin_discussionplugin'"},
+            'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+            'discussion': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_comments.Discussion']"})
+        },
+        'sites.site': {
+            'Meta': {'db_table': "'django_site'"},
+            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+    
+    complete_apps = ['cmsplugin_comments']

cmsplugin_comments/migrations/0002_auto__add_field_discussion_enable_comments.py

+# 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 'Discussion.enable_comments'
+        db.add_column('cmsplugin_comments_discussion', 'enable_comments', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Discussion.enable_comments'
+        db.delete_column('cmsplugin_comments_discussion', 'enable_comments')
+
+
+    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_comments.discussion': {
+            'Meta': {'object_name': 'Discussion'},
+            'enable_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'cmsplugin_comments.discussionplugin': {
+            'Meta': {'object_name': 'DiscussionPlugin', 'db_table': "'cmsplugin_discussionplugin'", '_ormbases': ['cms.CMSPlugin']},
+            'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+            'discussion': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_comments.Discussion']"})
+        }
+    }
+
+    complete_apps = ['cmsplugin_comments']
Add a comment to this file

cmsplugin_comments/migrations/__init__.py

Empty file added.

cmsplugin_comments/models.py

+from django.contrib.comments.moderation import CommentModerator, moderator
+from django.db import models
+from django.utils.translation import ugettext as _
+from cms.models import CMSPlugin
+
+class Discussion (models.Model):
+    title = models.CharField(_('Title'), max_length=128)
+    enable_comments = models.BooleanField(default=True)
+
+    def __unicode__(self):
+        return self.title
+
+class DiscussionPlugin(CMSPlugin):
+    discussion = models.ForeignKey(Discussion)
+
+class EntryModerator(CommentModerator):
+    """
+    email admins when comment is inserted
+    """
+    email_notification = True
+    enable_field = 'enable_comments'
+
+moderator.register(Discussion, EntryModerator)

cmsplugin_comments/templates/comments/form.html

+{% load comments i18n %}
+<form action="{% comment_form_target %}" method="post">
+  {% for field in form %}
+    {% if field.is_hidden %}
+      {{ field }}
+    {% else %}
+      <div
+        {% if field.errors %} class="error"{% endif %}
+        {% ifequal field.name "honeypot" %} class="honeypot"{% endifequal %}>
+        {% if field.errors %}{{ field.errors }}{% endif %}
+        {{ field.label_tag }} {{ field }}
+      </div>
+    {% endif %}
+  {% endfor %}
+  <p class="submit">
+    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+  </p>
+</form>

cmsplugin_comments/templates/comments/list.html

+{% load comments %}
+<div id="substance">
+<div class="comments-list">
+{% for comment in comments %}
+    <div class="comment">
+        <div class="username">{{ comment.user_name}} ({{ comment.submit_date|date:"d M Y" }})</div>
+        <p>{{comment.comment}}</p>
+    </div>
+{% endfor %}
+</div>
+</div>
+<span id="form-ctl" onclick="$('#form').toggle();">Добавить коментарий</span>
+
+<div id="form" style="display: none;">
+    {% render_comment_form for instance %}
+<div>

cmsplugin_comments/templates/comments/posted.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+<h2> Спасибо за ваш комментарий! </h2>
+
+{% endblock %}

cmsplugin_comments/templates/comments/preview.html

+{% extends "base.html" %}
+{% load i18n %}
+
+
+{% block content %}
+  {% load comments %}
+  <form action="{% comment_form_target %}" method="post">
+    {% if form.errors %}
+	<h3>Пожалуйста, исправьте ошибки ({{form.errors|length}}) указанные ниже:</h3>
+    {% else %}
+    <p><b>{% trans "Preview your comment" %}</b></p>
+      <blockquote>{{ comment|linebreaks }}</blockquote>
+      <p>
+      {% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
+      </p>
+    {% endif %}
+    {% for field in form %}
+      {% if field.is_hidden %}
+        {{ field }}
+      {% else %}
+        <div
+          {% if field.errors %} class="error"{% endif %}
+          {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+          {% if field.errors %}{{ field.errors }}{% endif %}
+          {{ field.label_tag }} {{ field }}
+        </div>
+      {% endif %}
+    {% endfor %}
+    <p class="submit">
+    <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+    </p>
+  </form>
+{% endblock %}

forms.py

-from django import forms
-from django.contrib.comments.forms import CommentForm
-from captcha.fields import CaptchaField
-from django.utils.translation import ugettext as _
-
-class CommentFormWithCaptcha(CommentForm):
-    captcha = CaptchaField()
-
-    def get_comment_create_data(self):
-        return super(CommentFormWithCaptcha, self).get_comment_create_data()

migrations/0001_init.py

-
-from south.db import db
-from django.db import models
-from cmsplugin_comments.models import *
-
-class Migration:
-    
-    def forwards(self, orm):
-        
-        # Adding model 'DiscussionPlugin'
-        db.create_table('cmsplugin_discussionplugin', (
-            ('cmsplugin_ptr', orm['cmsplugin_comments.DiscussionPlugin:cmsplugin_ptr']),
-            ('discussion', orm['cmsplugin_comments.DiscussionPlugin:discussion']),
-        ))
-        db.send_create_signal('cmsplugin_comments', ['DiscussionPlugin'])
-        
-        # Adding model 'Discussion'
-        db.create_table('cmsplugin_comments_discussion', (
-            ('id', orm['cmsplugin_comments.Discussion:id']),
-            ('title', orm['cmsplugin_comments.Discussion:title']),
-        ))
-        db.send_create_signal('cmsplugin_comments', ['Discussion'])
-        
-    
-    
-    def backwards(self, orm):
-        
-        # Deleting model 'DiscussionPlugin'
-        db.delete_table('cmsplugin_discussionplugin')
-        
-        # Deleting model 'Discussion'
-        db.delete_table('cmsplugin_comments_discussion')
-        
-    
-    
-    models = {
-        'cms.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': '5', 'db_index': 'True'}),
-            'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']"}),
-            'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
-            'placeholder': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
-            'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
-            'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
-            'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
-            'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.CMSPlugin']"}),
-            'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}),
-            'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
-        },
-        'cms.page': {
-            'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
-            'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
-            'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
-            'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
-            'menu_login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
-            'moderator_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'blank': 'True'}),
-            'navigation_extenders': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
-            'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['cms.Page']"}),
-            'publication_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
-            'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
-            'published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
-            'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
-            'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.Page']"}),
-            'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}),
-            'reverse_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'null': 'True', 'blank': 'True'}),
-            'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
-            'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}),
-            'soft_root': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
-            'template': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
-            'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
-        },
-        'cmsplugin_comments.discussion': {
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
-        },
-        'cmsplugin_comments.discussionplugin': {
-            'Meta': {'db_table': "'cmsplugin_discussionplugin'"},
-            'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
-            'discussion': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_comments.Discussion']"})
-        },
-        'sites.site': {
-            'Meta': {'db_table': "'django_site'"},
-            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
-        }
-    }
-    
-    complete_apps = ['cmsplugin_comments']

migrations/0002_auto__add_field_discussion_enable_comments.py

-# 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 'Discussion.enable_comments'
-        db.add_column('cmsplugin_comments_discussion', 'enable_comments', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False)
-
-
-    def backwards(self, orm):
-        
-        # Deleting field 'Discussion.enable_comments'
-        db.delete_column('cmsplugin_comments_discussion', 'enable_comments')
-
-
-    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_comments.discussion': {
-            'Meta': {'object_name': 'Discussion'},
-            'enable_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
-        },
-        'cmsplugin_comments.discussionplugin': {
-            'Meta': {'object_name': 'DiscussionPlugin', 'db_table': "'cmsplugin_discussionplugin'", '_ormbases': ['cms.CMSPlugin']},
-            'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
-            'discussion': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_comments.Discussion']"})
-        }
-    }
-
-    complete_apps = ['cmsplugin_comments']
Add a comment to this file

migrations/__init__.py

Empty file removed.

models.py

-from django.contrib.comments.moderation import CommentModerator, moderator
-from django.db import models
-from django.utils.translation import ugettext as _
-from cms.models import CMSPlugin
-
-class Discussion (models.Model):
-    title = models.CharField(_('Title'), max_length=128)
-    enable_comments = models.BooleanField(default=True)
-
-    def __unicode__(self):
-        return self.title
-
-class DiscussionPlugin(CMSPlugin):
-    discussion = models.ForeignKey(Discussion)
-
-class EntryModerator(CommentModerator):
-    """
-    email admins when comment is inserted
-    """
-    email_notification = True
-    enable_field = 'enable_comments'
-
-moderator.register(Discussion, EntryModerator)
+from setuptools import setup, find_packages
+setup(
+    name='cmsplugin_comments',
+    version= '0.1',
+    description='A very simple plugin for django-cms 2 to implement comments',
+    author='X',
+    author_email='X',
+    url='http://bitbucket.org/genbit/cmsplugin_comments',
+    license='MIT',
+    packages=find_packages(),
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: MIT License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Security',
+        'Topic :: Internet :: WWW/HTTP',
+        'Framework :: Django',
+    ],
+    include_package_data=True,
+    zip_safe=False,
+    install_requires=['setuptools'],
+    requires= ['captcha']
+)

templates/comments/form.html

-{% load comments i18n %}
-<form action="{% comment_form_target %}" method="post">
-  {% for field in form %}
-    {% if field.is_hidden %}
-      {{ field }}
-    {% else %}
-      <div
-        {% if field.errors %} class="error"{% endif %}
-        {% ifequal field.name "honeypot" %} class="honeypot"{% endifequal %}>
-        {% if field.errors %}{{ field.errors }}{% endif %}
-        {{ field.label_tag }} {{ field }}
-      </div>
-    {% endif %}
-  {% endfor %}
-  <p class="submit">
-    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
-    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
-  </p>
-</form>

templates/comments/list.html

-{% load comments %}
-<div id="substance">
-<div class="comments-list">
-{% for comment in comments %}
-    <div class="comment">
-        <div class="username">{{ comment.user_name}} ({{ comment.submit_date|date:"d M Y" }})</div>
-        <p>{{comment.comment}}</p>
-    </div>
-{% endfor %}
-</div>
-</div>
-<span id="form-ctl" onclick="$('#form').toggle();">Добавить коментарий</span>
-
-<div id="form" style="display: none;">
-    {% render_comment_form for instance %}
-<div>

templates/comments/posted.html

-{% extends "base.html" %}
-{% load i18n %}
-
-{% block content %}
-
-<h2> Спасибо за ваш комментарий! </h2>
-
-{% endblock %}

templates/comments/preview.html

-{% extends "base.html" %}
-{% load i18n %}
-
-
-{% block content %}
-  {% load comments %}
-  <form action="{% comment_form_target %}" method="post">
-    {% if form.errors %}
-	<h3>Пожалуйста, исправьте ошибки ({{form.errors|length}}) указанные ниже:</h3>
-    {% else %}
-    <p><b>{% trans "Preview your comment" %}</b></p>
-      <blockquote>{{ comment|linebreaks }}</blockquote>
-      <p>
-      {% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
-      </p>
-    {% endif %}
-    {% for field in form %}
-      {% if field.is_hidden %}
-        {{ field }}
-      {% else %}
-        <div
-          {% if field.errors %} class="error"{% endif %}
-          {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
-          {% if field.errors %}{{ field.errors }}{% endif %}
-          {{ field.label_tag }} {{ field }}
-        </div>
-      {% endif %}
-    {% endfor %}
-    <p class="submit">
-    <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
-    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
-    </p>
-  </form>
-{% endblock %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.