Ticket #1642 (new enhancement)

Opened 13 years ago

Last modified 9 years ago

Allow comments when there is diferent types of workspaces or sections.

Reported by: tracguest Owned by: trac
Priority: P2 Milestone: CPS 3.4.10
Component: CPSForum Version: 3.4.0
Severity: normal Keywords:
Cc:

Description

I've found this snippet in CommentTool?.py inside CPSForum product:

def getParentFolder(proxy):
    """Returns 'Section' or 'Workspace' parent folder."""
    parent = proxy.aq_inner.aq_parent
    while parent:
       if hasattr(parent, 'portal_type') and \
           (parent.portal_type == 'Section' or
            parent.portal_type == 'Workspace'):
            return parent
         parent = parent.aq_inner.aq_parent
    return proxy.aq_inner.aq_parent

I had some problem with this as I have a new type of folder which type is "WorkspaceCustomized?".

What I propose to improve this code is to add a new attribute to the class, let's say:

parentTypes = ['Section', 'Workspace'] ## This would be the initial value for a CPSDefault Site
sectionTypes = ['Section'] ## It's necessary to diferenciate which of the parentTypes are sections.

and modify the function as this:

def getParentFolder(proxy):
    """Returns parent folder."""
    parent = proxy.aq_inner.aq_parent
    while parent:
       if hasattr(parent, 'portal_type') and (parent.portal_type in parentTypes):
          return parent
       parent = parent.aq_inner.aq_parent
    return proxy.aq_inner.aq_parent

and in the getForum4Comments method modify this lines (the comment below is from the original code):

 # we should create a Workspace if parent folder is a workspace
 # or a Section if parent folder is a section
 if parent_folder.portal_type in sectionTypes:
    folder_type = 'Section'
 else:
    folder_type = 'Workspace'

I implemented this for my own site, and I thought it would be useful for any site. Is this possible to apply it to the original code?

Even this type information identifiers could be managed from ZMI in portal_discussions, what do you think?

Thank you very much.

Change History

comment:1 Changed 13 years ago by joseluis.rosa@…

I forgot to include my email when creating the ticket.

comment:2 Changed 13 years ago by sfermigier

  • Milestone changed from CPS 3.4.1 to CPS 3.4.2

comment:3 Changed 9 years ago by gracinet

  • Milestone changed from CPS 3.5.0 to CPS 3.4.10

CPSForum is already legacy in the 3.4 branch and probably won't be supported in 3.5 versions.

Note: See TracTickets for help on using tickets.