Exemplo n.º 1
0
class IProject(model.Schema):
    """ Marker interface and Dexterity Python Schema for Project
    """

    area = schema.Text(
        title=_('Area'),
        required=True,
    )

    owner = schema.TextLine(
        title=_('Owner'),
        required=True,
    )

    occupant = schema.Text(
        title=_('Occupant'),
        required=False,
    )

    availability = schema.Text(
        title=_('Availability'),
        required=False,
    )

    occupationStart = schema.Date(
        title=_('Start of occupation'),
        required=False,
    )

    cultivationType = schema.Text(
        title=_('Type of cultivation'),
        required=False,
    )

    orientation = schema.Text(
        title=_('Orientation'),
        required=False,
    )

    accessibility = schema.Text(
        title=_('Accessibility'),
        required=False,
    )

    address = schema.TextLine(
        title=_('Address'),
        required=False,
    )

    image = NamedBlobImage(
        title=_('Lead image'),
        required=False,
    )
Exemplo n.º 2
0
class ILabels(model.Schema):
    model.fieldset(
        'categorization',
        label=CPMF(u'label_schema_categorization', default=u'Categorization'),
        fields=['labels'],
    )

    form.widget(labels='collective.z3cform.keywordwidget.widget.KeywordFieldWidget')  # noqa
    labels = Keywords(
        title=_(u'Labels'),
        description=_(u'Labels displayed under the content body'),
        required=False,
        # Automatically get the index in catalog by name
        index_name='labels',
    )
Exemplo n.º 3
0
class HORECASubscriptionForm(Form):
    implements(ILocalProducerForm)
    label = _(u'Subscription as a HORECA business')
    fields = field.Fields(IProfessionnalsRegistration).select(
        'business_name',
        'purchasing_manager',
        'horeca_address',
        'horeca_phone_number',
        'horeca_mobile',
        'horeca_email',
        'horeca_company_number',
        'wanted_products',
        'localfood_chart_acceptation',
        'genuine_form_data',
    )

    ignoreContext = True

    @button.buttonAndHandler(_(u'Confirm'))
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        else:
            mailer = NoveltyMailer('horeca')
            mailer.notify_updates(data.get('wanted_products', []))

            api.group.add_user(
                groupname='horeca_business',
                user=api.user.get_current())  # TODO: check if not already in
            self.store_prefs(data)
            api.portal.show_message(
                message=_(u'Your preferences have been recorded.'),
                request=self.request,
                type='info',
            )

    def store_prefs(self, data):
        data_dict = {
            '{0}_{1}'.format(PROPERTY_PREFIX, key): value or ''
            for (key, value) in data.iteritems()
        }
        member = api.user.get_current()
        member.setMemberProperties(mapping=data_dict)
Exemplo n.º 4
0
 def extract_horeca_contact(self, user, products):
     wanted_products = set(user.getProperty('localfood_wanted_products',
                                            []))  # noqa
     if wanted_products.intersection(products):
         return (
             [(_(t), user.getProperty('localfood_{0}'.format(k)))
              for k, t in self._horeca_contact],
             wanted_products.intersection(products),
         )
Exemplo n.º 5
0
class ContactCardViewlet(base.ViewletBase):

    # XXX Should be improved to by more dynamic
    _fields = (
        (_(u'Lastname'), 'lastname'),
        (_(u'Firstname'), 'firstname'),
        (_(u'Organization'), 'organization'),
        (_(u'Address'), 'contact_address'),
        (CPMF('Phones'), 'phone'),
        (CCMF('Cell phone'), 'cell_phone'),
        (CCMF(u'Fax'), 'fax'),
        (CCMF(u'Email'), 'email'),
        (CCMF(u'Website'), 'website'),
    )

    @property
    def can_view(self):
        return len(self.widgets) > 0

    @property
    def widgets(self):
        """ Return a list of dictionary with widgets label and values """
        return [{
            'label': k,
            'value': self.format_value(v)
        } for k, v in self._fields if self.has_value(v)]

    def has_value(self, key):
        if self.get_value(key):
            return True
        return False

    def get_value(self, key):
        return getattr(self.context, key, None)

    def format_value(self, key, separator=u', '):
        value = self.get_value(key)
        if isinstance(value, basestring):
            return value
        if isinstance(value, collections.Iterable):
            return separator.join(value)
        return value
Exemplo n.º 6
0
    def send_emails_to(self, users):
        for user in users:
            recipient = user.getProperty('email')
            if not recipient:
                continue
            body = _(u'''
Bonjour,

Une correspondance a été trouvée pour l'un des produits que vous avez sélectionné.
Rendez-vous sur https://alimentation-locale.liege.be/professionnels pour en savoir plus sur votre nouvel interlocuteur.

Merci de faire le choix de l'alimentation locale, saine et durable.

Alimentation locale @ Liège''')
            api.portal.send_email(sender='*****@*****.**',
                                  recipient=recipient,
                                  subject=translate(
                                      _(u'New match(es) found for you'),
                                      target_language='fr'),
                                  body=body,
                                  immediate=False)
