google-code-export / django-forum

Automatically exported from code.google.com/p/django-forum
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

If a forum has multiple groups assigned to it managers.ForumManager.for_groups returns an instance of the forum for each group that has access. This causes the views.forum to raise a MultipleObjectsReturned #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a forum
2. Assign access to multiple groups
3. Visit forum list ( should see an instance of the forum for each group that 
has access ) 
4. click on one of the returned forums and a MultipleObjectsReturned exception 
should be raised

What is the expected output? What do you see instead?

I would expect that if a user has access to a forum, then only one instance of 
the forum is return.

What version of the product are you using? On what operating system?

OS : OSX 10.5.7
Python : Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12) 
Django : Django version 1.1 SVN-11385
forum :  ( was revsion 45, but I customised it locally as I needed to deploy it 
with 1.1 before the recent updates to 
the project.

Please provide any additional information below.

The fix is quite simple .. 
>>> change line 9 managers.py from
            return self.filter(public|user_groups)
>>> to
            return self.filter(public|user_groups).distinct()

Apologies about not submitting a proper patch - I don't know how to yet!

Original issue reported on code.google.com by jamie.cu...@gtempaccount.com on 10 Aug 2009 at 10:29

Attachments:

GoogleCodeExporter commented 9 years ago
I'm also new to testing, but I've attached a zip containing some fixtures and 
some rudimentary tests that catch 
this error.

Original comment by jamie.cu...@gtempaccount.com on 10 Aug 2009 at 11:01

Attachments:

GoogleCodeExporter commented 9 years ago
Hi! To submit a patch it's just:
$ diff -Naur old_file new_file > file.patch

That's it!

Original comment by byme...@gmail.com on 12 Aug 2009 at 11:24

GoogleCodeExporter commented 9 years ago
Thanks! 

Patch Attached.

Original comment by jamie.cu...@gtempaccount.com on 12 Aug 2009 at 11:27

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in SVN r50. Thanks!

Original comment by rwpoul...@gmail.com on 24 Aug 2009 at 10:15