Esempio n. 1
0
 def delete(self):
     """
     AJAX method to delete a field
     """
     schema = IEditableSchema(self.schema)
     schema.removeField(self.field.getName())
     notify(ObjectRemovedEvent(self.field, self.schema))
     notify(FieldRemovedEvent(self.aq_parent.aq_parent, self.field))
     self.request.response.setHeader('Content-Type', 'application/json')
Esempio n. 2
0
 def delete(self):
     """
     AJAX method to delete a field
     """
     schema = IEditableSchema(self.schema)
     schema.removeField(self.field.getName())
     notify(ObjectRemovedEvent(self.field, self.schema))
     notify(FieldRemovedEvent(self.__parent__.__parent__, self.field))
     self.request.response.setHeader('Content-Type', 'application/json')
Esempio n. 3
0
 def delete(self):
     """
     AJAX method to delete a field
     """
     schema = IEditableSchema(self.schema)
     schema.removeField(self.field.getName())
     notify(ObjectRemovedEvent(self.field, self.schema))
     notify(FieldRemovedEvent(self.aq_parent.aq_parent, self.field))
     self.request.response.setHeader('Content-Type', 'text/html')
Esempio n. 4
0
def upgrade_add_booking_behavior(context):
    portal_types = api.portal.get_tool(name='portal_types')
    event_type = portal_types.get('Event')
    fields = event_type.lookupSchema().names()

    if ('tarifs' not in fields and 'reservation' not in fields):
        # This upgrade step is specific to Liege, where those fields have been
        # added TTW.
        return

    add_behavior('Event', IBooking.__identifier__)
    for brain in api.content.find(portal_type='Event'):
        obj = brain.getObject()
        if getattr(obj, 'tarifs') is not None:
            obj.booking_price = getattr(obj, 'tarifs')
        if getattr(obj, 'reservation') is not None:
            has_booking = getattr(obj, 'reservation')
            if has_booking:
                obj.booking_type = 'mandatory'
            else:
                obj.booking_type = 'no_booking'
    schema = IEditableSchema(event_type.lookupSchema())
    schema.removeField('tarifs')
    schema.removeField('reservation')
Esempio n. 5
0
def upgrade_add_booking_behavior(context):
    portal_types = api.portal.get_tool(name="portal_types")
    event_type = portal_types.get("Event")
    fields = event_type.lookupSchema().names()

    if "tarifs" not in fields and "reservation" not in fields:
        # This upgrade step is specific to Liege, where those fields have been
        # added TTW.
        return

    add_behavior("Event", IBooking.__identifier__)
    for brain in api.content.find(portal_type="Event"):
        obj = brain.getObject()
        if getattr(obj, "tarifs") is not None:
            obj.booking_price = getattr(obj, "tarifs")
        if getattr(obj, "reservation") is not None:
            has_booking = getattr(obj, "reservation")
            if has_booking:
                obj.booking_type = "mandatory"
            else:
                obj.booking_type = "no_booking"
    schema = IEditableSchema(event_type.lookupSchema())
    schema.removeField("tarifs")
    schema.removeField("reservation")