示例#1
0
class ExpDate(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'Download expiration date')

    def safe_call(self):
        expires = datetime.fromtimestamp(self.wrapper.exp_time)
        return _friendly_date(expires)
示例#2
0
class ATNewsItemExtender(object):
    """ Extender for LandItem
    """
    implements(IOrderableSchemaExtender)

    fields = [
        StringField("long_title",
                    schemata="default",
                    widget=atapi.StringWidget(
                        label=_("Long title"),
                        description=_("The long title for this news item.")),
                    default=""),
    ]

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

    def getOrder(self, schematas):
        """ Manipulate the order in which fields appear.
        """
        schematas['default'] = [
            'id', 'title', 'long_title', 'description', 'text', 'image',
            'imageCaption'
        ]

        return schematas

    def getFields(self):
        return self.fields
示例#3
0
class UserEmail(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'User email')

    def safe_call(self):
        user = api.user.get(self.wrapper.userid)
        return user.getProperty('email')
示例#4
0
class UserName(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'User full name')

    def safe_call(self):
        # Need to get fullname as LDAP does not provide first/last names.
        user = api.user.get(userid=self.wrapper.userid)
        return user.getProperty('fullname') or u''
示例#5
0
 def fiddle(self, schema):
     if not schema.get('image'):
         schema['image'] = ImageField("image",
                                      schemata="default",
                                      sizes=None,
                                      widget=atapi.ImageWidget(
                                          label=_("cover"),
                                          description=_(
                                              "Cover for Publication"))
                                      )
示例#6
0
class LandItemExtender(object):
    """ Extender for LandItem
    """
    implements(ISchemaExtender)

    fields = [
        TextField("text",
                  schemata="default",
                  primary=True,
                  allowable_content_types=('text/html', ),
                  default_content_type='text/html',
                  default_output_type='text/html',
                  widget=atapi.RichWidget(
                      label=_("Metadata"),
                      description=_("Metadata for this item"))),
        StringField("embed",
                    schemata="default",
                    widget=atapi.TextAreaWidget(
                        label=_("Map View"),
                        description=_("Paste here the code provided "
                                      "by your webservice (iframe, jscode)"))),
        TextField(
            "webservices",
            schemata="default",
            primary=False,
            allowable_content_types=('text/html', ),
            default_content_type='text/html',
            default_output_type='text/html',
            widget=atapi.RichWidget(
                label=_("Web Map Services"),
                description=_("Web Map Services available for this data"))),
        TextField("download",
                  schemata="default",
                  primary=False,
                  allowable_content_types=('text/html', ),
                  default_content_type='text/html',
                  default_output_type='text/html',
                  widget=atapi.RichWidget(
                      label=_("Download"),
                      description=_("Download information"))),
        ImageField("legend",
                   schemata="default",
                   sizes=None,
                   widget=atapi.ImageWidget(
                       label=_("Legend"), description=_("Image for Legend"))),
    ]

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

    def getFields(self):
        return self.fields
示例#7
0
 def fiddle(self, schema):
     schema['auto_cover'] = BooleanField(
         "auto_cover",
         schemata="default",
         widget=atapi.BooleanWidget(
             label=_("Generate cover automatically."),
             description=_("Select this to create a cover image based "
                           "on the uploaded file. Only available for "
                           "PDF files.")))
     if not schema.get('image'):
         schema['image'] = ImageField(
             "image",
             schemata="default",
             sizes=None,
             widget=atapi.ImageWidget(
                 label=_("Cover"), description=_("Cover for Publication")))
示例#8
0
class EventExtender(object):
    adapts(IATEvent)
    implements(ISchemaExtender)

    fields = [
        StringField("event_timezone",
                    schemata="default",
                    default=_(u"Time zone: Copenhagen, Denmark"),
                    widget=atapi.StringWidget(
                        label=_("Event timezone info"),
                        description=_("Human readable info about timezone "
                                      "for this event."))),
    ]

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

    def getFields(self):
        return self.fields
示例#9
0
 def fiddle(self, schema):
     schema['auto_cover'] = BooleanField(
         "auto_cover",
         schemata="default",
         widget=atapi.BooleanWidget(
             label=_("Generate cover automatically."),
             description=_(
                  "Select this to create a cover image based "
                  "on the uploaded file. Only available for "
                  "PDF files."
             )
         )
     )
     if not schema.get('image'):
         schema['image'] = ImageField("image",
                                      schemata="default",
                                      sizes=None,
                                      widget=atapi.ImageWidget(
                                          label=_("Cover"),
                                          description=_(
                                              "Cover for Publication"))
                                      )
