def __call__(self): form = self.request.form cropping_util = self.context.restrictedTraverse('@@crop-image') if form.get('form.button.Delete', None) is not None: cropping_util._remove(self.fieldname, self.request.form.get('scalename')) IStatusMessage(self.request).add(_(u"Cropping area deleted")) if form.get('form.button.Save', None) is not None: x1 = int(round(float(self.request.form.get('x1')))) y1 = int(round(float(self.request.form.get('y1')))) x2 = int(round(float(self.request.form.get('x2')))) y2 = int(round(float(self.request.form.get('y2')))) scale_name = self.request.form.get('scalename') # Avoid browser cache self.context.setModificationDate(DateTime()) cropping_util._crop(fieldname=self.fieldname, scale=scale_name, box=(x1, y1, x2, y2), interface=self.interface) IStatusMessage(self.request).add( _(u"Successfully saved cropped area")) # disable columns self.request.set('disable_plone.leftcolumn', 1) self.request.set('disable_plone.rightcolumn', 1) return self.template()
def __call__(self): form = self.request.form cropping_util = self.context.restrictedTraverse('@@crop-image') if form.get('form.button.Delete', None) is not None: cropping_util._remove(self.fieldname, self.request.form.get('scalename')) IStatusMessage(self.request).add(_(u"Cropping area deleted")) if form.get('form.button.Save', None) is not None: x1 = int(round(float(self.request.form.get('x1')))) y1 = int(round(float(self.request.form.get('y1')))) x2 = int(round(float(self.request.form.get('x2')))) y2 = int(round(float(self.request.form.get('y2')))) scale_name = self.request.form.get('scalename') cropping_util._crop(fieldname=self.fieldname, scale=scale_name, box=(x1, y1, x2, y2), interface=self.interface) IStatusMessage(self.request).add( _(u"Successfully saved cropped area")) # disable columns self.request.set('disable_plone.leftcolumn', 1) self.request.set('disable_plone.rightcolumn', 1) return self.template()
def __call__(self): form = self.request.form cropping_util = self.context.restrictedTraverse('@@crop-image') if form.get('form.button.Cancel', None) is not None: if self.request.form.get("came_from", None): came_from = self.request.form.get("came_from") return self.request.response.redirect( uuidToObject(came_from).absolute_url()) return self.request.response.redirect( self.context.absolute_url() + '/view') if form.get('form.button.Delete', None) is not None: cropping_util._remove(self.fieldname, self.request.form.get('scalename')) IStatusMessage(self.request).add(_(u"Cropping area deleted")) if form.get('form.button.Save', None) is not None: x1 = int(round(float(self.request.form.get('x1')))) y1 = int(round(float(self.request.form.get('y1')))) x2 = int(round(float(self.request.form.get('x2')))) y2 = int(round(float(self.request.form.get('y2')))) scale_name = self.request.form.get('scalename') cropping_util._crop(fieldname=self.fieldname, scale=scale_name, box=(x1, y1, x2, y2), interface=self.interface) IStatusMessage(self.request).add( _(u"Successfully saved cropped area")) # disable columns self.request.set('disable_plone.leftcolumn', 1) self.request.set('disable_plone.rightcolumn', 1) return self.template()
class ISettings(Interface): """ Define settings data structure """ large_size = TextLine( title=_(u"Crop Editor Large Size"), description=_(u"width:height"), required=False, default=u"768:768", ) min_size = TextLine( title=_(u"Minimum Crop Area Size"), description=_(u"width:height"), required=False, default=u"50:50", ) constrain_cropping = Bool( title=_(u"Enable to constrain cropable scales"), description=_(u"Enable to reduce the scales shown for cropping in the " u"list of scales with crop support."), default=False, required=False, ) cropping_for = List( title=_(u"List of scales with crop support"), description=_(u"Select the scales with cropping support enabled. Only " u"active if enabled with checkbox."), required=False, default=[], value_type=Choice(vocabulary="plone.app.imagecropping.all_sizes"), ) """ XXX: not implemented right now
class SettingsEditForm(RegistryEditForm): """ Define form logic """ form.extends(RegistryEditForm) schema = ISettings label = _(u"Image Cropping Settings")
def __call__(self): form = self.request.form if form.get('form.button.Delete', None) is not None: cropping_util = self.context.restrictedTraverse('@@crop-image') cropping_util._remove(self.fieldname, form.get('scalename')) IStatusMessage(self.request).add(_(u'Cropping area deleted')) if form.get('form.button.Save', None) is not None: self._crop() IStatusMessage(self.request).add( _(u'Successfully saved cropped area')) # disable columns self.request.set('disable_plone.leftcolumn', 1) self.request.set('disable_plone.rightcolumn', 1) return self.template()
def go_back_title(self): if self.request.form.get('form.button.Save', None) is not None \ or self.request.form.get('form.button.Delete', None) is \ not None: if self.request.form.get("came_from", None): came_from = self.request.form.get("came_from") if uuidToObject(came_from): return _(u"Go back to ") + uuidToObject(came_from).title
class ISettings(Interface): ' Define settings data structure ' constrain_cropping = schema.Bool( title=_(u'Enable to constrain croppable scales'), description=_(u'Enable to reduce the scales shown for cropping in the ' u'list of scales with crop support.'), default=False, required=False, ) cropping_for = schema.List( title=_(u'List of scales with crop support'), description=_(u'Select the scales with cropping support enabled. Only ' u'active if enabled with checkbox.'), required=False, default=[], value_type=schema.Choice( vocabulary='plone.app.imagecropping.all_sizes'), ) """XXX: not implemented right now
def js_messages(self): return JS_MESSAGES % dict( discard_changes=_("Your changes will be lost. Continue?") )
def js_messages(self): return JS_MESSAGES % dict( discard_changes=_("Your changes will be lost. Continue?"))
def translated_confirm_discard_changes(self): # Escape for javascript return translate( _(u'Your changes will be lost. Continue?'), target_language=self.request.get('LANGUAGE', 'en'), ).replace('\'', '\\\'')