예제 #1
0
class ILocaleDayContext(Interface):
    """Specifices a usage context for days names"""

    type = TextLine(
        title=u"Day context type",
        description=u"Name of the day context, format or stand-alone.")

    defaultWidth = TextLine(
        title=u"Default day name width",
        default=u"wide")

    days = Dict(
        title=u"Day Names",
        description=(u"A mapping of day name widths to a mapping of"
                     u"corresponding day names."),
        key_type=Choice(
            title=u"Width type",
            values=(u"wide", u"abbreviated", u"narrow")),
        value_type=Dict(
            title=u"Day name",
            key_type=Choice(
                title=u"Type",
                values=(u"sun", u"mon", u"tue", u"wed",
                        u"thu", u"fri", u"sat")),
            value_type=TextLine(title=u"Day Name"))
    )
예제 #2
0
class IProjectionExperiment(IExperiment):

    # TODO: ignore context here? don't really need to store this?
    directives.widget(
        'species_distribution_models',
        ExperimentSDMFieldWidget,
        experiment_type=[ISDMExperiment.__identifier__],
        errmsg=u"Please select at least 1 Species Distribution Model")
    species_distribution_models = Dict(
        title=u'Species Distribution Models',
        key_type=TextLine(),
        value_type=Dict(key_type=TextLine(), value_type=Dict()),
        default=None,
        required=True,
    )

    directives.widget(
        'future_climate_datasets',
        FutureDatasetsFieldWidget,
        errmsg=u"Please select at least 1 future climate dataset.",
        vizclass=u'bccvl-absence-viz')
    future_climate_datasets = List(title=u'Future Climate Data',
                                   value_type=TextLine(),
                                   default=None,
                                   required=True)

    directives.mode(projection_region=HIDDEN_MODE)
    directives.widget('projection_region', TextAreaFieldWidget)
    projection_region = NamedBlobFile(
        title=u"Projection Region",
        description=
        u"GEOJson describing the geographic region the onto which the selected model is projected,",
        required=False,
    )
예제 #3
0
class IRelevantAceContentItemsTile(ISearchAceContentTile):

    show_share_btn = Bool(
        title=_(u"Show the share button"),
        default=False,
    )

    combine_results = Bool(
        title=_(u"Show listing results, in addition to assigned items"),
        default=False,
    )

    uuids = Dict(
        title=_(u"Elements"),
        key_type=TextLine(),
        value_type=Dict(
            key_type=TextLine(),
            value_type=TextLine(),
        ),
        required=False,
    )

    sortBy = Choice(
        title=_(u"Sort order for results and assigned items"),
        vocabulary=sortby_vocabulary,
    )

    form.omitted("uuids")
예제 #4
0
class IBiodiverseExperiment(IExperiment):

    # - Opt1 ... select experiments and pick datasets from experiment (like experimend sdm model select)
    # - Opt2 ... I think it's better to select datasets and show them grouped by grouping criteria for biodiverse. May make searching easier as well?
    # - Opt3 ... set criteria for grouping on page, and make search interface for specise only...
    #            restricts to single biodiverse experiment?.
    # - Opt4 ... make different interfaces .... optimised for different interests

    # Key is the dataset uuid and value a threstold to apply
    directives.widget('projection',
                      ExperimentResultProjectionFieldWidget,
                      experiment_type=[
                          ISDMExperiment.__identifier__,
                          IProjectionExperiment.__identifier__
                      ],
                      errmsg=u"Please select at least 1 dataset.")
    projection = Dict(
        title=u'Source Experiments',
        key_type=TextLine(),
        value_type=Dict(key_type=TextLine(), value_type=Dict()),
        required=True,
    )

    cluster_size = Choice(
        title=u'Biodiverse cell size',
        description=u'x/y cell size in meter',
        default=5000,
        required=True,
        values=(1000, 5000, 10000, 20000, 50000),
    )
