# -*- coding: utf-8 -*- # # File: WorkTeleService.py # # Copyright (c) 2007 by CommunesPlone # Generator: ArchGenXML Version 1.5.3 dev/svn # http://plone.org/products/archgenxml # # GNU General Public License (GPL) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # __author__ = """Gauthier BASTIEN , Stephan GEULETTE """ __docformat__ = 'plaintext' from AccessControl import ClassSecurityInfo from Products.Archetypes.atapi import * from Products.TeleServices.GenericTeleService import GenericTeleService from Products.TeleServices.config import * ##code-section module-header #fill in your manual code here from Products.CMFCore.utils import getToolByName from Products.PlacelessTranslationService import utranslate ##/code-section module-header schema = Schema(( StringField( name='demandType', widget=SelectionWidget( label='Demandtype', label_msgid='TeleServices_label_demandType', i18n_domain='TeleServices', ), required=True, vocabulary='listWorkDemandTypes', searchable= 'True', default_method='getUserDemandType' ), ComputedField( name='title', widget=ComputedField._properties['widget']( label='Title', label_msgid='TeleServices_label_title', i18n_domain='TeleServices', ), expression='context.getFormattedTitle()', accessor='Title', searchable= 'True' ), TextField( name='place', widget=TextAreaWidget( description="Give as more details as you can (locality, street, ...)", label='Place', label_msgid='TeleServices_label_place', description_msgid='TeleServices_help_place', i18n_domain='TeleServices', ), required=True, searchable= 'True' ), TextField( name='comment', widget=TextAreaWidget( description="Give some details about your demand.", label='Comment', label_msgid='TeleServices_label_comment', description_msgid='TeleServices_help_comment', i18n_domain='TeleServices', ), optional=True, searchable= 'True', default_method='checkIfCommentInOptionalFields' ), TextField( name='officialComment', widget=TextAreaWidget( label='Officialcomment', label_msgid='TeleServices_label_officialComment', i18n_domain='TeleServices', ), optional=True, write_permission="TeleServices: WorkTS Review state", searchable= 'True', default_method='checkIfOfficialCommentInOptionalFields' ), StringField( name='elementsNumber', widget=StringWidget( description="Give number of bags, bundles, elements, ...", label='Elementsnumber', label_msgid='TeleServices_label_elementsNumber', description_msgid='TeleServices_help_elementsNumber', i18n_domain='TeleServices', ), required=True, optional=True, searchable= 'True', default_method='checkIfElementsNumberInOptionalFields' ), StringField( name='pylonNumber', widget=StringWidget( description="Give the reference number indicated on the pylon.", label='Pylonnumber', label_msgid='TeleServices_label_pylonNumber', description_msgid='TeleServices_help_pylonNumber', i18n_domain='TeleServices', ), required=True, optional=True, searchable= 'True', default_method='checkIfPylonNumberInOptionalFields' ), ), ) ##code-section after-local-schema #fill in your manual code here ##/code-section after-local-schema WorkTeleService_schema = BaseSchema.copy() + \ getattr(GenericTeleService, 'schema', Schema(())).copy() + \ schema.copy() ##code-section after-schema #fill in your manual code here ##/code-section after-schema class WorkTeleService(BaseContent, GenericTeleService): """ """ security = ClassSecurityInfo() __implements__ = (getattr(BaseContent,'__implements__',()),) + (getattr(GenericTeleService,'__implements__',()),) # This name appears in the 'add' box archetype_name = 'WorkTeleService' meta_type = 'WorkTeleService' portal_type = 'WorkTeleService' allowed_content_types = [] + list(getattr(GenericTeleService, 'allowed_content_types', [])) filter_content_types = 0 global_allow = 1 #content_icon = 'WorkTeleService.gif' immediate_view = 'base_view' default_view = 'base_view' suppl_views = () typeDescription = "WorkTeleService" typeDescMsgId = 'description_edit_workteleservice' actions = ( {'action': "string:${object_url}/genericteleservice_view", 'category': "object", 'id': 'view', 'name': 'View', 'permissions': ("View",), 'condition': 'python:1' }, ) _at_rename_after_creation = True schema = WorkTeleService_schema ##code-section class-header #fill in your manual code here ##/code-section class-header # Methods security.declarePublic('getFormattedTitle') def getFormattedTitle(self): """ Retourne le titre : demandtype """ vocab = self.getField('demandType').Vocabulary(self) return self.displayValue(vocab, self.getDemandType()) security.declarePublic('getUserDemandType') def getUserDemandType(self): """ Get first the demandType property on the object. If not exists, call the getDemandTypeFromRequest from portal_teleservices to try to populate the DemandType selection box. """ savedDemandType = None #check necessary for edit form if hasattr(self, 'demandType'): savedDemandType = getattr(self, 'demandType') if savedDemandType != None: return savedDemandType else: return self.portal_teleservices.getDemandTypeFromRequest() security.declarePublic('listWorkDemandTypes') def listWorkDemandTypes(self): """ return a list of enabled workteleservice """ return self.portal_teleservices.listTermsVocab('WorkTeleService', 'DemandTypeTerm', ['on_line']) security.declarePublic('checkIfOfficialCommentInOptionalFields') def checkIfOfficialCommentInOptionalFields(self): """ check if the officialComment field is enabled for the current DemandType """ return self.checkIfInOptionalFields(field="officialComment") security.declarePublic('checkIfCommentInOptionalFields') def checkIfCommentInOptionalFields(self): """ check if the Comment field is enabled for the current DemandType """ return self.checkIfInOptionalFields(field="comment") security.declarePublic('checkIfElementsNumberInOptionalFields') def checkIfElementsNumberInOptionalFields(self): """ check if the ElementsNumber field is enabled for the current DemandType """ return self.checkIfInOptionalFields(field="elementsNumber") security.declarePublic('checkIfPylonNumberInOptionalFields') def checkIfPylonNumberInOptionalFields(self): """ check if the PylonNumber field is enabled for the current DemandType """ return self.checkIfInOptionalFields(field="pylonNumber") security.declarePublic('checkIfInOptionalFields') def checkIfInOptionalFields(self, field): """ return DEFAULT_NO_VALUE if the field is not enabled in DemandTypeTerm.optionalFields """ #we get the demandtype term dtt = self.portal_teleservices.getTermObject('WorkTeleService', 'DemandTypeTerm', self.getDemandType()) if field in dtt.getOptionalFields(): return '' else: return DEFAULT_NO_VALUE registerType(WorkTeleService, PROJECTNAME) # end of class WorkTeleService ##code-section module-footer #fill in your manual code here ##/code-section module-footer