|
| 1 | +from cs_dynamicpages import _ |
| 2 | +from plone import schema |
| 3 | +from plone.autoform.interfaces import IFormFieldProvider |
| 4 | +from plone.supermodel import model |
| 5 | +from Products.CMFPlone.utils import safe_hasattr |
| 6 | +from zope.component import adapter |
| 7 | +from zope.interface import implementer |
| 8 | +from zope.interface import Interface |
| 9 | +from zope.interface import provider |
| 10 | + |
| 11 | + |
| 12 | +class IRowVerticalSpacingMarker(Interface): |
| 13 | + pass |
| 14 | + |
| 15 | + |
| 16 | +@provider(IFormFieldProvider) |
| 17 | +class IRowVerticalSpacing(model.Schema): |
| 18 | + padding_top = schema.Choice( |
| 19 | + title=_("Row padding top"), |
| 20 | + description=_("Select the padding top that this row will have"), |
| 21 | + vocabulary="cs_dynamicpages.RowPaddingTop", |
| 22 | + required=True, |
| 23 | + default="pt-0", |
| 24 | + ) |
| 25 | + padding_bottom = schema.Choice( |
| 26 | + title=_("Row padding bottom"), |
| 27 | + description=_("Select the padding bottom that this row will have"), |
| 28 | + vocabulary="cs_dynamicpages.RowPaddingBottom", |
| 29 | + required=True, |
| 30 | + default="pb-0", |
| 31 | + ) |
| 32 | + margin_top = schema.Choice( |
| 33 | + title=_("Row margin top"), |
| 34 | + description=_("Select the margin top that this row will have"), |
| 35 | + vocabulary="cs_dynamicpages.RowMarginTop", |
| 36 | + required=True, |
| 37 | + default="mt-0", |
| 38 | + ) |
| 39 | + margin_bottom = schema.Choice( |
| 40 | + title=_("Row margin bottom"), |
| 41 | + description=_("Select the margin bottom that this row will have"), |
| 42 | + vocabulary="cs_dynamicpages.RowMarginBottom", |
| 43 | + required=True, |
| 44 | + default="mb-0", |
| 45 | + ) |
| 46 | + |
| 47 | + |
| 48 | +@implementer(IRowVerticalSpacing) |
| 49 | +@adapter(IRowVerticalSpacingMarker) |
| 50 | +class RowVerticalSpacing: |
| 51 | + def __init__(self, context): |
| 52 | + self.context = context |
| 53 | + |
| 54 | + @property |
| 55 | + def padding_top(self): |
| 56 | + if safe_hasattr(self.context, "padding_top"): |
| 57 | + return self.context.padding_top |
| 58 | + return None |
| 59 | + |
| 60 | + @padding_top.setter |
| 61 | + def padding_top(self, value): |
| 62 | + self.context.padding_top = value |
| 63 | + |
| 64 | + @property |
| 65 | + def padding_bottom(self): |
| 66 | + if safe_hasattr(self.context, "padding_bottom"): |
| 67 | + return self.context.padding_bottom |
| 68 | + return None |
| 69 | + |
| 70 | + @padding_bottom.setter |
| 71 | + def padding_bottom(self, value): |
| 72 | + self.context.padding_bottom = value |
| 73 | + |
| 74 | + @property |
| 75 | + def margin_top(self): |
| 76 | + if safe_hasattr(self.context, "margin_top"): |
| 77 | + return self.context.margin_top |
| 78 | + return None |
| 79 | + |
| 80 | + @margin_top.setter |
| 81 | + def margin_top(self, value): |
| 82 | + self.context.margin_top = value |
| 83 | + |
| 84 | + @property |
| 85 | + def margin_bottom(self): |
| 86 | + if safe_hasattr(self.context, "margin_bottom"): |
| 87 | + return self.context.margin_bottom |
| 88 | + return None |
| 89 | + |
| 90 | + @margin_bottom.setter |
| 91 | + def margin_bottom(self, value): |
| 92 | + self.context.margin_bottom = value |
0 commit comments