# -*- coding: utf-8 # Copyright 2005 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField, TextField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget, MultiSelectionWidget from Products.Archetypes.public import BaseFolder, BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from BaseFunctions import BaseFunctions from Permissions import * from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema + Schema(( )) class Gallery(BaseFolder, BaseFunctions): """ Gallery """ meta_type = "Gallery" archetype_name = "Gallery" global_allow = 1 allow_discussion = 1 allowed_content_types = ('Image','Gallery') security = ClassSecurityInfo() content_icon='exhibition_icon.gif' schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/gallery_view', 'permissions': ('View',), }, { 'id':'addImage', 'name':'Add image', 'action':'string:${object_url}/createObject?type_name=Image', 'permissions': ('Modify portal content',), }, { 'id':'addGallery', 'name':'Add gallery', 'action':'string:${object_url}/createObject?type_name=Gallery', 'permissions': ('Modify portal content',), }, #{ #'id':'folderContents', #'name':'Contents', #'action':'string:${object_url}/folder_contents', #'permissions': ('Modify portal content',), #}, ) def manage_afterAdd(self,item,container): """sets permissions""" self.manage_permission('Add portal content', ('Manager','Teacher','Member') ,1) security.declareProtected('Add portal content', 'deleteObject') def deleteObject(self, REQUEST): """ delete object """ id = REQUEST.get("id") self._delObject(id) return REQUEST.RESPONSE.redirect(self.absolute_url()+'/linkcollector_view') #def enableAllowDiscussion(self): # """enable""" # for ob in self.objectValues("ATImage"): # print ob.allow_discussion # if not ob.allow_discussion: # ob.allow_discussion = 1 registerType(Gallery, PROJECT_NAME)