Exemplo n.º 7
0
class IContactCard(directorycontact.IDirectoryContactDetails):

    form.omitted('use_parent_address')
    form.omitted('street')
    form.omitted('number')
    form.omitted('additional_address_details')
    form.omitted('zip_code')
    form.omitted('city')
    form.omitted('region')
    form.omitted('country')
    form.omitted('im_handle')

    model.fieldset(
        'address',
        label=CCMF(u'Address'),
        fields=['lastname', 'firstname', 'organization', 'contact_address'],
    )

    lastname = schema.TextLine(
        title=_(u'Lastname'),
        required=False,
    )

    firstname = schema.TextLine(
        title=_(u'Firstname'),
        required=False,
    )

    organization = schema.TextLine(
        title=_(u'Organization'),
        required=False,
    )

    contact_address = schema.TextLine(
        title=_('Address'),
        required=False,
    )
Exemplo n.º 8
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        else:
            mailer = NoveltyMailer('horeca')
            mailer.notify_updates(data.get('wanted_products', []))

            api.group.add_user(
                groupname='horeca_business',
                user=api.user.get_current())  # TODO: check if not already in
            self.store_prefs(data)
            api.portal.show_message(
                message=_(u'Your preferences have been recorded.'),
                request=self.request,
                type='info',
            )
Exemplo n.º 9
0
class ICommunityGarden(model.Schema):
    """ Marker interface and Dexterity Python Schema for CommunityGarden
    """

    owner = schema.TextLine(
        title=_('Owner'),
        required=False,
    )

    project_author = schema.TextLine(
        title=_('Project Author'),
        required=False,
    )

    manager = schema.TextLine(
        title=_('Manager'),
        required=False,
    )

    inauguration = schema.TextLine(
        title=_('Inauguration'),
        required=False,
    )

    gardener = schema.TextLine(
        title=_('Gardener'),
        required=False,
    )

    address = schema.TextLine(
        title=_('Address'),
        required=False,
    )

    image = NamedBlobImage(
        title=_('Lead image'),
        required=False,
    )
Exemplo n.º 10
0
def must_be_checked(value):
    if value:
        return True
    raise Invalid(_("In order to continue, you must check this box."))
Exemplo n.º 11
0
class IProfessionnalsRegistration(Interface):
    producer_name = schema.TextLine(
        title=_(u'Producer name'),
        required=True,
    )

    business_name = schema.TextLine(
        title=_(u'Business name'),
        required=True,
    )

    purchasing_manager = schema.TextLine(
        title=_(u'Purchasing manager'),
        required=True,
    )

    producer_address = schema.TextLine(
        title=_(u'Address'),
        required=True,
    )

    horeca_address = schema.TextLine(
        title=_(u'Address'),
        required=True,
    )

    producer_company_number = schema.TextLine(
        title=_(u'Company number'),
        required=True,
    )

    horeca_company_number = schema.TextLine(
        title=_(u'Company number'),
        required=True,
    )

    producer_phone_number = schema.TextLine(
        title=_(u'Contact phone number'),
        required=True,
    )

    producer_mobile = schema.TextLine(
        title=_(u'Contact mobile'),
        required=False,
    )

    producer_email = schema.TextLine(
        title=_(u'Contact email'),
        required=True,
    )

    horeca_phone_number = schema.TextLine(
        title=_(u'Contact phone number'),
        required=True,
    )

    horeca_mobile = schema.TextLine(
        title=_(u'Contact mobile'),
        required=False,
    )

    horeca_email = schema.TextLine(
        title=_(u'Contact email'),
        required=True,
    )

    localfood_chart_acceptation = schema.Bool(
        title=_(u'I accept the chart conditions.'),
        required=True,
        constraint=must_be_checked,
    )

    genuine_form_data = schema.Bool(
        title=_(u'The data I provide is genuine.'),
        required=True,
        constraint=must_be_checked,
    )

    genuine_form_data_and_quality = schema.Bool(
        title=_(u'The data I provide is genuine, the products are fine.'),
        required=True,
        constraint=must_be_checked,
    )

    directives.widget(proposed_products=MultiSelect2FieldWidget)
    proposed_products = schema.List(
        title=_(u'Proposed product types'),
        description=_(u'Please select the types of product you can propose'),
        value_type=schema.Choice(
            title=_(u'Product types'),
            vocabulary='collective.taxonomy.typesproduits',
        ),
        required=True,
        constraint=must_have_selection,
    )

    directives.widget(wanted_products=MultiSelect2FieldWidget)
    wanted_products = schema.List(
        title=_(u'Wanted product types'),
        description=_(u'Please select the types of product you want to find'),
        value_type=schema.Choice(
            title=_(u'Product types'),
            vocabulary='collective.taxonomy.typesproduits',
        ),
        required=True,
        constraint=must_have_selection,
    )