# -*- coding: utf-8 # Copyright 2005 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget, RichWidget from AccessControl import ClassSecurityInfo from Products.Archetypes.public import registerType from Products.Krihvel.BaseTask import BaseTask from Products.Krihvel.config import PROJECT_NAME schema = BaseSchema + Schema(( LinesField('Target', required=1, searchable=1, accessor="getTarget", isMetadata=1, vocabulary='getClasses', widget=SelectionWidget( format="select", label="Target", label_msgid='label_target', description="Target whos get that task.", description_msgid='desc_target', i18n_domain="krihvel"), ), )) class Pairs(BaseTask): """ Pairs module. """ meta_type = "Pairs" archetype_name = "Pairs" allowed_content_types = ('Image',) global_allow = 0 security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/pairs_view', 'permissions': ('View',), }, ) def _renameAfterCreation(self, check_auto_id=False): pass def __init__(self, id): self.id = id self.images = [] def getClasses(self): """ Classes massive """ classes = ['I','II'] print self.Target, self.getTarget() return classes def addRow(self, REQUEST): """ add image row to game """ image_1_text = REQUEST.get('picture_1_text') image_2_text = REQUEST.get('picture_2_text') image_1_url = REQUEST.get('picture_1_url') image_2_url = REQUEST.get('picture_2_url') user = str(REQUEST.AUTHENTICATED_USER) homefolder = self.portal_membership.getHomeFolder(user) if image_1_url != '0': col1 = {'type':'image','value':image_1_url} elif image_1_text != '': col1 = {'type':'text','value':image_1_text} else: col1 = 'None' if image_2_url != '0': col2 = {'type':'image','value':image_2_url} elif image_2_text != '': col2 = {'type':'text','value':image_2_text} else: col2 = 'None' self.images.append({'col1':col1,'col2':col2}) self._p_changed = 1 def getGameData(self): """aaa""" return self.images def getPicArrayForGame(self, col): """aaa""" array = "" for item in self.images: array=array+"#"+item[col]['value'] return array def getTypeArrayForGame(self, col): """aaa""" array = "" for item in self.images: array=array+"#"+item[col]['type'] return array registerType(Pairs, PROJECT_NAME)