Ask Your Question
0

'AnonymousUser' object has no attribute 'get_groups'

asked 2014-11-22 00:31:06 -0500

johnli gravatar image

After enable user group, for anonymous user, it throws error below. Any idea?

askbot/models/question.py in get_latest_revision

posts_filter['groups__in'] = user.get_groups()

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-11-23 21:40:05 -0500

johnli gravatar image

updated 2014-11-29 16:14:35 -0500

 #  if user and askbot_settings.GROUP_ENABLED: (askbot/models/question.py line 745)
 #  this line throws 'AnonymousUser' object has no attribute 'get_groups' exception for AnonymousUser. See fix below.
 # user passed to this function could be actual user object, Anonymous user which doesnt have get_group(), or None

  if user and askbot_settings.GROUPS_ENABLED:
        if user.is_authenticated():
        #get post with groups shared with having at least 
        #one of the user groups
        #of those posts return the latest revision
            posts_filter['groups__in'] = user.get_groups()
edit flag offensive delete link more

Comments

Thanks, committed this change to the master branch.

Evgeny gravatar imageEvgeny ( 2014-11-29 17:27:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-22 00:31:06 -0500

Seen: 426 times

Last updated: Nov 29 '14