예제 #5
0
class ILocaleDates(Interface):
    """This object contains various data about dates, times and time zones."""

    localizedPatternChars = TextLine(
        title=_u("Localized Pattern Characters"),
        description=_u("Localized pattern characters used in dates and times"))

    calendars = Dict(
        title=_u("Calendar type to ILocaleCalendar"),
        key_type=Choice(title=_u("Calendar Type"),
                        values=(_u("gregorian"), _u("arabic"), _u("chinese"),
                                _u("civil-arabic"), _u("hebrew"),
                                _u("japanese"), _u("thai-buddhist"))),
        value_type=Field(title=_u("Calendar"),
                         description=_u("This is a ILocaleCalendar object.")))

    timezones = Dict(title=_u("Time zone type to ILocaleTimezone"),
                     key_type=TextLine(title=_u("Time Zone type")),
                     value_type=Field(
                         title=_u("Time Zone"),
                         description=_u("This is a ILocaleTimeZone object.")))

    def getFormatter(category,
                     length=None,
                     name=None,
                     calendar=_u("gregorian")):
        """Get a date/time formatter.
예제 #6
0
class IGitActivity(Interface):
    """An activity log entry for a Git repository."""

    id = Int(title=_("ID"), readonly=True, required=True)

    repository = Reference(
        title=_("Repository"),
        required=True,
        readonly=True,
        schema=IGitRepository,
        description=_("The repository that this log entry is for."))

    date_changed = Datetime(
        title=_("Date changed"),
        required=True,
        readonly=True,
        description=_("The time when this change happened."))

    changer = PublicPersonChoice(
        title=_("Changer"),
        required=True,
        readonly=True,
        vocabulary="ValidPerson",
        description=_("The user who made this change."))

    changee = PersonChoice(
        title=_("Changee"),
        required=False,
        readonly=True,
        vocabulary="ValidPersonOrTeam",
        description=_("The person or team that this change was applied to."))

    changee_description = Attribute(
        "A human-readable description of the changee.")

    what_changed = Choice(
        title=_("What changed"),
        required=True,
        readonly=True,
        vocabulary=GitActivityType,
        description=_("The property of the repository that changed."))

    old_value = Dict(
        title=_("Old value"),
        required=False,
        readonly=True,
        description=_("Representation of the value before the change."),
        key_type=TextLine(),
        value_type=Text())

    new_value = Dict(
        title=_("New value"),
        required=False,
        readonly=True,
        description=_("Representation of the value after the change."),
        key_type=TextLine(),
        value_type=Text())
예제 #7
0
 def testValidate(self):
     field = Dict(title=u'Dict field',
                  description=u'', readonly=False, required=False)
     field.validate(None)
     field.validate({})
     field.validate({1: 'foo'})
     field.validate({'a': 1})
예제 #8
0
class ILiveFSEditableAttributes(IHasOwner):
    """`ILiveFS` attributes that can be edited.

    These attributes need launchpad.View to see, and launchpad.Edit to change.
    """
    date_last_modified = exported(Datetime(
        title=_("Date last modified"), required=True, readonly=True))

    owner = exported(PersonChoice(
        title=_("Owner"), required=True, readonly=False,
        vocabulary="AllUserTeamsParticipationPlusSelf",
        description=_("The owner of this live filesystem image.")))

    distro_series = exported(Reference(
        IDistroSeries, title=_("Distro Series"), required=True, readonly=False,
        description=_("The series for which the image should be built.")))

    name = exported(TextLine(
        title=_("Name"), required=True, readonly=False,
        constraint=name_validator,
        description=_("The name of the live filesystem image.")))

    metadata = exported(Dict(
        title=_(
            "A dict of data about the image.  Entries here will be passed to "
            "the builder slave."),
        key_type=TextLine(), required=True, readonly=False))
예제 #9
0
class ILocaleTimeZone(Interface):
    """Represents and defines various timezone information. It mainly manages
    all the various names for a timezone and the cities contained in it.

    Important: ILocaleTimeZone objects are not intended to provide
    implementations for the standard datetime module timezone support. They
    are merily used for Locale support.
    """

    type = TextLine(
        title=u"Time Zone Type",
        description=u"Standard name of the timezone for unique referencing.",
        required=True,
        readonly=True)

    cities = List(title=u"Cities",
                  description=u"Cities in Timezone",
                  value_type=TextLine(title=u"City Name"),
                  required=True,
                  readonly=True)

    names = Dict(title=u"Time Zone Names",
                 description=u"Various names of the timezone.",
                 key_type=Choice(title=u"Time Zone Name Type",
                                 values=(u'generic', u'standard',
                                         u'daylight')),
                 value_type=Tuple(title=u"Time Zone Name and Abbreviation",
                                  min_length=2,
                                  max_length=2),
                 required=True,
                 readonly=True)
예제 #10
0
class ISnapBaseEditableAttributes(Interface):
    """`ISnapBase` attributes that can be edited.

    Anyone can view these attributes, but they need launchpad.Edit to change.
    """

    name = exported(
        SnapBaseNameField(title=_("Name"),
                          required=True,
                          readonly=False,
                          constraint=name_validator))

    display_name = exported(
        TextLine(title=_("Display name"), required=True, readonly=False))

    distro_series = exported(
        Reference(IDistroSeries,
                  title=_("Distro series"),
                  required=True,
                  readonly=False))

    build_channels = exported(
        Dict(
            title=_("Source snap channels for builds"),
            key_type=TextLine(),
            required=True,
            readonly=False,
            description=_(
                "A dictionary mapping snap names to channels to use when building "
                "snaps that specify this base.")))
예제 #11
0
class ILocaleMonthContext(Interface):
    """Specifices a usage context for month names"""

    type = TextLine(
        title=u'Month context type',
        description=u"Name of the month context, format or stand-alone.")

    defaultWidth = TextLine(title=u'Default month name width', default=u'wide')

    months = Dict(title=u'Month Names',
                  description=u'A mapping of month name widths to a mapping of'
                  u'corresponding month names.',
                  key_type=Choice(title=u'Width type',
                                  values=(u'wide', u'abbreviated', u'narrow')),
                  value_type=Dict(title=u'Month name',
                                  key_type=Int(title=u'Type', min=1, max=12),
                                  value_type=TextLine(title=u'Month Name')))
예제 #12
0
    def testValidateRequired(self):
        field = Dict(title=u'Dict field',
                     description=u'', readonly=False, required=True)
        field.validate({})
        field.validate({1: 'foo'})
        field.validate({'a': 1})

        self.assertRaises(RequiredMissing, field.validate, None)
예제 #13
0
class IMembershipList(ISubscriptionList):
    allowed_senders = Set()  #email addresses of all allowed senders
    allowed_senders_data = Dict()  #full dictionary of emails and userid for

    #allowed senders and their subscription status

    def is_allowed_sender(allowed_sender):
        """ 
