def threads(request, document_slug): """View all the threads in a discussion forum.""" doc = get_document(document_slug, request) try: sort = int(request.GET.get('sort', 0)) except ValueError: sort = 0 try: desc = int(request.GET.get('desc', 0)) except ValueError: desc = 0 desc_toggle = 0 if desc else 1 threads_ = sort_threads(doc.thread_set, sort, desc) threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE) feed_urls = ((reverse('wiki.discuss.threads.feed', args=[document_slug]), ThreadsFeed().title(doc)), ) is_watching_forum = (request.user.is_authenticated() and NewThreadEvent.is_notifying(request.user, doc)) return jingo.render( request, 'kbforums/threads.html', { 'document': doc, 'threads': threads_, 'is_watching_forum': is_watching_forum, 'sort': sort, 'desc_toggle': desc_toggle, 'feeds': feed_urls })
def test_multi_feed_titling(self): """Ensure that titles are being applied properly to feeds.""" d = document(save=True) response = get(self.client, 'wiki.discuss.threads', args=[d.slug]) doc = pq(response.content) given_ = doc('link[type="application/atom+xml"]')[0].attrib['title'] exp_ = ThreadsFeed().title(d) eq_(exp_, given_)
def test_threads_sort(self): """Ensure that threads are being sorted properly by date/time.""" d = document(save=True) t = thread(document=d, save=True) t.new_post(creator=t.creator, content='foo') time.sleep(1) t2 = thread(document=d, save=True) t2.new_post(creator=t2.creator, content='foo') given_ = ThreadsFeed().items(d)[0].id eq_(t2.id, given_)
from django.conf.urls.defaults import patterns, url, include from django.contrib.contenttypes.models import ContentType from kbforums.feeds import ThreadsFeed, PostsFeed from kbforums.models import Post from sumo.views import redirect_to from flagit import views as flagit_views # These patterns inherit from /document/discuss doc_discuss_patterns = patterns( 'kbforums.views', url(r'^$', 'threads', name='wiki.discuss.threads'), url(r'^/feed', ThreadsFeed(), name='wiki.discuss.threads.feed'), url(r'^/new', 'new_thread', name='wiki.discuss.new_thread'), url(r'^/watch', 'watch_forum', name='wiki.discuss.watch_forum'), url(r'^/post-preview-async$', 'post_preview_async', name='wiki.discuss.post_preview_async'), url(r'^/(?P<thread_id>\d+)$', 'posts', name='wiki.discuss.posts'), url(r'^/(?P<thread_id>\d+)/feed$', PostsFeed(), name='wiki.discuss.posts.feed'), url(r'^/(?P<thread_id>\d+)/watch$', 'watch_thread', name='wiki.discuss.watch_thread'), url(r'^/(?P<thread_id>\d+)/reply$', 'reply', name='wiki.discuss.reply'), url(r'^/(?P<thread_id>\d+)/sticky$', 'sticky_thread', name='wiki.discuss.sticky_thread'), url(r'^/(?P<thread_id>\d+)/lock$', 'lock_thread',
def test_threads_sort(self): """Ensure that threads are being sorted properly by date/time.""" f = Document.objects.get(pk=1) given_ = ThreadsFeed().items(f)[0].id exp_ = 4L eq_(exp_, given_)