user966660
user966660

Reputation: 592

Plone - How can I check if User is on /folder_contents view action

Because I use plone.app.widgets (1.8.0) and wildcard.foldercontents (1.3.2), I have to disable pa.widgets-Javascript only for /folder_contents tab.

Multiupload does not work with pa.widgets enabled

 ().fileUpload is not a function

But how can I determine that? What I've tried:

context/absolute_url  
context/@@plone_context_state/object_url
getViewTemplateId
and a few more

Plone 4.3.4.1

Upvotes: 0

Views: 159

Answers (4)

Kim Paulissen
Kim Paulissen

Reputation: 618

In Plone 6: using the View class

from Acquisition import aq_inner
from plone.app.content.browser.contents import FolderContentsView

# Get the current context
context = aq_inner(context)

# Check if the context is a FolderContentsView
if isinstance(context, FolderContentsView):
    print("You are inside a FolderContentsView")
else:
    print("You are not inside a FolderContentsView")
    

or with the interface:

from Acquisition import aq_inner
from plone.app.content.browser.interfaces import IFolderContentsView

# Get the current context
context = aq_inner(context)

# Check if the context provides the IFolderContentsView interface
if IFolderContentsView.providedBy(context):
    print("You are inside a FolderContentsView")
else:
    print("You are not inside a FolderContentsView")

Upvotes: 0

Juliano Araújo
Juliano Araújo

Reputation: 3608

You could try the following code:

mt = getToolByName(self.context, 'portal_membership')
member = mt.getMemberById(username)
if member == 'Anonymous':
    pass
else:
    pass

And you can handle when is Anonymou or logged member.

Upvotes: 0

Cekk
Cekk

Reputation: 67

I had a similar issue with wildcard.foldercontents and collective.z3cform.widgets..both have a related js code that goes in conflict.

i check that condition like this:

self.request.steps[-1] != "folder_contents"

In folder_contents tab, last step in the request is always "folder_contents".

I don't know if it's the best solution, but it works

Upvotes: 1

user966660
user966660

Reputation: 592

Sorry, just so simple

request.ACTUAL_URL

open for a better solution :-)

Upvotes: 0

Related Questions