SHARE
TWEET

Untitled

a guest Jan 18th, 2019 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from Products.ATContentTypes.content import base
  2. from Products.ATContentTypes.content import schemata
  3. from Products.ATContentTypes.content import document
  4. from Products.ATContentTypes.content.document import ATDocument
  5. from zope.interface import implements, Interface
  6. try:
  7.     from Products.LinguaPlone import *
  8. except ImportError:
  9.     from Products.Archetypes import *
  10.  
  11. from Products.Archetypes.atapi import BooleanField
  12. from Products.Archetypes.atapi import BooleanWidget
  13. from Products.Archetypes.atapi import ReferenceField
  14. from Products.Archetypes.atapi import TextField
  15. from Products.Archetypes.atapi import RichWidget
  16. from archetypes.referencebrowserwidget import ReferenceBrowserWidget
  17. from plone.app.iterate.interfaces import IIterateAware
  18.  
  19. from iasplus.policy import IASPlusMessageFactory as _
  20.  
  21. # schema declaration
  22. #original - schema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
  23.  
  24. schema = document.ATDocumentSchema.copy() + public.Schema((
  25.  
  26.     TextField('body',
  27.             searchable = 0,
  28.             required = 1,
  29.             allowable_content_types = ('text/plain',
  30.                                        'text/structured',
  31.                                        'text/html',),
  32.             default_output_type = 'text/x-html-safe',
  33.             widget = RichWidget(label = _(u'body', default=u'body'),
  34.                     rows = '3',  
  35.             ),
  36.     ),
  37.    
  38.     ReferenceField('jurisdictionImage',
  39.         required = True,
  40.         searchable = False,
  41.         multiValued=0,
  42.         allowed_types=('Image'),
  43.         relationship= "jurisdictionImage",  
  44.         widget = ReferenceBrowserWidget(
  45.             label = _(u'jurisdiction_image', default=u'Associated Jurisdiction Image'),
  46.             allow_search = True,
  47.             allow_browse = True,)
  48.         ),
  49.    
  50.  )        
  51. )
  52.  
  53.  
  54. class IJurisdiction(Interface):
  55.     pass
  56.    
  57.  
  58. class Jurisdiction(base.ATCTContent):
  59.     implements(IJurisdiction, IIterateAware)
  60.    
  61.     schema = schema
  62.     meta_type = 'Jurisdiction'
  63.    
  64.     if 'description' in schema:
  65.         schema['description'].required = True
  66.        
  67.     def getAssociatedImage(self):
  68.         imageSet = self.getJurisdictionImage()
  69.        
  70.         if imageSet is not None:
  71.             return imageSet.absolute_url()
  72.  
  73. public.registerType(Jurisdiction, 'iasplus.policy')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top