src/pyams_content/shared/logo/zmi/properties.py
changeset 392 8fc847d83992
child 527 5dd1aa8bedd9
equal deleted inserted replaced
391:6cd4434612f5 392:8fc847d83992
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_content.shared.logo import IWfLogo
       
    20 from pyams_form.interfaces.form import IInnerSubForm
       
    21 from pyams_skin.layer import IPyAMSLayer
       
    22 
       
    23 # import packages
       
    24 from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
       
    25 from pyams_utils.adapter import adapter_config
       
    26 from pyams_zmi.form import InnerAdminEditForm
       
    27 from z3c.form import field
       
    28 
       
    29 from pyams_content import _
       
    30 
       
    31 
       
    32 @adapter_config(name='logo-settings',
       
    33                 context=(IWfLogo, IPyAMSLayer, SharedContentPropertiesEditForm),
       
    34                 provides=IInnerSubForm)
       
    35 class LogoPropertiesEditForm(InnerAdminEditForm):
       
    36     """Logo properties edit form extension"""
       
    37 
       
    38     legend = _("Main logo settings")
       
    39     fieldset_class = 'bordered no-x-margin margin-y-10'
       
    40 
       
    41     fields = field.Fields(IWfLogo).select('image', 'url')
       
    42     weight = 1
       
    43 
       
    44     def get_ajax_output(self, changes):
       
    45         if 'image' in changes.get(IWfLogo, ()):
       
    46             return {'status': 'reload',
       
    47                     'message': self.request.localizer.translate(self.successMessage)}
       
    48         else:
       
    49             return super(LogoPropertiesEditForm, self).get_ajax_output(changes)