def test_delete_removes_watches(self): """Assert deleting a document deletes watches on its threads.""" t = Thread.objects.get(pk=1) d = t.document NewThreadEvent.notify('*****@*****.**', t) assert NewThreadEvent.is_notifying('*****@*****.**', t) d.delete() assert not NewThreadEvent.is_notifying('*****@*****.**', t)
def test_delete_removes_watches(self): """Assert deleting a document deletes watches on its threads.""" t = Thread.objects.get(pk=1) d = t.document NewThreadEvent.notify('*****@*****.**', t) assert NewThreadEvent.is_notifying('*****@*****.**', t) d.delete() assert not NewThreadEvent.is_notifying('*****@*****.**', t)
def _toggle_watch_kbforum_as(self, username, document, turn_on=True): """Watch a discussion forum and return it.""" self.client.login(username=username, password='******') user = User.objects.get(username=username) watch = 'yes' if turn_on else 'no' post(self.client, 'wiki.discuss.watch_forum', {'watch': watch}, args=[document.slug]) # Watch exists or not, depending on watch. if turn_on: assert NewThreadEvent.is_notifying(user, document), ( 'NewThreadEvent should be notifying.') else: assert not NewThreadEvent.is_notifying(user, document), ( 'NewThreadEvent should not be notifying.') return document
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 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_watch_forum(self): """Watch then unwatch a forum.""" self.client.login(username='******', password='******') user = User.objects.get(username='******') d = Document.objects.filter()[0] post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'}, args=[d.slug]) assert NewThreadEvent.is_notifying(user, d) # NewPostEvent is not notifying. p = d.thread_set.all()[0].post_set.all()[0] assert not NewPostEvent.is_notifying(user, p) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'}, args=[d.slug]) assert not NewThreadEvent.is_notifying(user, d)
def test_watch_forum(self): """Watch then unwatch a forum.""" self.client.login(username='******', password='******') user = User.objects.get(username='******') d = Document.objects.filter()[0] post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'}, args=[d.slug]) assert NewThreadEvent.is_notifying(user, d) # NewPostEvent is not notifying. p = d.thread_set.all()[0].post_set.all()[0] assert not NewPostEvent.is_notifying(user, p) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'}, args=[d.slug]) assert not NewThreadEvent.is_notifying(user, d)
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_watch_forum(self): """Watch then unwatch a forum.""" u = user(save=True) self.client.login(username=u.username, password='******') d = document(save=True) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'}, args=[d.slug]) assert NewThreadEvent.is_notifying(u, d) # NewPostEvent is not notifying. t = thread(document=d, save=True) p = t.new_post(creator=t.creator, content='test') #p = d.thread_set.all()[0].post_set.all()[0] assert not NewPostEvent.is_notifying(u, p) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'}, args=[d.slug]) assert not NewThreadEvent.is_notifying(u, d)
def test_watch_forum(self): """Watch then unwatch a forum.""" u = user(save=True) self.client.login(username=u.username, password='******') d = document(save=True) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'}, args=[d.slug]) assert NewThreadEvent.is_notifying(u, d) # NewPostEvent is not notifying. t = thread(document=d, save=True) p = t.new_post(creator=t.creator, content='test') #p = d.thread_set.all()[0].post_set.all()[0] assert not NewPostEvent.is_notifying(u, p) post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'}, args=[d.slug]) assert not NewThreadEvent.is_notifying(u, d)
def test_watch_thread(self): """Watch then unwatch a thread.""" self.client.login(username='******', password='******') user = User.objects.get(username='******') t = Thread.objects.filter()[0] post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'}, args=[t.document.slug, t.id]) assert NewPostEvent.is_notifying(user, t) # NewThreadEvent is not notifying. assert not NewThreadEvent.is_notifying(user, t.document) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'}, args=[t.document.slug, t.id]) assert not NewPostEvent.is_notifying(user, t)
def test_watch_thread(self): """Watch then unwatch a thread.""" u = user(save=True) self.client.login(username=u.username, password='******') t = thread(save=True) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'}, args=[t.document.slug, t.id]) assert NewPostEvent.is_notifying(u, t) # NewThreadEvent is not notifying. assert not NewThreadEvent.is_notifying(u, t.document) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'}, args=[t.document.slug, t.id]) assert not NewPostEvent.is_notifying(u, t)
def test_watch_thread(self): """Watch then unwatch a thread.""" self.client.login(username='******', password='******') user = User.objects.get(username='******') t = Thread.objects.filter()[0] post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'}, args=[t.document.slug, t.id]) assert NewPostEvent.is_notifying(user, t) # NewThreadEvent is not notifying. assert not NewThreadEvent.is_notifying(user, t.document) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'}, args=[t.document.slug, t.id]) assert not NewPostEvent.is_notifying(user, t)
def test_watch_thread(self): """Watch then unwatch a thread.""" u = user(save=True) self.client.login(username=u.username, password='******') t = thread(save=True) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'}, args=[t.document.slug, t.id]) assert NewPostEvent.is_notifying(u, t) # NewThreadEvent is not notifying. assert not NewThreadEvent.is_notifying(u, t.document) post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'}, args=[t.document.slug, t.id]) assert not NewPostEvent.is_notifying(u, t)