예제 #14
0
class IMMExperiment(IExperiment):

    directives.widget('function', FunctionsRadioFieldWidget)
    function = Choice(
        title=u'Algorithm',
        vocabulary='sdm_functions_source',
        default=None,
        required=True,
    )

    directives.widget('species_occurrence_dataset',
                      DatasetFieldWidget,
                      genre=['DataGenreSpeciesOccurrence'],
                      errmsg=u"Please select at least 1 occurrence dataset.",
                      vizclass=u'bccvl-occurrence-viz')
    species_occurrence_dataset = TextLine(
        title=u'Species Occurrence Datasets',
        default=None,
        required=True,
    )

    directives.widget('species_absence_dataset',
                      DatasetFieldWidget,
                      genre=['DataGenreSpeciesAbsence'],
                      errmsg=u"Please select at least 1 absence dataset.",
                      vizclass=u'bccvl-absence-viz')
    species_absence_dataset = TextLine(
        title=u'Species Absence Datasets',
        default=None,
        required=False,
    )

    directives.widget('scale_down',
                      BoolRadioFieldWidget,
                      true_label=u"Scale to finest resolution",
                      false_label=u"Scale to coarsest resolution")
    scale_down = Bool(
        title=u'Select common resolution',
        description=
        u'Environmental datasets will be scaled to the same resolution. This option allows to select to scale to highest or lowest resolution.',
        default=False,
        required=False)

    directives.widget('datasubsets', DataSubsetsFieldWidget)
    datasubsets = List(
        title=u'Climate & Environmental Data Subsets',
        value_type=Dict(),
        required=True,
    )

    directives.mode(modelling_region=HIDDEN_MODE)
    directives.widget('modelling_region', TextAreaFieldWidget)
    modelling_region = NamedBlobFile(
        title=u"Modelling Region",
        description=
        u"GEOJson describing the geographic region which is used to generate the model.",
        required=False,
    )
