Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accreditation Portlet renders an error message for anonymous users #336

Merged
merged 9 commits into from
Oct 31, 2017

Conversation

nihadness
Copy link
Contributor

Current behavior
The accreditation portlet is rendered with an error message, for anonymous users.

2017-10-30 14:13:01 ERROR portlets Error while rendering <plone.app.portlets.manager.ColumnPortletManagerRenderer object at 0x7f90e1134e90>
Traceback (most recent call last):
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/plone.app.portlets-2.5.5-py2.7.egg/plone/app/portlets/manager.py", line 63, in safe_render
    return portlet_renderer.render()
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
    return self.im_func(im_self, *args, **kw)
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/zope.pagetemplate-3.6.3-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 132, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/five.pt-2.2.4-py2.7.egg/five/pt/engine.py", line 98, in __call__
    return self.template.render(**kwargs)
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/z3c.pt-3.1.0-py2.7.egg/z3c/pt/pagetemplate.py", line 158, in render
    return base_renderer(**context)
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/zpt/template.py", line 297, in render
    return super(PageTemplate, self).render(**_kw)
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/home/nihad/dev/nihadness/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "5d3ea8c50d9609c8a4f76406ad3089b1.py", line 139, in render
  File "148c1d5e736a407b11ce7ae2f395fd4e.py", line 135, in render_portlet
Unauthorized: You are not allowed to access 'laboratory' in this context

Expected behavior after this PR
Accreditation Portlet is not being rendered for anonymous users.

For more detailed information, please see:#301

Copy link
Contributor

@ramonski ramonski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good approach @nihadness. But please have a look at the source of plone.app.layout.globals.portal.PortalState (here it is the @@plone_portal_state view) and search for anonymous. Then use that method with inverted logic.

However, we should delete this portlet in the future and setup a set of sane portlets during setup like here: https://github.com/senaite/senaite.lims/blob/master/src/senaite/lims/setuphandlers.py#L24

@nihadness
Copy link
Contributor Author

Looks better now, I guess :)

plone_view context/@@plone;">
anonymous portal_state/anonymous;
plone_view context/@@plone;"
tal:condition="python: not anonymous">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even skip the python part in the condition and just write tal:condition="not:anonymous". But this is also fine;) well done

@ramonski ramonski merged commit 0309f3b into senaite:senaite-integration Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants