##############################################################################
# Copyright (c) 2004-2005 Black Rock City, LLC
# Copyright (c) 2004-2005 ObjectRealms, LLC
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
##############################################################################
"""
$Id: permissions.py 20210 2005-07-11 08:59:08Z rob $
"""
from Products.CMFCore import CMFCorePermissions
from Products.Archetypes import public as atapi
import config

# can someone add/remove new teams members
ManageTeamMembership = "%s: Manage team memberships" % config.PROJECTNAME

# can someone configure the team itself
ManageTeam = "%s: Manage team" % config.PROJECTNAME

# can someone view anything in the team
ViewTeam = CMFCorePermissions.View

# can someone view all members of the team
ViewAllTeam = CMFCorePermissions.AccessInactivePortalContent

# can someone manage/configure a teamspace
ManageTeamSpace = CMFCorePermissions.ManagePortal

def initialize():
    permissions = {}
    types = atapi.listTypes(config.PROJECTNAME)
    for atype in types:
        if atype['name'] == "TeamMembership":
            permission = ManageTeamMembership
        else:
            permission = "%s: Add %s" % (config.PROJECTNAME, atype['portal_type'])
        permissions[atype['portal_type']] = permission
        # Assign default roles
        CMFCorePermissions.setDefaultRoles(permission, ('Manager',))

    return permissions
