From 37781db84157d12cbfc6e8a454e2a2dc3846e2dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 1 Sep 2014 23:21:16 +0200 Subject: [PATCH 1/1] =?utf8?q?Remise=20en=20route=20de=20l'affichage=20de?= =?utf8?q?=20ses=20collections=20apr=C3=A8s=20login.=20realis--?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_theme/homepage_dispatcher.py | 25 ++++++++++++++++-------- skins/photo_theme/member_albums.py | 4 ++-- utils.py | 18 ++++++++++++++++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/skins/photo_theme/homepage_dispatcher.py b/skins/photo_theme/homepage_dispatcher.py index de5cb66..bc3e140 100755 --- a/skins/photo_theme/homepage_dispatcher.py +++ b/skins/photo_theme/homepage_dispatcher.py @@ -9,12 +9,21 @@ resp = req.RESPONSE came_from = req.form.get('came_from') if came_from : - urlQs = came_from.split('?', 1) - if len(urlQs) == 1 : - came_from = '%s?%s' % (urlQs[0], mq(portal_status_message=_('Login success'))) - else : - url, qs= urlQs - came_from = '%s?%s&%s' % (url, qs, mq(portal_status_message=_('Login success'))) - return resp.redirect(came_from) + urlQs = came_from.split('?', 1) + if len(urlQs) == 1 : + came_from = '%s?%s' % (urlQs[0], mq(portal_status_message=_('Login success'))) + else : + url, qs= urlQs + came_from = '%s?%s&%s' % (url, qs, mq(portal_status_message=_('Login success'))) + return resp.redirect(came_from) -return resp.redirect('%s?%s' % (utool(), mq(portal_status_message=_('Login success')))) \ No newline at end of file +else : + from Products.Plinn.utils import searchContentsWithLocalRolesForAuthenticatedUser as search + results = search(portal_type='Portfolio') + if results : + atool = getToolByName(context, 'portal_actions') + return context.setRedirect(atool, 'user/my_albums', portal_status_message=_('Login success')) + else : + utool = getToolByName(context, 'portal_url') + return resp.redirect('%s?%s' % (utool(), mq(portal_status_message=_('Login success')))) + \ No newline at end of file diff --git a/skins/photo_theme/member_albums.py b/skins/photo_theme/member_albums.py index 9425f2b..dab1be5 100755 --- a/skins/photo_theme/member_albums.py +++ b/skins/photo_theme/member_albums.py @@ -1,6 +1,6 @@ ##parameters= -from Products.realis.utils import searchContentsWithLocalRolesForAuthenticatedUser as search +from Products.Plinn.utils import searchContentsWithLocalRolesForAuthenticatedUser as search -results = search(context, portal_type='Portfolio') +results = search(portal_type='Portfolio') return context.member_albums_template(results = results) \ No newline at end of file diff --git a/utils.py b/utils.py index 6b3b697..de68f22 100755 --- a/utils.py +++ b/utils.py @@ -319,4 +319,20 @@ def _sudo(func, userid=None) : raise e return ret - \ No newline at end of file + +security.declarePublic('searchContentsWithLocalRolesForAuthenticatedUser') +def searchContentsWithLocalRolesForAuthenticatedUser(**kw): + mtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMembershipTool') + ctool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ICatalogTool') + member = mtool.getAuthenticatedMember() + userid = member.getId() + userAndGroups = ['user:%s' % userid] + + getGroups = getattr(member, 'getGroups', None) + if getGroups is not None : + for group in getGroups(): + userAndGroups.append('user:'+group) + + kw[ 'allowedRolesAndUsers' ] = userAndGroups + + return ctool.unrestrictedSearchResults(**kw) -- 2.20.1