# -*- coding: utf-8 # Copyright 2005 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField, ImageField, ReferenceField from Products.Archetypes.public import LinesWidget, TextAreaWidget, StringWidget, SelectionWidget, MultiSelectionWidget, ImageWidget from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget from Products.Archetypes.public import BaseContent, BaseFolder, 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 ExhibitionFolder(BaseFolder, BaseFunctions): """ Exhibition Folder""" meta_type = "ExhibitionFolder" archetype_name = "ExhibitionFolder" global_allow = 0 allowed_content_types = ('Exhibition',) security = ClassSecurityInfo() content_icon='exhibition_icon.gif' schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/exhibition_folder_view', 'permissions': ('View',), }, ) def manage_afterAdd(self,item,container): """sets permissions""" self.manage_permission('Add portal content', ('Manager','Teacher',) ,1) def getExhibitions(self): """return ex""" return self.objectValues("Exhibition") def getExhibition(self, exhibition): """shalala""" if hasattr(self, exhibition): return getattr(self, exhibition) registerType(ExhibitionFolder, PROJECT_NAME) class Exhibition(BaseContent, BaseFunctions): """ Exhibition """ meta_type = "Exhibition" archetype_name = "Exhibition" global_allow = 1 allowed_content_types = () security = ClassSecurityInfo() content_icon='exhibition_icon.gif' schema = schema + Schema(( LinesField('Groups', required=1, accessor="getGroups", isMetadata=1, multiValued=1, vocabulary='getClasses', widget=MultiSelectionWidget( format="select", label="Groups", label_msgid='label_groups', description="This is exhibition for this group or groups", description_msgid='desc_groups', i18n_domain="krihvel"), ), ImageField('DisplayIcon', accessor="getDisplayIcon", original_size=(150, 90), max_size = (150, 90), widget=ImageWidget( label="Display icon", label_msgid='label_displayicon', description="This is dispaly icon for this exhibition", description_msgid='desc_displayicon', i18n_domain="krihvel"), ), ReferenceField('refsToExhibition', accessor = 'getRefsToExhibition', relationship = 'References', mutator = 'addRefsToExhibition', allowed_types = ('MathAnswer','PairsAnswer','PaperAnswer','CrosswordAnswer','FillInAnswer','ImageEditorRasterAnswer'), multiValued = True, widget = ReferenceBrowserWidget( visible = {'view':'invisible', 'edit':'invisible'}, ), ), )) actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/exhibition_view', 'permissions': ('View',), }, ) security.declareProtected('View', 'countExponents') def countExponents(self): """counts objects in exhibition""" return len(self.getRefsToExhibition()) def getExponents(self): """shalala""" return self.getRefsToExhibition() def getExponent(self, exponent): """ejfkh""" if hasattr(self, 'kalasaba'): self.kalasaba = self.kalasaba + 1 if not hasattr(self, 'kalasaba'): self.kalasaba = 1 if self.kalasaba > 5: raise 'oled tsykklis' for ex in self.getExponents(): if ex.id == exponent: return ex.UID() return False registerType(Exhibition, PROJECT_NAME)