예제 #15
0
 def setUp(self):
     super(TestSnapBuildChannelsWidget, self).setUp()
     field = Dict(
         __name__="auto_build_channels",
         title="Source snap channels for automatic builds")
     self.context = self.factory.makeSnap()
     self.field = field.bind(self.context)
     self.request = LaunchpadTestRequest()
     self.widget = SnapBuildChannelsWidget(self.field, self.request)
예제 #16
0
class ISDMExperiment(IExperiment):

    form.widget('functions', FunctionsFieldWidget)
    functions = List(
        title=u'Algorithm',
        value_type=Choice(vocabulary='sdm_functions_source'),
        default=None,
        required=True,
    )

    form.widget('species_occurrence_dataset',
                DatasetFieldWidget,
                genre=['DataGenreSpeciesOccurrence'],
                errmsg=u"Please select at least 1 occurrence dataset.",
                vizclass=u'bccvl-occurrence-viz')
    species_occurrence_dataset = TextLine(
        title=u'Species Occurrence Datasets',
        default=None,
        required=True,
    )

    form.widget('species_absence_dataset',
                DatasetFieldWidget,
                genre=['DataGenreSpeciesAbsence'],
                errmsg=u"Please select at least 1 emmission scenario.",
                vizclass=u'bccvl-absence-viz')
    species_absence_dataset = TextLine(
        title=u'Species Absence Datasets',
        default=None,
        required=False,
    )

    species_pseudo_absence_points = Bool(
        title=u"Pseudo absence points",
        description=u"Enable generation of random pseudo absence "
        u"points across area defined in environmental data",
        default=False,
        required=False)

    species_number_pseudo_absence_points = Int(
        title=u"Number of pseudo absence points",
        description=u"The number of random pseudo absence points to generate",
        default=10000,
        required=False)

    form.widget('environmental_datasets',
                DatasetDictFieldWidget,
                multiple='multiple',
                genre=['DataGenreCC', 'DataGenreE'],
                filters=['text', 'source', 'layer', 'resolution'],
                errmsg=u"Please select at least 1 layer.")
    environmental_datasets = Dict(
        title=u'Climate & Environmental Datasets',
        key_type=TextLine(),
        value_type=Set(value_type=TextLine()),
        required=True,
    )
예제 #17
0
파일: data.py 프로젝트: Py-AMS/pyams-utils
class IObjectData(Interface):
    """Object data generic interface

    Objects providing this interface can create an 'object_data' dictionary attribute which
    will be used to create matching HTML data attributes.
    """

    object_data = Dict(title="Data associated with this object",
                       required=False)
예제 #18
0
    def testValidateMinValues(self):
        field = Dict(title=u'Dict field',
                     description=u'', readonly=False, required=False,
                     min_length=1)
        field.validate(None)
        field.validate({1: 'a'})
        field.validate({1: 'a', 2: 'b'})

        self.assertRaises(TooShort, field.validate, {})
예제 #19
0
    def testValidateMaxValues(self):
        field = Dict(title=u'Dict field',
                     description=u'', readonly=False, required=False,
                     max_length=1)
        field.validate(None)
        field.validate({})
        field.validate({1: 'a'})

        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b'})
        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b', 3: 'c'})
예제 #20
0
class ILocaleMonthContext(Interface):
    """Specifices a usage context for month names"""

    type = TextLine(
        title=_u("Month context type"),
        description=_u("Name of the month context, format or stand-alone."))

    defaultWidth = TextLine(title=_u("Default month name width"),
                            default=_u("wide"))

    months = Dict(
        title=_u("Month Names"),
        description=_u("A mapping of month name widths to a mapping of"
                       "corresponding month names."),
        key_type=Choice(title=_u("Width type"),
                        values=(_u("wide"), _u("abbreviated"), _u("narrow"))),
        value_type=Dict(title=_u("Month name"),
                        key_type=Int(title=_u("Type"), min=1, max=12),
                        value_type=TextLine(title=_u("Month Name"))))
