Ticket #1642 (new enhancement)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: tracguest Assigned to: trac
Priority: P2 Milestone: CPS 3.5.0
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

05/08/06 15:49:23 changed by joseluis.rosa@iavante.es

I forgot to include my email when creating the ticket.

05/19/06 17:22:02 changed by sfermigier

  • milestone changed from CPS 3.4.1 to CPS 3.4.2.