Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Say hello to KB discussion. [bug 602958]
Browse files Browse the repository at this point in the history
Adds a `kbforums` app, which is a clone of the `forums` app with a few
tweaks:

* The top-level `Forum` model is replaced by `wiki.models.Document`.
* The permissions have been simplified. There are no per-document forum
  permissions.
* The `Document` does not track its `last_post`.
* `Post.author` has been renamed to `Post.creator` following our ad hoc
  standard.
* The ability to override `Post.created` and `Post.updated`, only used
  in the data migration, is gone.
* Moving threads is gone. This needs more thought, and moving to the
  `forums` app is non-trivial.
  • Loading branch information
James Socol committed Oct 20, 2010
1 parent 07193c4 commit 4aa9140
Show file tree
Hide file tree
Showing 28 changed files with 2,664 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apps/kbforums/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The number of threads per page.
THREADS_PER_PAGE = 20

# The number of posts per page.
POSTS_PER_PAGE = 20
72 changes: 72 additions & 0 deletions apps/kbforums/feeds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from django.utils.feedgenerator import Atom1Feed
from django.utils.html import strip_tags, escape

from tower import ugettext as _

import forums as constants
from kbforums.models import Thread
from wiki.models import Document


class ThreadsFeed(Feed):
feed_type = Atom1Feed

def get_object(self, request, document_slug):
return get_object_or_404(Document,
slug=document_slug,
locale=request.locale)

def title(self, document):
return _('Recently updated threads about %s') % document.title

def link(self, document):
return document.get_absolute_url()

def items(self, document):
return document.thread_set.order_by(
'-last_post__created')[:constants.THREADS_PER_PAGE]

def item_title(self, item):
return item.title

def item_author_name(self, item):
return item.creator

def item_pubdate(self, item):
return item.created


class PostsFeed(Feed):
feed_type = Atom1Feed

def get_object(self, request, document_slug, thread_id):
doc = get_object_or_404(Document,
slug=document_slug,
locale=request.locale)
return get_object_or_404(Thread, pk=thread_id, document=doc)

def title(self, thread):
return _('Recent posts in %s') % thread.title

def link(self, thread):
return thread.get_absolute_url()

def description(self, thread):
return self.title(thread)

def items(self, thread):
return thread.post_set.order_by('-created')

def item_title(self, item):
return strip_tags(item.content_parsed)[:100]

def item_description(self, item):
return escape(item.content_parsed)

def item_author_name(self, item):
return item.creator

def item_pubdate(self, item):
return item.created
Loading

0 comments on commit 4aa9140

Please sign in to comment.