예제 #21
0
    def testValidateMinValuesAndMaxValues(self):
        field = Dict(title=u('Dict field'),
                     description=u(''), readonly=False, required=False,
                     min_length=1, max_length=2)
        field.validate(None)
        field.validate({1: 'a'})
        field.validate({1: 'a', 2: 'b'})

        self.assertRaises(TooShort, field.validate, {})
        self.assertRaises(TooLong, field.validate, {1: 'a', 2: 'b', 3: 'c'})
예제 #22
0
class ILocaleDayContext(Interface):
    """Specifices a usage context for days names"""

    type = TextLine(
        title=u'Day context type',
        description=u"Name of the day context, format or stand-alone.")

    defaultWidth = TextLine(title=u'Default day name width', default=u'wide')

    days = Dict(title=u'Day Names',
                description=u'A mapping of day name widths to a mapping of'
                u'corresponding day names.',
                key_type=Choice(title=u'Width type',
                                values=(u'wide', u'abbreviated', u'narrow')),
                value_type=Dict(title=u'Day name',
                                key_type=Choice(title=u"Type",
                                                values=(u'sun', u'mon', u'tue',
                                                        u'wed', u'thu', u'fri',
                                                        u'sat')),
                                value_type=TextLine(title=u'Day Name')))
예제 #23
0
    def testValidateValueType(self):
        field = Dict(title=u'Dict field',
                     description=u'', readonly=False, required=False,
                     value_type=Int())
        field.validate(None)
        field.validate({'a': 5})
        field.validate({'a': 2, 'b': 3})

        self.assertRaises(WrongContainedType, field.validate, {1: ''} )
        self.assertRaises(WrongContainedType, field.validate, {1: 3.14159} )
        self.assertRaises(WrongContainedType, field.validate, {'a': ()} )
예제 #24
0
    def testValidateKeyTypes(self):
        field = Dict(title=u'Dict field',
                     description=u'', readonly=False, required=False,
                     key_type=Int())
        field.validate(None)
        field.validate({5: 'a'})
        field.validate({2: 'a', 2: 'b'})

        self.assertRaises(WrongContainedType, field.validate, {'': 1} )
        self.assertRaises(WrongContainedType, field.validate, {3.14159: 1} )
        self.assertRaises(WrongContainedType, field.validate, {(): 'a'} )
예제 #25
0
class IMonkeyPatchEvent(Interface):
    """Monkey patch applied event"""

    patch_info = Dict(
        title=u"Misc information about the patch",
        description=u"""A mapping about the patch with following keys:
        * 'description': A text that describes the monkey patch
        * 'zcml_info': A text about the ZCML portion that made the patch
        * 'original': Dotted name of the original method/function.
        * 'replacement': Dotted name of the new function
        """)
예제 #26
0
class ILocaleDisplayNames(Interface):
    """Localized Names of common text strings.

    This object contains localized strings for many terms, including
    language, script and territory names. But also keys and types used
    throughout the locale object are localized here.
    """

    languages = Dict(title=u"Language type to translated name",
                     key_type=TextLine(title=u"Language Type"),
                     value_type=TextLine(title=u"Language Name"))

    scripts = Dict(title=u"Script type to script name",
                   key_type=TextLine(title=u"Script Type"),
                   value_type=TextLine(title=u"Script Name"))

    territories = Dict(title=u"Territory type to translated territory name",
                       key_type=TextLine(title=u"Territory Type"),
                       value_type=TextLine(title=u"Territory Name"))

    variants = Dict(title=u"Variant type to name",
                    key_type=TextLine(title=u"Variant Type"),
                    value_type=TextLine(title=u"Variant Name"))

    keys = Dict(title=u"Key type to name",
                key_type=TextLine(title=u"Key Type"),
                value_type=TextLine(title=u"Key Name"))

    types = Dict(title=u"Type type and key to localized name",
                 key_type=Tuple(title=u"Type Type and Key"),
                 value_type=TextLine(title=u"Type Name"))