Commits

limpbrains committed c64f6a7

initial commit

Comments (0)

Files changed (12)

+syntax: glob
+*.orig
+.svn
+*.pyc
+*.db
+*.kpf
+env
+build
+settings_local.py
+*~
+from forms import CommentFormWithCaptcha 
+
+def get_form():
+    return CommentFormWithCaptcha
+from models import Discussion
+from django.contrib import admin
+
+class DiscussionAdmin(admin.ModelAdmin):
+    pass
+
+admin.site.register(Discussion, DiscussionAdmin)
+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)
+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']

Empty file added.

+from django.contrib.comments.models import Comment
+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)
+
+    def __unicode__(self):
+        return self.title
+
+class DiscussionPlugin(CMSPlugin):
+    discussion = models.ForeignKey(Discussion)

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.