Exemplo n.º 1
0
    def afterSetUp(self):
        self.setRoles(('Manager', ))
        #make a collection
        self.collection = self._createType(self.folder, 'Topic', 'collection')
        crit = self.collection.addCriterion('portal_type',
                                            'ATSimpleStringCriterion')
        crit.setValue('Folder')

        #Ensure folders can have personleadimages
        self.loginAsPortalOwner()
        prefs = ILeadImagePrefsForm(self.portal)
        types = list(prefs.allowed_types)
        if not 'Folder' in types:
            types.append('Folder')
            prefs.allowed_types = types
        self.logout()
        self.login()

        # add a folder
        folder1 = self._createType(self.folder, 'Folder', 'folder_1')
        #Add personleadimage to folder
        test_image = os.path.join(os.path.dirname(__file__), 'test_41x41.jpg')
        raw_image = open(test_image, 'rb').read()
        field = folder1.getField(IMAGE_FIELD_NAME)
        field.set(folder1, raw_image)
        folder1.reindexObject()
Exemplo n.º 2
0
 def sizes(self):
     # This property is not used in Plone 4 !
     # XXX it's still used in plone4 and thus overrides plone.app.imaging settings
     portal = getUtility(IPloneSiteRoot)
     cli_prefs = ILeadImagePrefsForm(portal)
     sizes = IMAGE_SIZES.copy()
     sizes['leadimage'] = (cli_prefs.image_width, cli_prefs.image_height)
     return sizes
Exemplo n.º 3
0
 def getFields(self):
     portal = getUtility(IPloneSiteRoot)
     cli_prefs = ILeadImagePrefsForm(portal)
     if cli_prefs.cli_props is not None:
         portal_type = getattr(self.context, 'portal_type', None)
         if portal_type in cli_prefs.allowed_types:
             return self.fields
     return []
    def __call__(self, context):
        portal = getUtility(IPloneSiteRoot)
        cli_prefs = ILeadImagePrefsForm(portal)
        width = cli_prefs.image_width
        height = cli_prefs.image_height
        scale = config.IMAGE_SCALE_NAME
        result = [
            SimpleTerm(scale, scale, "%s (%dx%d)" % (scale, width, height)),
        ]

        for scale, (width, height) in config.IMAGE_SIZES.items():
            result.append(
                SimpleTerm(scale, scale,
                           "%s (%dx%d)" % (scale, width, height)))

        return SimpleVocabulary(result)
Exemplo n.º 5
0
def importVarious(self):
    if self.readDataFile('contentleadimage.txt') is None:
        return

    portal = self.getSite()
    ptool = getToolByName(portal, 'portal_properties')
    props = ptool.cli_properties

    if not props.hasProperty('image_width'):
        props.manage_addProperty('image_width', config.IMAGE_SCALE_SIZE[0], 'int')
    if not props.hasProperty('image_height'):
        props.manage_addProperty('image_height', config.IMAGE_SCALE_SIZE[1], 'int')
    if not props.hasProperty('desc_scale_name'):
        props.manage_addProperty('desc_scale_name', 'thumb', 'string')
    if not props.hasProperty('body_scale_name'):
        props.manage_addProperty('body_scale_name', 'mini', 'string')

    setupCatalog(portal, indexes=dict(hasContentLeadImage='FieldIndex'),
                 metadata=['hasContentLeadImage'])

    prefs = ILeadImagePrefsForm(portal)
    prefs.viewlet_description = False
Exemplo n.º 6
0
 def prefs(self):
     portal = getUtility(IPloneSiteRoot)
     return ILeadImagePrefsForm(portal)
 def prefs(self):
     res = ''
     if LEADIMAGE_EXISTS:
         portal = getUtility(IPloneSiteRoot)
         res = ILeadImagePrefsForm(portal)
     return res