From 1ea700b294025e118fa3c48c0fbf2b63dc106597 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 13 Mar 2012 00:31:43 +0100 Subject: Add simple comments --- .../0002_auto__chg_field_post_post_id.py | 49 ++++++++++++++++++++++ settings.py | 6 ++- static/comments.css | 16 +++++++ templates/aggregator/base.html | 1 + templates/aggregator/post_detail.html | 12 ++++++ urls.py | 5 ++- 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 aggregator/migrations/0002_auto__chg_field_post_post_id.py create mode 100644 static/comments.css diff --git a/aggregator/migrations/0002_auto__chg_field_post_post_id.py b/aggregator/migrations/0002_auto__chg_field_post_post_id.py new file mode 100644 index 0000000..906ed2d --- /dev/null +++ b/aggregator/migrations/0002_auto__chg_field_post_post_id.py @@ -0,0 +1,49 @@ +# 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): + + # Changing field 'Post.post_id' + db.alter_column('aggregator_post', 'post_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)) + + + def backwards(self, orm): + + # Changing field 'Post.post_id' + db.alter_column('aggregator_post', 'post_id', self.gf('django.db.models.fields.CharField')(max_length=500, unique=True)) + + + models = { + 'aggregator.feed': { + 'Meta': {'ordering': "['-updated']", 'object_name': 'Feed'}, + 'base_url': ('django.db.models.fields.URLField', [], {'max_length': '255'}), + 'br2nl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'favicon_ext': ('django.db.models.fields.CharField', [], {'default': "'png'", 'max_length': '4'}), + 'feed_url': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'profile_url': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '500', 'blank': 'True'}), + 'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'uses_title': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'with_markdown': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'aggregator.post': { + 'Meta': {'ordering': "['-updated']", 'object_name': 'Post'}, + 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'body': ('django.db.models.fields.TextField', [], {}), + 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['aggregator.Feed']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'post_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'remote_url': ('django.db.models.fields.URLField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'updated': ('django.db.models.fields.DateTimeField', [], {}) + } + } + + complete_apps = ['aggregator'] diff --git a/settings.py b/settings.py index 2c1a9bc..12ebdc5 100644 --- a/settings.py +++ b/settings.py @@ -111,7 +111,11 @@ TEMPLATE_DIRS = ( '%s/templates' % DEPLOY_PATH, ) -INSTALLED_APPS = ('aggregator', +INSTALLED_APPS = ('django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.comments', + 'django.contrib.staticfiles', + 'aggregator', 'south') # A sample logging configuration. The only tangible logging diff --git a/static/comments.css b/static/comments.css new file mode 100644 index 0000000..b136c15 --- /dev/null +++ b/static/comments.css @@ -0,0 +1,16 @@ +#comments, form { + background-color: #808080; + padding: 5px; + border: 1px #505050 solid; + margin-bottom: 15px; + color: #000000; +} + +#comments dd { + margin-left: 40px; + margin-bottom: 15px; +} + +form label { + display: block; +} diff --git a/templates/aggregator/base.html b/templates/aggregator/base.html index 1f3ec37..6a37f5a 100644 --- a/templates/aggregator/base.html +++ b/templates/aggregator/base.html @@ -5,6 +5,7 @@ ryuslash + {% block head %}{% endblock %} diff --git a/templates/aggregator/post_detail.html b/templates/aggregator/post_detail.html index eb39f95..574d9b1 100644 --- a/templates/aggregator/post_detail.html +++ b/templates/aggregator/post_detail.html @@ -1,8 +1,20 @@ {% extends "aggregator/base.html" %} +{% load comments %} + +{% block head %} + +{% endblock %} {% block content %} {% include "aggregator/post_content.html" with post=object %} +{% get_comment_count for object as comment_count %} +{% if comment_count > 0 %} + {% render_comment_list for object %} +{% endif %} + +{% render_comment_form for object %} +
{% with next=object.get_next_by_updated previous=object.get_previous_by_updated %} {% if previous %} diff --git a/urls.py b/urls.py index c42fbb6..af2a313 100644 --- a/urls.py +++ b/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls.defaults import patterns, url, include from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.generic import DetailView @@ -8,6 +8,7 @@ from aggregator.feeds import LatestPostsFeed urlpatterns = patterns('', url(r'^((?P\d+)/)?$', 'aggregator.views.posts'), url(r'^post/((?P\d+)/)?$', DetailView.as_view(model=Post)), - url(r'^feed/posts/$', LatestPostsFeed())) + url(r'^feed/posts/$', LatestPostsFeed()), + url(r'^comments/', include('django.contrib.comments.urls'))) urlpatterns += staticfiles_urlpatterns() -- cgit v1.2.3-54-g00ecf