Issue 47: Staff-only forums
Reported by he...@sandgrave-media.de, Dec 4, 2008
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 4, 2008
Project Member #1 rwpoul...@gmail.com
This is a good idea, if we are going down a permissions-based path should we try to
use the existing Django permissions framework?

EG Perhaps only certain *groups* of people should be able to access a forum?

If we are going to use the code above, we also need to allow superusers to view staff
forums.

I'll ponder the groups/permissions changes that would be needed and make a decision
over the next few days. Thanks for the suggestion & code contribution!
Summary: Extented Private-Forum for staff-Users
Status: Accepted
Owner: rwpoulton
Dec 29, 2008
Project Member #2 rwpoul...@gmail.com
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
Project Member #3 rwpoul...@gmail.com
 Issue 53  has been merged into this issue.
Feb 1, 2009
#4 xphuture
Here is a first version of the patch.
groups.patch
6.5 KB   View   Download
Feb 6, 2009
Project Member #5 rwpoul...@gmail.com
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