示例#10
0
class Extender(object):
    """ Extender
    """
    implements(ISchemaExtender)

    fields = [
        BooleanField(
            "frozen",
            schemata="default",
            widget=atapi.BooleanWidget(
                label=_("Freze this item"),
                description=_("Freeze this item and make it unclickable"))),
        ImageField("image",
                   schemata="default",
                   sizes=None,
                   widget=atapi.ImageWidget(
                       label=_("Thumbnail"),
                       description=_("Image for thumbnail"))),
        StringField("url",
                    schemata="default",
                    widget=atapi.StringWidget(
                        label=_("More details URL"),
                        description=_("Provide an external link, if any"))),
        TextField("text",
                  schemata="default",
                  primary=True,
                  allowable_content_types=('text/html', ),
                  default_content_type='text/html',
                  default_output_type='text/html',
                  widget=atapi.RichWidget(
                      label=_("Rich text"),
                      description=_("Detailed body for this item"))),
    ]

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

    def getFields(self):
        return self.fields
class IEnhancedUserDataSchema(IUserDataSchema):
    """ Use all the fields from the default user data schema, and add various
    extra fields.
    """
    first_name = schema.TextLine(
        title=_(u'label_first_name', default=u'Name'),
        description=_(u'help_first_name',
                      default=u'Enter your first name.'),
        required=True,
    )

    last_name = schema.TextLine(
        title=_(u'label_last_name', default=u'Family name'),
        description=_(u'help_last_name',
                      default=u'Enter your last name.'),
        required=True,
    )

    thematic_domain = schema.List(
        title=_(u'label_thematic_domain',
                default=u'Professional thematic domain'),
        value_type=schema.Choice(
            vocabulary=professional_thematic_domain_options),
        required=True,
        constraint=at_least_one_checked
    )

    institutional_domain = schema.List(
        title=_(u'label_institutional_domain',
                default=u'Institutional domain'),
        value_type=schema.Choice(vocabulary=institutional_domain_options),
        required=True,
        constraint=at_least_one_checked
    )

    reason = schema.TextLine(
        title=_(u'label_reason', default=u'Reason to create the account'),
        description=_(u'help_reason',
                      default=u'Fill in the reason for account creation'),
        required=False,
    )

    job_title = schema.TextLine(
        title=_(u'label_job_title', default=u'Job title'),
        description=_(u'help_job_title',
                      default=u'Fill in the job title'),
        required=False,
    )

    postal_address = schema.Text(
        title=_(u'label_postal_address', default=u'Postal address'),
        description=_(u'help_postal_address',
                      default=u'Fill in the postal address'),
        required=False,
    )

    telephone = schema.ASCIILine(
        title=_(u'label_telephone', default=u'Telephone number'),
        description=_(u'help_telephone',
                      default=u'Fill in the telephone number'),
        required=False,
        constraint=validate_phone
    )

    mobile = schema.ASCIILine(
        title=_(u'label_mobile', default=u'Mobile telephone number'),
        description=_(u'help_mobile',
                      default=u'Fill in the mobile telephone number'),
        required=False,
        constraint=validate_phone
    )

    fax = schema.ASCIILine(
        title=_(u'label_fax', default=u'Fax number'),
        description=_(u'help_fax',
                      default=u'Fill in the fax number'),
        required=False,
        constraint=validate_phone
    )

    organisation = schema.TextLine(
        title=_(u'label_organisation', default=u'Organisation'),
        description=_(u'help_organisation',
                      default=u'Fill in the organisation'),
        required=False,
    )

    disclaimer = schema.Bool(
        title=_(u'label_disclaimer', default=u'Accept terms of use'),
        description=_(u'help_disclaimer',
                      default=u"Tick this box to indicate that you have found,"
                      " read and accepted the terms of use for this site. "
                      "Your email will not be further distributed to third "
                      "parties. The registration is only used for reporting "
                      "purposes to the EP and Council."),
        required=True,
        constraint=validateAccept,
    )

    disclaimer_permission = schema.Bool(
        title=_(u'label_disclaimer_permission',
                default=u'I give permission'),
        description=_(
                u'help_disclaimer_permission',
                default=u""),
        required=True,
    )

    phone_numbers = schema.List(
        title=_(u'label_phone_numbers', default=u'Phone numbers'),
        description=_(u'help_phone_numbers',
                      default=u'Fill in phone numbers.'),
        value_type=schema.TextLine(),
        required=False
    )

    institution = schema.TextLine(
        title=_(u'label_institution', default=u'Institution'),
        description=_(u'help_institution',
                      default=u'Fill in the institution'),
        required=False,
    )

    position = schema.TextLine(
        title=_(u'label_position', default=u'Position'),
        description=_(
            u'help_position',
            default=u'Fill in your position within your Institution'),
        required=False,
    )

    from_country = schema.TextLine(
        title=_(u'label_from_country', default=u'From country'),
        description=_(u'help_from_country',
                      default=u'Fill in the From country'),
        required=False,
    )

    from_city = schema.TextLine(
        title=_(u'label_from_city', default=u'From city'),
        description=_(u'help_from_city',
                      default=u'Fill in the From city'),
        required=False,
    )

    address = schema.Text(
        title=_(u'label_address', default=u'Address'),
        description=_(u'help_address',
                      default=u'Fill in the address'),
        required=False,
    )
