Changeset 43:544f3cf6a4f0
- Timestamp:
- 08/31/08 16:07:55 (3 months ago)
- Author:
- Jeffrey Gelens <jeffrey@…>
- Branch:
- default
- Message:
-
Upgraded source to work with Django Trunk (soon 1.0)
- Files:
-
- 1 added
- 1 removed
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
|
r38
|
r43
|
|
| 12 | 12 | }) |
| 13 | 13 | ) |
| 14 | | list_display = ('title', 'pub_date', 'comments') |
| | 14 | list_display = ('title', 'pub_date') |
| 15 | 15 | list_filter = ('topic', 'pub_date') |
| 16 | 16 | search_fields = ('title','body') |
-
|
r26
|
r43
|
|
| 5 | 5 | from blog.models import Article |
| 6 | 6 | from django.contrib.contenttypes.models import ContentType |
| 7 | | from django.contrib.comments.models import FreeComment |
| | 7 | from django.contrib.comments.models import Comment |
| 8 | 8 | |
| 9 | 9 | JST = tzinfo.FixedOffset(540) |
| … |
… |
|
| 60 | 60 | def items(self): |
| 61 | 61 | article_type = ContentType.objects.get(app_label="blog", model="article") |
| 62 | | comments = FreeComment.objects \ |
| | 62 | comments = Comment.objects \ |
| 63 | 63 | .filter(content_type=article_type, is_public=True) \ |
| 64 | 64 | .order_by("-submit_date")[:10] |
-
|
r38
|
r43
|
|
| 11 | 11 | |
| 12 | 12 | class Link(models.Model): |
| 13 | | name = models.CharField(max_length=50, core=True) |
| | 13 | name = models.CharField(max_length=50) |
| 14 | 14 | url = models.URLField() |
| 15 | 15 | kind = models.CharField(max_length=1, choices=LINK_CHOICES) |
| … |
… |
|
| 35 | 35 | get_latest_by = 'pub_date' |
| 36 | 36 | |
| 37 | | def comments(self): |
| 38 | | from django.contrib.contenttypes.models import ContentType |
| 39 | | from django.contrib.comments.models import FreeComment |
| 40 | | from django.utils.html import escape |
| | 37 | #def comments(self): |
| | 38 | # from django.contrib.contenttypes.models import ContentType |
| | 39 | # from django.contrib.comments.models import Comment |
| | 40 | # from django.utils.html import escape |
| 41 | 41 | |
| 42 | | content_type = ContentType.objects.get(app_label__exact="blog",model__exact="article") |
| 43 | | comments = FreeComment.objects.filter(content_type__exact=content_type.id, object_id__exact=self.id) |
| 44 | | links = [] |
| | 42 | # content_type = ContentType.objects.get(app_label__exact="blog",model__exact="article") |
| | 43 | # comments = Comment.objects.filter(content_type__exact=content_type.id, object_id__exact=self.id) |
| | 44 | # links = [] |
| 45 | 45 | |
| 46 | | for comment in comments: |
| 47 | | if len(links) > 4: |
| 48 | | break |
| 49 | | else: |
| 50 | | links.append('<a href="/admin/comments/freecomment/%s">%s</a>' % \ |
| 51 | | (comment.id, escape(comment.person_name))) |
| | 46 | # for comment in comments: |
| | 47 | # if len(links) > 4: |
| | 48 | # break |
| | 49 | # else: |
| | 50 | # links.append('<a href="/admin/comments/freecomment/%s">%s</a>' % \ |
| | 51 | # (comment.id, escape(comment.person_name))) |
| 52 | 52 | |
| 53 | | return '<br />'.join(links) |
| 54 | | comments.allow_tags = True |
| | 53 | # return '<br />'.join(links) |
| | 54 | #comments.allow_tags = True |
| 55 | 55 | |
| 56 | 56 | def comments_open(self): |
-
|
r38
|
r43
|
|
| 1 | 1 | from django.conf import settings |
| 2 | 2 | from django.db.models import signals |
| 3 | | from django.contrib.comments.models import FreeComment |
| | 3 | from django.contrib.comments.models import Comment |
| 4 | 4 | from django.contrib.sites.models import Site |
| 5 | 5 | from django.contrib.flatpages.models import FlatPage |
| … |
… |
|
| 46 | 46 | instance.is_public = False |
| 47 | 47 | |
| 48 | | signals.post_save.connect(moderate_comments, sender=FreeComment) |
| | 48 | signals.post_save.connect(moderate_comments, sender=Comment) |
-
|
r20
|
r43
|
|
| 1 | 1 | from django import template |
| 2 | 2 | from blog.models import Link |
| 3 | | from django.contrib.comments.models import FreeComment |
| | 3 | from django.contrib.comments.models import Comment |
| 4 | 4 | from django.contrib.contenttypes.models import ContentType |
| 5 | 5 | |
| … |
… |
|
| 14 | 14 | def latest_comments(): |
| 15 | 15 | article_type = ContentType.objects.get(app_label="blog", model="article") |
| 16 | | latest_comments = FreeComment.objects \ |
| | 16 | latest_comments = Comment.objects \ |
| 17 | 17 | .filter(content_type=article_type, is_public=True) \ |
| 18 | 18 | .order_by("-submit_date")[:5] |
-
|
r25
|
r43
|
|
| 8 | 8 | <h1 style="text-align: left;">{{ month|date:"F y" }} Archives</h1> |
| 9 | 9 | {% for article in articles %} |
| 10 | | {% get_free_comment_count for blog.article article.id as comment_count %} |
| | 10 | {% get_comment_count for blog.article article.id as comment_count %} |
| 11 | 11 | <div class="article-head"><h2><a href="{{ article.get_absolute_url }}">{{ article.title }}</a></h2></div> |
| 12 | 12 | <div class="article-date"> |
-
|
r38
|
r43
|
|
| 30 | 30 | <hr /> |
| 31 | 31 | {% for article in articles %} |
| 32 | | {% get_free_comment_count for blog.article article.id as comment_count %} |
| | 32 | {% get_comment_count for blog.article article.id as comment_count %} |
| 33 | 33 | <div class="hentry article"> |
| 34 | 34 | <abbr class="published" title="{{ article.pub_date|date:"Y-m-d\Th:i:sO" }}">{{ article.pub_date|naturalday|capfirst }}, </abbr> |
-
|
r38
|
r43
|
|
| 24 | 24 | </div> |
| 25 | 25 | |
| 26 | | {% get_free_comment_list for blog.article article.id as comment_list %} |
| | 26 | {% get_comment_list for blog.article article.id as comment_list %} |
| 27 | 27 | |
| 28 | 28 | <div class="article"> |
| 29 | 29 | {% for comment in comment_list %} |
| 30 | 30 | {% if comment.is_public %} |
| 31 | | <h2 class="comment-title" id="c{{ comment.id }}">{{ comment.person_name }}</h2> |
| | 31 | <h2 class="comment-title" id="c{{ comment.id }}">{{ comment.name }}</h2> |
| 32 | 32 | <span class="comment-published">said {{ comment.submit_date|naturalday }}:</span> |
| 33 | 33 | {{ comment.comment|textile }} |
| … |
… |
|
| 43 | 43 | </div> |
| 44 | 44 | <br /><br /> |
| 45 | | {% free_comment_form for blog.article article.id %} |
| | 45 | {% render_comment_form for blog.article article.id %} |
| 46 | 46 | {% endif %} |
| 47 | 47 | </div> |
-
|
r37
|
r43
|
|
| 6 | 6 | urlpatterns = patterns('', |
| 7 | 7 | (r'^admin/(.*)', admin.site.root), |
| 8 | | (r'^comments/', include('django.contrib.comments.urls.comments')), |
| | 8 | (r'^comments/', include('django.contrib.comments.urls')), |
| 9 | 9 | (r'^', include('blog.urls')), |
| 10 | 10 | ) |