Example #1
0
class ImageExtender(object):
    adapts(IMonetEvent)
    implements(ISchemaExtender)

    fields = [
        ExtensionBlobImageField(
            'image',
            required=False,
            storage=AnnotationStorage(migrate=True),
            languageIndependent=True,
            max_size=zconf.ATNewsItem.max_image_dimension,
            sizes=None,
            swallowResizeExceptions=zconf.swallowImageResizeExceptions.enable,
            pil_quality=zconf.pil_config.quality,
            pil_resize_algo=zconf.pil_config.resize_algo,
            validators=(('isNonEmptyFile', V_REQUIRED),
                        ('checkNewsImageMaxSize', V_REQUIRED)),
            widget=ImageWidget(
                label=_(u'label_imagedevent_image', default=u'Image'),
                description=_(
                    u'help_imagedevent_image',
                    default=u"Will be shown in views that render content's "
                    u"images and in the event view itself"),
                show_content_type=False,
            ),
        ),
    ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields
Example #2
0
 def _validate_cadence(self, errors, cadence, startdate, enddate):
     if not cadence:
         return
     if cadence and not startdate and not enddate:
         errors['cadence'] = _(
             "do_not_provide_cadence",
             default=u'Start and end date not provided. '
             u'Cadence days are not allowed in that case.')
     startOk = False
     endOk = False
     if startdate and startdate.weekday() in cadence:
         startOk = True
     if enddate and enddate.weekday() in cadence:
         endOk = True
     if not startOk and startdate:
         errors['startDate'] = _(
             "cadence_bound_except_start",
             default=
             u'The start date is not a valid date because is not in the cadence set.'
         )
         return errors
     if not endOk and enddate:
         errors['endDate'] = _(
             "cadence_bound_except_end",
             default=
             u'The end date is not a valid date because is not in the cadence set.'
         )
         return errors
 def getSlotsVocab(self):
     vocab = DisplayList()
     vocab.add('', _(u'-- Unspecified --'))
     vocab.add('morning', _(u'Morning'))
     vocab.add('afternoon', _(u'Afternoon'))
     vocab.add('night', _(u'Evening'))
     vocab.add('allday', _(u'All day long'))
     return vocab
 def getSlotsVocab(self):
     vocab = DisplayList()
     vocab.add('', _(u'-- Unspecified --'))
     vocab.add('morning', _(u'Morning'))
     vocab.add('afternoon', _(u'Afternoon'))
     vocab.add('night', _(u'Evening'))
     vocab.add('allday', _(u'All day long'))
     return vocab
Example #5
0
class MigrateBlobs(formbase.PageForm):
    form_fields = form.FormFields(IMigrateBlobsSchema)
    label = _(u'Blobs Migration')
    description = _(
        u'Migrate all events images, making them use plone.app.blob')

    @form.action(_(u'Migrate events images'))
    def actionMigrate(self, action, data):
        output = migrateMonetEvent(self.context)
        IStatusMessage(self.request).addStatusMessage(output, type='info')
        return self.request.response.redirect(self.context.absolute_url())

    @form.action(_(u'Cancel'))
    def actionCancel(self, action, data):
        return self.request.response.redirect(self.context.absolute_url())
 def getEventTypeVocab(self):
     mp = getToolByName(self, 'portal_properties')
     items = mp.monet_calendar_event_properties.event_types
     vocab = DisplayList()
     for item in items:
         vocab.add(item, _(item))
     return vocab
 def getEventTypeVocab(self):
     mp = getToolByName(self,'portal_properties')
     items = mp.monet_calendar_event_properties.event_types
     vocab = DisplayList()
     for item in items:
         vocab.add(item,_(item))
     return vocab
Example #8
0
    def post_validate(self, REQUEST, errors):
        """Check to make sure that the user give date in the right format/range"""
        # LinguaPlone hack usage; do not run validation when translating
        if '/translate_item' in REQUEST.ACTUAL_URL:
            return

        blacklist = set(REQUEST.get('except', []))
        cadence = [int(x) for x in REQUEST.get('cadence', []) if x]
        including = set(REQUEST.get('including', []))
        startdate = REQUEST.get('startDate', None)
        if startdate:
            startdate = startdate.split(' ')[0].split('-')
            startdate = datetime(int(startdate[0]), int(startdate[1]),
                                 int(startdate[2])).date()
        enddate = REQUEST.get('endDate', None)
        if enddate:
            enddate = enddate.split(' ')[0].split('-')
            enddate = datetime(int(enddate[0]), int(enddate[1]),
                               int(enddate[2])).date()

        # Required field validation. Provide both start and end date, or including
        if (startdate and not enddate) or \
                (not startdate and enddate) or \
                (not startdate and not enddate and not including):
            errors['startDate'] = errors['endDate'] = \
                    _("required_datefields_error",
                      default=u'Start and End date are required, or you must provide the "Include" field')
            return

        # blacklist validation
        self._validate_blacklist(errors, blacklist, startdate, enddate)
        # Check if cadence fill event start and end
        self._validate_cadence(errors, cadence, startdate, enddate)
    def post_validate(self, REQUEST, errors):
        """Check to make sure that the user give date in the right format/range"""
        # LinguaPlone hack usage; do not run validation when translating
        if '/translate_item' in REQUEST.ACTUAL_URL:
            return

        blacklist = set(REQUEST.get('except', []))
        cadence = [int(x) for x in REQUEST.get('cadence', []) if x]
        including = set(REQUEST.get('including', []))
        startdate = REQUEST.get('startDate', None)
        if startdate:
            startdate = startdate.split(' ')[0].split('-')
            startdate = datetime(int(startdate[0]),int(startdate[1]),int(startdate[2])).date()
        enddate = REQUEST.get('endDate', None)
        if enddate:
            enddate = enddate.split(' ')[0].split('-')
            enddate = datetime(int(enddate[0]),int(enddate[1]),int(enddate[2])).date()

        # Required field validation. Provide both start and end date, or including
        if (startdate and not enddate) or \
                (not startdate and enddate) or \
                (not startdate and not enddate and not including):
            errors['startDate'] = errors['endDate'] = \
                    _("required_datefields_error",
                      default=u'Start and End date are required, or you must provide the "Include" field')
            return

        # blacklist validation
        self._validate_blacklist(errors, blacklist, startdate, enddate)
        # Check if cadence fill event start and end
        self._validate_cadence(errors, cadence, startdate, enddate)
 def _get_days_vocab(self):
     return DisplayList([('0',_('Monday')),
                        ('1',_('Tuesday')),
                        ('2',_('Wednesday')),
                        ('3',_('Thursday')),
                        ('4',_('Friday')),
                        ('5',_('Saturday')),
                        ('6',_('Sunday'))])
 def _validate_cadence(self, errors, cadence, startdate, enddate):
     if not cadence:
         return
     if cadence and not startdate and not enddate:
             errors['cadence'] = _("do_not_provide_cadence",
                                  default=u'Start and end date not provided. '
                                          u'Cadence days are not allowed in that case.')            
     startOk = False
     endOk = False
     if startdate and startdate.weekday() in cadence:
         startOk = True
     if enddate and enddate.weekday() in cadence:
         endOk = True
     if not startOk and startdate:
         errors['startDate'] = _("cadence_bound_except_start",
                                 default=u'The start date is not a valid date because is not in the cadence set.')
         return errors
     if not endOk and enddate:
         errors['endDate'] = _("cadence_bound_except_end",
                               default=u'The end date is not a valid date because is not in the cadence set.')
         return errors
    def _validate_blacklist(self, errors, blacklist, startdate, enddate):
        if not blacklist:
            return
        if blacklist and not startdate and not enddate:
                errors['except'] = _("do_not_provide_except",
                                     default=u'Start and end date not provided. '
                                             u'Except days are not allowed in that case.')            
        for black in blacklist:
            try:
                black = black.split('-')
                datee = datetime(int(black[0]), int(black[1]), int(black[2])).date()
            except:
                errors['except'] = _("description_except",
                                     default=u'Enter the dates in the form yyyy-mm-dd')
                return

            if startdate and datee < startdate:
                errors['except'] = _("interval_except",
                                     default=u'One or more dates are not in the previous range [Start event - End event]')
                return errors
            if enddate and datee > enddate:
                errors['except'] = _("interval_except",
                                     default=u'One or more dates are not in the previous range [Start event - End event]')
                return

            if startdate and datee==startdate:
                errors['startDate'] = _("except_bound_except_start",
                                     default=u'The start date is not a valid date because an except entry invalidate it.')
                return

            if enddate and datee==enddate:
                errors['endDate'] = _("except_bound_except_end",
                                     default=u'The end date is not a valid date because an except entry invalidate it.')
                return
Example #13
0
    def _validate_blacklist(self, errors, blacklist, startdate, enddate):
        if not blacklist:
            return
        if blacklist and not startdate and not enddate:
            errors['except'] = _("do_not_provide_except",
                                 default=u'Start and end date not provided. '
                                 u'Except days are not allowed in that case.')
        for black in blacklist:
            try:
                black = black.split('-')
                datee = datetime(int(black[0]), int(black[1]),
                                 int(black[2])).date()
            except:
                errors['except'] = _(
                    "description_except",
                    default=u'Enter the dates in the form yyyy-mm-dd')
                return

            if startdate and datee < startdate:
                errors['except'] = _(
                    "interval_except",
                    default=
                    u'One or more dates are not in the previous range [Start event - End event]'
                )
                return errors
            if enddate and datee > enddate:
                errors['except'] = _(
                    "interval_except",
                    default=
                    u'One or more dates are not in the previous range [Start event - End event]'
                )
                return

            if startdate and datee == startdate:
                errors['startDate'] = _(
                    "except_bound_except_start",
                    default=
                    u'The start date is not a valid date because an except entry invalidate it.'
                )
                return

            if enddate and datee == enddate:
                errors['endDate'] = _(
                    "except_bound_except_end",
                    default=
                    u'The end date is not a valid date because an except entry invalidate it.'
                )
                return
Example #14
0
from Products.ATContentTypes.content.image import ATImageSchema
from Products.ATContentTypes.lib.imagetransform import ATCTImageTransform
from Products.ATContentTypes.permission import ChangeEvents
from Products.ATContentTypes.configuration import zconf
from AccessControl import ClassSecurityInfo
from Products.CMFCore import permissions

EventSchema = RecurringEventSchema.copy() + Schema((
    LinesField('eventType',
               required=True,
               searchable=False,
               languageIndependent=True,
               enforceVocabulary=True,
               vocabulary='getEventTypeVocab',
               widget=MultiSelectionWidget(format='checkbox',
                                           label=_(u'label_event_type',
                                                   default=u'Event Type(s)'))),
    StringField(
        'slots',
        required=True,
        searchable=False,
        languageIndependent=True,
        vocabulary='getSlotsVocab',
        default='',
        widget=SelectionWidget(
            format='select',
            label=_(u'label_slots', default=u'Time slots'),
            description=_(
                u'help_slots',
                default=
                u'Select the time of day on which the event takes place.'))),
    TextField(
Example #15
0
from Products.ATContentTypes.permission import ChangeEvents
from Products.ATContentTypes.configuration import zconf
from AccessControl import ClassSecurityInfo
from Products.CMFCore import permissions

EventSchema = RecurringEventSchema.copy() + Schema((

    LinesField('eventType',
               required=True,
               searchable=False,
               languageIndependent=True,
               enforceVocabulary=True,
               vocabulary='getEventTypeVocab',
               widget = MultiSelectionWidget(
                        format = 'checkbox',
                        label = _(u'label_event_type', default=u'Event Type(s)')
                        )),

    StringField('slots',
                required=True,
                searchable=False,
                languageIndependent=True,
                vocabulary='getSlotsVocab',
                default='',
                widget=SelectionWidget(
                        format = 'select',
                        label = _(u'label_slots', default=u'Time slots'),
                        description = _(u'help_slots', default=u'Select the time of day on which the event takes place.')
                        )),

    TextField('time',
UID:ATEvent-%(uid)s
SEQUENCE:0
LAST-MODIFIED:%(modified)s
SUMMARY:%(summary)s
"""


RECURRING_EVENT_SCHEMA = atapi.Schema((
         
        LinesField(
            'cadence',
            required= False,
            vocabulary='_get_days_vocab',
            widget = MultiSelectionWidget(
                format = 'checkbox',
                label=_("label_cadence", default=u"Cadence"),
                description=_("description_cadence",
                              default=u"You can set the actual days of the event in the date range specified above.\n"
                                      u"If you don't set this field the event takes place every day of the week."),
                ),
            enforceVocabulary=True,
            languageIndependent=True
        ),
                                     
        LinesField(
            'except',
            required= False,
            widget = CalendarInAndOutWidget(
                label=_("label_except", default=u"Except"),
                description=_("description_field_except",
                              default=u"In this field you can set the list of days on which the event is not held.\n"
Example #17
0
 def _get_days_vocab(self):
     return DisplayList([('0', _('Monday')), ('1', _('Tuesday')),
                         ('2', _('Wednesday')), ('3', _('Thursday')),
                         ('4', _('Friday')), ('5', _('Saturday')),
                         ('6', _('Sunday'))])
Example #18
0
DTSTART:%(startdate)s
DTEND:%(enddate)s
UID:ATEvent-%(uid)s
SEQUENCE:0
LAST-MODIFIED:%(modified)s
SUMMARY:%(summary)s
"""

RECURRING_EVENT_SCHEMA = atapi.Schema((
    LinesField(
        'cadence',
        required=False,
        vocabulary='_get_days_vocab',
        widget=MultiSelectionWidget(
            format='checkbox',
            label=_("label_cadence", default=u"Cadence"),
            description=
            _("description_cadence",
              default=
              u"You can set the actual days of the event in the date range specified above.\n"
              u"If you don't set this field the event takes place every day of the week."
              ),
        ),
        enforceVocabulary=True,
        languageIndependent=True),
    LinesField(
        'except',
        required=False,
        widget=CalendarInAndOutWidget(
            label=_("label_except", default=u"Except"),
            description=_(