class ICaptchaSchema(Interface):
    captcha = Captcha(
        title=_(u'Verification'),
        required=False
    )
from plone.app.users.userdataschema import IUserDataSchemaProvider
from zope import schema
from zope.browserpage import ViewPageTemplateFile
from zope.component import getUtility
from zope.formlib import form
from zope.formlib.boolwidgets import CheckBoxWidget
from zope.interface import Interface
from zope.interface import implements
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
import re


professional_thematic_domain_options = SimpleVocabulary([
    # Keep alphabetical order here.
    # Don't use "," in values. The "," is the separator. Replace with "_".
    SimpleTerm(value='Agriculture', title=_(u'Agriculture')),
    SimpleTerm(value='Architectural and Landscape Design',
               title=_(u'Architectural and Landscape Design')),
    SimpleTerm(value='Atmosphere', title=_(u'Atmosphere')),
    SimpleTerm(value='Climate Change', title=_(u'Climate Change')),
    SimpleTerm(value='Demography', title=_(u'Demography')),
    SimpleTerm(value='Ecology and Environment',
               title=_(u'Ecology and Environment')),
    SimpleTerm(value='Emergency Management', title=_(u'Emergency Management')),
    SimpleTerm(value='Energy_ Utilities and Industrial Infrastructure',
               title=_(u'Energy, Utilities and Industrial Infrastructure')),
    SimpleTerm(value='Forestry', title=_(u'Forestry')),
    SimpleTerm(value='Health', title=_(u'Health')),
    SimpleTerm(value='Hydrography', title=_(u'Hydrography')),
    SimpleTerm(value='Mapping', title=_(u'Mapping')),
    SimpleTerm(value='Security', title=_(u'Security')),
示例#14
0
from plone.app.users.browser.register import RegistrationForm
from plone.app.users.browser.personalpreferences import UserDataPanel
from plone.app.users.browser.register import CantChoosePasswordWidget
from Products.CMFCore.interfaces import ISiteRoot
from plone.app.controlpanel.widgets import MultiCheckBoxVocabularyWidget
from zope import schema
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.interface import implements
from zope.browserpage import ViewPageTemplateFile
from zope.formlib.boolwidgets import CheckBoxWidget
from land.copernicus.content.config import EEAMessageFactory as _
import re

professional_thematic_domain_options = SimpleVocabulary([
    # Keep alphabetical order here.
    SimpleTerm(value='Agriculture', title=_(u'Agriculture')),
    SimpleTerm(value='Architectural and Landscape Design',
               title=_(u'Architectural and Landscape Design')),
    SimpleTerm(value='Atmosphere', title=_(u'Atmosphere')),
    SimpleTerm(value='Climate Change', title=_(u'Climate Change')),
    SimpleTerm(value='Demography', title=_(u'Demography')),
    SimpleTerm(value='Ecology and Environment',
               title=_(u'Ecology and Environment')),
    SimpleTerm(value='Emergency Management', title=_(u'Emergency Management')),
    SimpleTerm(value='Energy, Utilities and Industrial Infrastructure',
               title=_(u'Energy, Utilities and Industrial Infrastructure')),
    SimpleTerm(value='Forestry', title=_(u'Forestry')),
    SimpleTerm(value='Health', title=_(u'Health')),
    SimpleTerm(value='Hydrography', title=_(u'Hydrography')),
    SimpleTerm(value='Mapping', title=_(u'Mapping')),
    SimpleTerm(value='Security', title=_(u'Security')),
示例#15
0
class FilesComma(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'List of files, comma separated')

    def safe_call(self):
        return ', '.join(self.wrapper.filenames)
示例#16
0
class FilesStar(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'List of files, newline and leading *')

    def safe_call(self):
        return _starlist(self.wrapper.filenames)
示例#17
0
class NumFiles(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'Number of files')

    def safe_call(self):
        return len(self.wrapper.filenames)
示例#18
0
    def update(self):
        if self.request.REQUEST_METHOD == 'GET':
            # add fields
            subscriber = self.context
            details = subscriber.get_details()
            phones = details.get("phone_numbers", "").split(", ")

            first_name = schema.TextLine(
                __name__="first_name",
                title=_(u'label_first_name', default=u'Name'),
                description=_(u'help_first_name',
                              default=u'Enter your first name.'),
                required=False,
                default=util.toUnicode(details.get("first_name", "")))

            last_name = schema.TextLine(
                __name__="last_name",
                title=_(u'label_last_name', default=u'Family name'),
                description=_(u'help_last_name',
                              default=u'Enter your last name.'),
                required=False,
                default=util.toUnicode(details.get("last_name", "")))

            phone_numbers = schema.List(__name__="phone_numbers",
                                        title=_(u'label_phone_numbers',
                                                default=u'Phone numbers'),
                                        description=_(
                                            u'help_phone_numbers',
                                            default=u'Fill in phone numbers.'),
                                        value_type=schema.TextLine(),
                                        required=False,
                                        default=phones)

            institution = schema.TextLine(
                __name__="institution",
                title=_(u'label_institution', default=u'Organisation'),
                description=_(u'help_institution',
                              default=u'Fill in the organisation'),
                required=False,
                default=util.toUnicode(details.get("institution", "")))

            position = schema.TextLine(
                __name__="position",
                title=_(u'label_position', default=u'Position'),
                description=_(
                    u'help_position',
                    default=u'Fill in your position within your Organisation'),
                required=False,
                default=util.toUnicode(details.get("position", "")))

            from_country = schema.TextLine(
                __name__="from_country",
                title=_(u'label_from_country', default=u'Country'),
                description=_(u'help_from_country',
                              default=u'Fill in your country.'),
                required=False,
                default=util.toUnicode(details.get("from_country", "")))

            from_city = schema.TextLine(
                __name__="from_city",
                title=_(u'label_from_city', default=u'City'),
                description=_(u'help_from_city',
                              default=u'Fill in your city.'),
                required=False,
                default=util.toUnicode(details.get("from_city", "")))

            self.form.fields += Fields(first_name, last_name, phone_numbers,
                                       institution, position, from_country,
                                       from_city)

        if self.request.REQUEST_METHOD == 'POST':
            # save values
            if 'form.buttons.save' in self.request.form:
                prefix = 'form.widgets.'
                userid = self.request.form.get('form.widgets.userid')
                member = api.user.get(userid=userid)
                member.setMemberProperties(
                    mapping={
                        "first_name":
                        self.request.form.get(prefix + 'first_name'),
                        "last_name":
                        self.request.form.get(prefix + 'last_name'),
                        "phone_numbers":
                        self.request.form.get(prefix +
                                              'phone_numbers').split("\r\n"),
                        "institution":
                        self.request.form.get(prefix + 'institution'),
                        "position":
                        self.request.form.get(prefix + 'position'),
                        "from_country":
                        self.request.form.get(prefix + 'from_country'),
                        "from_city":
                        self.request.form.get(prefix + 'from_city'),
                    })
示例#19
0
class MissingFiles(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'Missing files block')

    def safe_call(self):
        return _missing_list(self.wrapper.missing_files) or u''
示例#20
0
class URL(BaseSubstitution):
    category = _(u'Async download')
    description = _(u'Download URL')

    def safe_call(self):
        return self.wrapper.done_url