Skip to content

Commit

Permalink
Merge pull request collective#18 from cguardia/master
Browse files Browse the repository at this point in the history
Fix like for authenticated users when anonymous voting is enabled
  • Loading branch information
davisagli committed Sep 23, 2015
2 parents 35461df + 0311e35 commit e1efe7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cioppino/twothumbs/browser/like.py
Expand Up @@ -62,20 +62,21 @@ class LikeThisShizzleView(BrowserView):
def __call__(self, REQUEST, RESPONSE):
registry = getUtility(IRegistry)
anonuid = None
if not registry.get('cioppino.twothumbs.anonymousvoting', False):
# First check if the user is allowed to rate
portal_state = getMultiAdapter((self.context, self.request),
name='plone_portal_state')
if portal_state.anonymous():
anonymous_voting = registry.get('cioppino.twothumbs.anonymousvoting', False)
portal_state = getMultiAdapter((self.context, self.request),
name='plone_portal_state')

if portal_state.anonymous():
if not anonymous_voting:
return RESPONSE.redirect('%s/login?came_from=%s' %
(portal_state.portal_url(),
REQUEST['HTTP_REFERER'])
)
else:
anonuid = self.request.cookies.get(COOKIENAME, None)
if anonuid is None:
anonuid = str(uuid4())
RESPONSE.setCookie(COOKIENAME, anonuid)
else:
anonuid = self.request.cookies.get(COOKIENAME, None)
if anonuid is None:
anonuid = str(uuid4())
RESPONSE.setCookie(COOKIENAME, anonuid)

form = self.request.form
action = None
Expand Down
2 changes: 2 additions & 0 deletions docs/HISTORY.rst
Expand Up @@ -6,6 +6,8 @@ Changelog

- HTML render fixes.
[andreasma]
- Fix bug in like view that prevented authenticated user id from being used
in votes when anonymous voting was enabled [cguardia]


1.8 (2014-11-07)
Expand Down

0 comments on commit e1efe7e

Please sign in to comment.