| Issue 47: | Staff-only forums | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Hello, I did a extension on django-forum, for use as a private forum. Forums can simply be asigned to be private by checking a Checkbox. For me it works. Maybe also for you. Sorry for my bad english Index: lib/forum/feeds.py =========================================================== ======== --- . (revision 28) +++ . (working copy) @@ -47,7 +47,7 @@ if obj: return Post.objects.filter(thread__forum__pk=obj.id).order_by('-time') else: - return Post.objects.order_by('-time') + return Post.objects.filter(thread__forum__is_private=None).order_by('-time') def items(self, obj): return self.get_query_set(obj)[:15] Index: lib/forum/models.py =========================================================== ======== --- . (revision 28) +++ . (working copy) @@ -26,7 +26,8 @@ description = models.TextField(_("Description")) threads = models.IntegerField(_("Threads"), default=0) posts = models.IntegerField(_("Posts"), default=0) - + is_private = models.BooleanField('Privat', blank=True, null=True) + def _get_forum_latest_post(self): """This gets the latest post for the forum""" if not hasattr(self, '__forum_latest_post'): Index: lib/forum/views.py =========================================================== ======== --- . (revision 28) +++ . (working copy) @@ -28,6 +28,9 @@ f = get_object_or_404(Forum, slug=slug) form = CreateThreadForm() + + if f.is_private and request.user.is_staff != True: + return HttpResponseRedirect('/forum') return object_list( request, queryset=f.thread_set.all(), @@ -45,6 +48,10 @@ posts for that thread, in chronological order. """ t = get_object_or_404(Thread, pk=thread) + + if t.forum.is_private and request.user.is_staff != True: + return HttpResponseRedirect('/forum') + p = t.post_set.all().order_by('time') s = t.subscription_set.filter(author=request.user)
Dec 29, 2008
I like the idea of this but the patch will need significant work before I can accept it. Can you please update this code to include the following? * Allow superusers to view staff forums * Ensure you're using i18n around text (eg field names) * On all redirects, use reverse lookups as not everybody uses /forum. * When listing forums, only list forums that user can access. This means we won't even list private forums to non-staff users. * Update the new templatetags (https://code.google.com/p/django-forum/wiki/RecentPostTemplateTags) to exclude private forums. * In the forum list we should somehow signify a forum is private if the user has access to it, eg the word 'Private' next to the thread count. If you can update the patch I'll accept it right away. Unfortunately in it's current state it isn't complete enough IMO.
Summary:
Staff-only forums
Labels: -Type-Defect Type-Enhancement
Jan 30, 2009
Issue 53 has been merged into this issue.
Feb 1, 2009
Here is a first version of the patch.
Feb 6, 2009
Committed in SVN r38. Thanks for your patch! Next step is a small patch so that superusers can see all forums - but that isn't important enough to prevent me putting this in. I will leave this open as a reminder to me if it hasn't been done soon.
Status:
Started
|
Status: Accepted
Owner: rwpoulton