Exemple #1
0
class ISprintAttendance(Interface):
    """An attendance of a person at a sprint."""

    attendee = PublicPersonChoice(title=_('Attendee'),
                                  required=True,
                                  vocabulary='ValidPersonOrTeam')
    attendeeID = Attribute('db attendee value')
    sprint = Choice(
        title=_('The Sprint'),
        required=True,
        vocabulary='Sprint',
        description=_("Select the meeting from the list presented above."))
    time_starts = Datetime(title=_('From'),
                           required=True,
                           description=_(
                               "The date and time of arrival and "
                               "availability for sessions during the sprint."))
    time_ends = Datetime(
        title=_('To'),
        required=True,
        description=_(
            "The date and time of your departure. "
            "Please ensure the time reflects accurately "
            "when you will no longer be available for sessions at this event, to "
            "assist those planning the schedule."))
    is_physical = Bool(title=_("How will you be attending?"),
                       description=_(
                           "True, you will be physically present, "
                           "or false, you will be remotely present."),
                       required=False,
                       readonly=False,
                       default=True)
Exemple #2
0
    def test_datetime_deserializer_for_not_required_datetime(self):
        field = Datetime()
        field.required = False
        deserializer = IDeserializer(field)
        value = deserializer('None', None, None)

        self.assertEqual(None, value)
    def test_datetime_deserializer_for_not_required_datetime(self):
        field = Datetime()
        field.required = False
        deserializer = IDeserializer(field)
        value = deserializer('None', None, None)

        self.assertEqual(None, value)
Exemple #4
0
class IGitRuleView(Interface):
    """`IGitRule` attributes that require launchpad.View."""

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

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

    position = Int(
        title=_("Position"), required=True, readonly=True,
        description=_(
            "The position of this rule in its repository's rule order."))

    creator = PublicPersonChoice(
        title=_("Creator"), required=True, readonly=True,
        vocabulary="ValidPerson",
        description=_("The user who created this rule."))

    date_created = Datetime(
        title=_("Date created"), required=True, readonly=True,
        description=_("The time when this rule was created."))

    date_last_modified = Datetime(
        title=_("Date last modified"), required=True, readonly=True,
        description=_("The time when this rule was last modified."))

    grants = Attribute("The access grants for this rule.")
Exemple #5
0
class IPersonNotification(Interface):
    """A textual message about a change in our records about a person."""

    person = Object(
        title=_("The person who will receive this notification."),
        schema=IPerson)
    date_emailed = Datetime(
        title=_("Date emailed"),
        description=_("When was the notification sent? None, if it hasn't"
                      " been sent yet."),
        required=False)
    date_created = Datetime(title=_("Date created"))
    body = Text(title=_("Notification body."))
    subject = TextLine(title=_("Notification subject."))

    can_send = Attribute("Can the notification be sent?")

    to_addresses = Attribute(
        "The list of addresses to send the notification to.")

    def destroySelf():
        """Delete this notification."""

    def send():
        """Send the notification by email."""
class IAccountViewRestricted(Interface):
    """Private information on an `IAccount`."""

    date_created = Datetime(title=_('Date Created'),
                            required=True,
                            readonly=True)

    creation_rationale = Choice(
        title=_("Rationale for this account's creation."),
        required=True,
        readonly=True,
        values=AccountCreationRationale.items)

    openid_identifiers = Attribute(_("Linked OpenId Identifiers"))

    date_status_set = Datetime(title=_('Date status last modified.'),
                               required=True,
                               readonly=False)

    status_comment = Text(title=_("Why are you deactivating your account?"),
                          required=False,
                          readonly=False)

    def reactivate(comment):
        """Activate this account.
class ISearchForm(Interface):
    """
    Interface for creating a prenotazione
    """
    text = TextLine(
        title=_('label_text', u'Text to search'),
        default=u'',
        required=False,
    )
    review_state = Choice(
        title=__("State"),
        default='',
        required=False,
        source='rg.prenotazioni.booking_review_states'
    )
    gate = Choice(
        title=_("label_gate", u"Gate"),
        default='',
        required=False,
        source='rg.prenotazioni.gates'
    )
    start = Datetime(
        title=_('label_start', u'Start date '),
        description=_(" format (YYYY-MM-DD)"),
        default=None,
        constraint=check_date,
        required=False,
    )
    end = Datetime(
        title=_('label_end', u'End date'),
        description=_(" format (YYYY-MM-DD)"),
        default=None,
        constraint=check_date,
        required=False,
    )
Exemple #8
0
    def setUp(self):
        from plone.app.widgets.dx import DatetimeWidget

        self.request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
        self.field = Datetime(__name__='datetimefield')
        self.widget = DatetimeWidget(self.request)
        self.widget.pattern_options = {'date': {'firstDay': 0}}
class IOAuthAccessToken(IOAuthToken):
    """A token used by a consumer to access protected resources in LP.

    It's created automatically once a user logs in and grants access to a
    consumer.  The consumer then exchanges an `IOAuthRequestToken` for it.
    """

    permission = Choice(
        title=_('Access level'),
        required=True,
        readonly=False,
        vocabulary=AccessLevel,
        description=_('The level of access given to the application acting '
                      'on your behalf.'))

    date_created = Datetime(
        title=_('Date created'),
        required=True,
        readonly=True,
        description=_('The date some request token was exchanged for '
                      'this token.'))

    date_expires = Datetime(
        title=_('Date expires'),
        required=False,
        readonly=False,
        description=_('From this date onwards this token can not be used '
                      'by the consumer to access protected resources.'))

    def checkNonceAndTimestamp(nonce, timestamp):
        """Verify the nonce and timestamp.
Exemple #10
0
class ICve(Interface):
    """A single CVE database entry."""

    export_as_webservice_entry()

    id = Int(title=_('ID'), required=True, readonly=True)
    sequence = exported(
        TextLine(title=_('CVE Sequence Number'),
                 description=_('Should take the form XXXX-XXXX, all digits.'),
                 required=True,
                 readonly=False,
                 constraint=valid_cve_sequence))
    status = exported(
        Choice(title=_('Current CVE State'),
               default=CveStatus.CANDIDATE,
               description=_("Whether or not the "
                             "vulnerability has been reviewed and assigned a "
                             "full CVE number, or is still considered a "
                             "Candidate, or is deprecated."),
               required=True,
               vocabulary=CveStatus))
    description = exported(
        TextLine(title=_('Title'),
                 description=_('A description of the CVE issue. This will be '
                               'updated regularly from the CVE database.'),
                 required=True,
                 readonly=False))
    datecreated = exported(Datetime(title=_('Date Created'),
                                    required=True,
                                    readonly=True),
                           exported_as='date_created')
    datemodified = exported(Datetime(title=_('Date Modified'),
                                     required=True,
                                     readonly=False),
                            exported_as='date_modified')
    bugs = exported(
        CollectionField(
            title=_('Bugs related to this CVE entry.'),
            readonly=True,
            value_type=Reference(schema=Interface)))  # Redefined in bug.py.

    # Other attributes.
    url = exported(
        TextLine(title=_('URL'),
                 description=_("Return a URL to the site that has the CVE "
                               "data for this CVE reference.")))
    displayname = exported(TextLine(title=_("Display Name"),
                                    description=_(
                                        "A very brief name describing "
                                        "the ref and state.")),
                           exported_as='display_name')
    title = exported(
        TextLine(title=_("Title"), description=_("A title for the CVE")))
    references = Attribute("The set of CVE References for this CVE.")

    def createReference(source, content, url=None):
        """Create a new CveReference for this CVE."""

    def removeReference(ref):
        """Remove a CveReference."""
Exemple #11
0
class IEmailDisplayForm(Interface):

    server_status = TextLine(
        title=_('Server Status'),
        description=_('Current status of the SchoolTool email service'),
        required=False)

    from_address = TextLine(title=_(u'From'),
                            description=_(u'The sender address'),
                            required=False)

    to_addresses = TextLine(
        title=_(u'To'),
        description=_(u'Recipient addresses comma separated'),
        required=False)

    time_created = Datetime(
        title=_(u'Created on'),
        description=_(u'Date and time when the message was created'),
        required=False)

    subject = TextLine(title=_(u'Subject'), required=False)

    body = Text(title=_(u'Body'), required=False)

    status = TextLine(title=_(u'Email Status'), required=False)

    time_sent = Datetime(
        title=_(u'Last time tried'),
        description=_(u'Date and time when the message was last tried'),
        required=False)
Exemple #12
0
class ICodeImportMachine(Interface):
    """A machine that can perform imports."""

    id = Int(readonly=True, required=True)

    state = Choice(
        title=_('State'),
        required=True,
        vocabulary=CodeImportMachineState,
        default=CodeImportMachineState.OFFLINE,
        description=_("The state of the controller daemon on this machine."))

    hostname = TextLine(title=_('Host name'),
                        required=True,
                        description=_('The hostname of the machine.'))

    current_jobs = Attribute(
        'The current jobs that the machine is processing.')

    events = Attribute('The events associated with this machine.')

    date_created = Datetime(title=_("Date Created"),
                            required=True,
                            readonly=True)

    heartbeat = Datetime(title=_("Heartbeat"),
                         description=_(
                             "When the controller deamon last recorded it was"
                             " running."))

    def shouldLookForJob(worker_limit):
        """Should we look for a job to run on this machine?

        There are three reasons we might not look for a job:

        a) The machine is OFFLINE
        b) The machine is QUIESCING (in which case we might go OFFLINE)
        c) There are already enough jobs running on this machine.
        """

    def setOnline(user=None, message=None):
        """Record that the machine is online, marking it ready to accept jobs.

        Set state to ONLINE, and record the corresponding event.
        :param user: `Person` that requested going online if done by a user.
        :param message: User-provided message.
        """

    def setOffline(reason, user=None, message=None):
        """Record that the machine is offline.

        Set state to OFFLINE, and record the corresponding event.

        :param reason: `CodeImportMachineOfflineReason` enum value.
        :param user: `Person` that requested going online if done by a user.
        :param message: User-provided message.
        """

    def setQuiescing(user, message=None):
        """Initiate an orderly shut down without interrupting running jobs.
class ICodeImportResult(Interface):
    """A completed code import job."""

    id = Int(readonly=True, required=True)

    date_created = Datetime(readonly=True, required=True)

    code_import = Object(
        schema=ICodeImport,
        readonly=True,
        required=True,
        description=_("The code import for which the job was run."))

    machine = Object(schema=ICodeImportMachine,
                     readonly=True,
                     required=True,
                     description=_("The machine the job ran on."))

    requesting_user = Object(
        schema=IPerson,
        readonly=True,
        required=False,
        description=_("The user that requested the import, if any."))

    log_excerpt = Text(readonly=True,
                       required=False,
                       description=_(
                           "The last few lines of the partial log, in case it "
                           "is set."))

    log_file = Object(
        schema=ILibraryFileAlias,
        readonly=True,
        required=False,
        description=_("A partial log of the job for users to see. It is "
                      "normally only recorded if the job failed in a step "
                      "that interacts with the remote repository. If a job "
                      "was successful, or failed in a houskeeping step, the "
                      "log file would not contain information useful to the "
                      "user."))

    status = Choice(vocabulary=CodeImportResultStatus,
                    readonly=True,
                    required=True,
                    description=_(
                        "How the job ended. Success, some kind of failure, or "
                        "some kind of interruption before completion."))

    date_job_started = Datetime(readonly=True,
                                required=True,
                                description=_("When the job started running."))

    date_job_finished = Datetime(
        readonly=True,
        required=True,
        description=_("When the job stopped running."))

    job_duration = Attribute("How long did the job take to run.")
class IOAuthRequestToken(IOAuthToken):
    """A token used by a consumer to ask the user to authenticate on LP.

    After the user has authenticated and granted access to that consumer, the
    request token is exchanged for an access token and is then destroyed.
    """

    permission = Choice(
        title=_('Permission'),
        required=True,
        readonly=False,
        vocabulary=OAuthPermission,
        description=_('The permission you give to the application which may '
                      'act on your behalf.'))
    date_created = Datetime(
        title=_('Date created'),
        required=True,
        readonly=True,
        description=_('The date the token was created. The request token '
                      'will be good for a limited time after this date.'))

    date_expires = Datetime(
        title=_('Date expires'),
        required=False,
        readonly=False,
        description=_('The expiration date for the permission you give to '
                      'the application which may act on your behalf.'))

    date_reviewed = Datetime(
        title=_('Date reviewed'),
        required=True,
        readonly=True,
        description=_('The date in which the user authorized (or not) the '
                      'consumer to access his protected resources on '
                      'Launchpad.'))

    is_reviewed = Bool(
        title=_('Has this token been reviewed?'),
        required=False,
        readonly=True,
        description=_('A reviewed request token can only be exchanged for an '
                      'access token (in case the user granted access).'))

    def review(user, permission, context=None):
        """Grant `permission` as `user` to this token's consumer.

        :param context: An IProduct, IProjectGroup, IDistribution or
            IDistributionSourcePackage in which the permission is valid. If
            None, the permission will be valid everywhere.

        Set this token's person, permission and date_reviewed.  This will also
        cause this token to be marked as used, meaning it can only be
        exchanged for an access token with the same permission, consumer and
        person.
        """

    def createAccessToken():
        """Create an `IOAuthAccessToken` identical to this request token.
Exemple #15
0
class IMeeting(IContainer, IContained):
    """interface of an meeting
    """
    name = TextLine(title=_(u'Display name'))
    address = TextLine(title=_(u'Address'), required=False)
    start_date = Datetime(title=_(u'Start date'), required=False)
    end_date = Datetime(title=_(u'End date'), required=False)
    headline = TextLine(title=_(u'Headline'), required=False)
    description = Text(title=_(u'Description'), required=False)
Exemple #16
0
class IFAQPublic(IHasOwner):

    id = exported(Int(
        title=_('FAQ Number'),
        description=_('The unique number identifying the FAQ in Launchpad.'),
        required=True,
        readonly=True),
                  as_of='devel')

    title = exported(Title(
        title=_('Title'),
        description=_('The title describing this FAQ, often a question.'),
        required=True),
                     as_of='devel')

    keywords = exported(TextLine(
        title=_('Keywords'),
        description=_('One or more terms that relate to this FAQ.'),
        required=False),
                        as_of='devel')

    content = exported(Text(
        title=_('Content'),
        description=_(
            'The answer for this FAQ in plain text. You may choose to '
            'include a URL to an external FAQ.'),
        required=True),
                       as_of='devel')

    date_created = exported(Datetime(title=_('Created'),
                                     required=True,
                                     readonly=True),
                            as_of='devel')

    last_updated_by = exported(PublicPersonChoice(
        title=_('Last Updated By'),
        description=_('The last person who modified the document.'),
        vocabulary='ValidPersonOrTeam',
        required=False,
        readonly=True),
                               as_of='devel')

    date_last_updated = exported(Datetime(title=_('Last Updated'),
                                          required=False,
                                          readonly=True),
                                 as_of='devel')

    target = exported(Reference(
        title=_('Target'),
        description=_('Product or distribution containing this FAQ.'),
        schema=IFAQTarget,
        required=True,
        readonly=True),
                      as_of='devel')

    related_questions = Attribute(
        _('The set of questions linked to this FAQ.'))
class IHasOOPSReferences(Interface):
    """Has references to OOPSes that can be queried."""
    @operation_parameters(
        start_date=Datetime(title=_("Modified after date")),
        end_date=Datetime(title=_("Modified before date")),
    )
    @export_read_operation()
    @operation_for_version('devel')
    def findReferencedOOPS(start_date, end_date):
        """Find OOPS reports between start_date and end_date.
Exemple #18
0
class IEventSchema(Interface):

    """Schema for event views.
    """

    title = TextLine(
        title=_(u'Title'),
        required=False,
        missing_value=u'',
        max_length=100)

    contact_name = TextLine(
        title=_(u'Contact Name'),
        required=False,
        missing_value=u'',
        max_length=100)

    location = TextLine(
        title=_(u'Location'),
        required=False,
        missing_value=u'',
        max_length=100)

    contact_email = EmailLine(
        title=_(u'Contact Email'),
        required=False)

    categories = Set(
        title=_(u'Category'),
        required=False,
        missing_value=set(),
        value_type=Choice(vocabulary="cmf.calendar.AvailableEventTypes"))

    contact_phone = TextLine(
        title=_(u'Contact Phone'),
        required=False,
        missing_value=u'',
        max_length=100)

    event_url = URI(
        title=_(u'URL'),
        required=False,
        missing_value=u'',
        max_length=100)

    start_date = Datetime(
        title=_(u'From'),)

    stop_date = Datetime(
        title=_(u'To'),)

    description = Text(
        title=_(u'Description'),
        required=False,
        missing_value=u'')
class IDatetimeTest(Interface):
    d1 = Datetime(required=True,
                  min=datetime(2003, 1, 1, tzinfo=tzinfo(0)),
                  max=datetime(2020, 12, 31, tzinfo=tzinfo(0)))

    d2 = Datetime(required=False)

    d3 = Choice(required=False,
                values=(datetime(2003, 9, 15, tzinfo=tzinfo(0)),
                        datetime(2003, 10, 15, tzinfo=tzinfo(0))),
                missing_value=datetime(2000, 1, 1, tzinfo=tzinfo(0)))
Exemple #20
0
class IDemoContent(Interface):

    now = Datetime(title=u"Now", readonly=True)

    startDate = Date(title=u"Start Date")
    endDate = Date(title=u"End Date")

    startDatetime = Datetime(title=u"Start Datetime")
    endDatetime = Datetime(title=u"End Datetime")

    severalDates = Set(title=u"Several dates", value_type=Date(title=u"Date"))
class IArchiveAuthTokenView(Interface):
    """Interface for Archive Authorization Tokens requiring launchpad.View."""
    id = Int(title=_('ID'), required=True, readonly=True)

    archive = Reference(
        IArchive,
        title=_("Archive"),
        required=True,
        readonly=True,
        description=_("The archive for this authorization token."))

    person = Reference(
        IPerson,
        title=_("Person"),
        required=False,
        readonly=True,
        description=_("The person for this authorization token."))
    person_id = Attribute('db person value')

    date_created = Datetime(
        title=_("Date Created"),
        required=True,
        readonly=True,
        description=_("The timestamp when the token was created."))

    date_deactivated = Datetime(
        title=_("Date De-activated"),
        required=False,
        description=_("The timestamp when the token was de-activated."))

    token = TextLine(
        title=_("Token"),
        required=True,
        readonly=True,
        description=_("The access token to the archive for this person."))

    archive_url = TextLine(
        title=_("Archive url"),
        readonly=True,
        description=_(
            "External archive URL including basic auth for this person"))

    name = TextLine(
        title=_("Name"),
        required=False,
        readonly=True,
        description=_(
            "The name in the case of a named authorization token, or None."))

    def deactivate():
        """Deactivate the token by setting date_deactivated to UTC_NOW."""

    def asDict():
        """Returns a dictionary where the value of `token` is the secret and
Exemple #22
0
class IRevision(Interface):
    """Bazaar revision."""

    id = Int(title=_('The database revision ID'))

    date_created = Datetime(title=_("Date Created"),
                            required=True,
                            readonly=True)
    log_body = Attribute("The revision log message.")

    revision_author_id = Attribute("Revision author identifier id.")
    revision_author = Attribute("The revision author identifier.")

    gpgkey = Attribute("The OpenPGP key used to sign the revision.")
    revision_id = Attribute("The globally unique revision identifier.")
    revision_date = Datetime(title=_("The date the revision was committed."),
                             required=True,
                             readonly=True)
    karma_allocated = Bool(
        title=_("Has karma been allocated for this revision?"),
        required=True,
        default=False)
    parents = Attribute("The RevisionParents for this revision.")
    parent_ids = Attribute(
        "The revision_ids of the parent Revisions. Parent revisions are "
        "identified by their revision_id rather than a foreign key "
        "so that ghosts and parents that actually exist can be modelled "
        "in the same way.")
    properties = Attribute("The `RevisionProperty`s for this revision.")

    def getProperties():
        """Return the revision properties as a dict."""

    def allocateKarma(branch):
        """Allocate karma to the revision_author for this revision."""

    def getBranch(allow_private=False, allow_junk=True):
        """Return a branch associated with this revision.

        The chances are that there will be many branches with any revision
        that has landed on the trunk branch.  A branch owned by the revision
        author is chosen over a branch not owned by the author.  A branch with
        the revision in the history is chosen over a branch that just has the
        revision in the ancestry.

        :param allow_private: If True, a public or private branch may be
            returned.  Otherwise only a public branch may be returned.
        :param allow_junk: If True junk branches are acceptable, if False,
            only non-junk branches are returned.
        :return: A `Branch` or None if an appropriate branch cannot be found.
        """

    def getLefthandParent():
        """Return lefthand parent of revision, or None if not in database."""
Exemple #23
0
class ISprintSpecification(Interface):
    """A link between a Sprint and a Specification."""

    id = Attribute(
        "The ID of this sprint/spec link. We expose this because there is "
        "no uniqueness of spec names across projects and of course "
        "distros, so there is no unique way to identify a sprintspec by spec "
        "name, because multiple specs at a sprint could have the same name.")
    sprint = Choice(
        title=_('Sprint'), required=True, readonly=True,
        description=_(
            "Select the meeting or sprint at which you would like "
            "feature to be discussed or implemented. The meeting organisers "
            "will review and approve or decline this request."),
        vocabulary='FutureSprint')
    specification = Int(
        title=_('Specification'), required=True, readonly=True)
    status = Choice(
        title=_('Agenda Status'), required=True,
        vocabulary=SprintSpecificationStatus)
    whiteboard = Text(
        title=_('Whiteboard'), required=False,
        description=_(
            "Any reasoning or rationale for your decision. "
            "Your changes will override the current text. Note that "
            "this is purely related to whether this spec is approved for "
            "the agenda of this meeting, not a commentary of "
            "the specification in general."))
    registrant = PublicPersonChoice(
        title=_('Nominated by'), required=False,
        vocabulary='ValidPersonOrTeam')
    date_created = Datetime(
        title=_('Date nominated'),
        description=_(
            "The date this topic was nominated for the sprint agenda."))
    decider = PublicPersonChoice(
        title=_('Decided by'), required=False,
        vocabulary='ValidPersonOrTeam')
    date_decided = Datetime(
        title=_('Date decided'),
        description=_(
            "The date this topic was reviewed and accepted or declined for "
            "the meeting agenda."))

    is_confirmed = Attribute(
        "True if this spec is confirmed for the agenda of this sprint.")
    is_decided = Attribute(
        'True if this spec has been accepted or declined for this sprint.')

    def acceptBy(decider):
        """Flag the sprint as being accepted by the decider."""

    def declineBy(decider):
        """Flag the sprint as being declined by the decider."""
class IDCPublishing(Interface):
    """Publishing properties
    """

    effective = Datetime(
        title=u'Effective Date',
        description=u"The date and time that an object should be published. ")

    expires = Datetime(
        title=u'Expiration Date',
        description=
        u"The date and time that the object should become unpublished.")
Exemple #25
0
class IStructuralSubscriptionPublic(Interface):
    """The public parts of a subscription to a Launchpad structure."""

    id = Int(title=_('ID'), readonly=True, required=True)
    product = Int(title=_('Product'), required=False, readonly=True)
    productseries = Int(title=_('Product series'),
                        required=False,
                        readonly=True)
    projectgroup = Int(title=_('Project group'), required=False, readonly=True)
    milestone = Int(title=_('Milestone'), required=False, readonly=True)
    distribution = Int(title=_('Distribution'), required=False, readonly=True)
    distroseries = Int(title=_('Distribution series'),
                       required=False,
                       readonly=True)
    sourcepackagename = Int(title=_('Source package name'),
                            required=False,
                            readonly=True)
    subscriber = exported(
        PersonChoice(title=_('Subscriber'),
                     required=True,
                     vocabulary='ValidPersonOrTeam',
                     readonly=True,
                     description=_("The person subscribed.")))
    subscribed_by = exported(
        PublicPersonChoice(
            title=_('Subscribed by'),
            required=True,
            vocabulary='ValidPersonOrTeam',
            readonly=True,
            description=_("The person creating the subscription.")))
    date_created = exported(
        Datetime(title=_("The date on which this subscription was created."),
                 required=False,
                 readonly=True))
    date_last_updated = exported(
        Datetime(
            title=_("The date on which this subscription was last updated."),
            required=False,
            readonly=True))

    target = exported(
        Reference(
            schema=Interface,  # IStructuralSubscriptionTarget
            required=True,
            readonly=True,
            title=_("The structure to which this subscription belongs.")))

    bug_filters = exported(
        CollectionField(
            title=_('List of bug filters that narrow this subscription.'),
            readonly=True,
            required=False,
            value_type=Reference(schema=Interface)))  # IBugSubscriptionFilter
class IDCTimes(Interface):
    """Time properties
    """

    created = Datetime(
        title=u'Creation Date',
        description=u"The date and time that an object is created. "
        u"\nThis is normally set automatically.")

    modified = Datetime(
        title=u'Modification Date',
        description=u"The date and time that the object was last modified in a\n"
        u"meaningful way.")
Exemple #27
0
class IScriptActivity(Interface):
    """A record of an invocation of a script."""

    name = TextLine(
        title=_('Script name'), required=True,
        description=_('The name of the script that was run'))
    hostname = TextLine(
        title=_('Host name'), required=True,
        description=_('The host on which the script was run'))
    date_started = Datetime(
        title=_('Date started'), required=True,
        description=_('The date at which the script started'))
    date_completed = Datetime(
        title=_('Date completed'), required=True,
        description=_('The date at which the script completed'))
Exemple #28
0
class ISprintPublic(IHasOwner, IHasDrivers, IHasSpecifications,
                    IHeadingContext):
    """`ISprint` attributes that anyone can view."""

    id = Int(title=_('The Sprint ID'))

    displayname = Attribute('A pseudonym for the title.')
    owner = PublicPersonChoice(title=_('Owner'),
                               required=True,
                               readonly=True,
                               vocabulary='ValidPersonOrTeam')
    datecreated = Datetime(title=_('Date Created'),
                           required=True,
                           readonly=True)

    # joins
    attendees = Attribute('The set of attendees at this sprint.')
    attendances = Attribute('The set of SprintAttendance records.')

    def specificationLinks(status=None):
        """Return the SprintSpecification records matching the filter,
        quantity and sort given. The rules for filtering and sorting etc are
        the same as those for IHasSpecifications.specifications()
        """

    def getSpecificationLink(id):
        """Return the specification link for this sprint that has the given
        ID. We use the naked ID because there is no unique name for a spec
        outside of a single product or distro, and a sprint can cover
        multiple products and distros.
        """

    def isDriver(user):
        """Returns True if and only if the specified user
class IBugNotification(IHasOwner):
    """A textual representation of bug changes."""

    id = Attribute('id')
    message = Attribute(
        "The message containing the text representation of the changes"
        " to the bug.")
    activity = Attribute(
        "The bug activity object corresponding to this notification.  Will "
        "be None for older notification objects, and will be None if the "
        "bugchange object that provides the data for the change returns None "
        "for getBugActivity.")
    bug = BugField(title=u"The bug this notification is for.", required=True)
    is_comment = Bool(title=u"Comment",
                      description=u"Is the message a comment?",
                      required=True)
    date_emailed = Datetime(
        title=u"Date emailed",
        description=u"When was the notification sent? None, if it hasn't"
        " been sent yet.",
        required=False)
    recipients = Attribute(
        "The people to which this notification should be sent.")
    status = Choice(
        title=_("Status"),
        required=True,
        vocabulary=BugNotificationStatus,
        default=BugNotificationStatus.PENDING,
        description=_("The status of this bug notification."),
    )
    bug_filters = Attribute(
        "List of bug filters that caused this notification.")
Exemple #30
0
class IArchiveFile(Interface):
    """A file in an archive.

    This covers files that are not published in the archive's package pool,
    such as the Packages and Sources index files.
    """

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

    archive = Reference(
        title=_("The archive containing the index file."),
        schema=IArchive, required=True, readonly=True)

    container = TextLine(
        title=_("An identifier for the component that manages this file."),
        required=True, readonly=True)

    path = TextLine(
        title=_("The path to the index file within the published archive."),
        required=True, readonly=True)

    library_file = Reference(
        title=_("The index file in the librarian."),
        schema=ILibraryFileAlias, required=True, readonly=True)

    scheduled_deletion_date = Datetime(
        title=_("The date when this file should stop being published."),
        required=False, readonly=False)
class IQuestionSubscription(Interface):
    """A subscription for a person to a question."""

    export_as_webservice_entry(publish_web_link=False, as_of='devel')

    id = Int(title=_('ID'), readonly=True, required=True)
    person = exported(PersonChoice(title=_('Person'),
                                   required=True,
                                   vocabulary='ValidPersonOrTeam',
                                   readonly=True,
                                   description=_(
                                       "The person's Launchpad ID or "
                                       "e-mail address.")),
                      as_of="devel")
    question = exported(Reference(Interface,
                                  title=_("Question"),
                                  required=True,
                                  readonly=True),
                        as_of="devel")
    date_created = exported(Datetime(title=_('Date subscribed'),
                                     required=True,
                                     readonly=True),
                            as_of="devel")

    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the question?"""
Exemple #32
0
class DatetimeWidgetTests(unittest.TestCase):

    def setUp(self):
        from plone.app.widgets.dx import DatetimeWidget

        self.request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
        self.field = Datetime(__name__='datetimefield')
        self.widget = DatetimeWidget(self.request)
        self.widget.pattern_options = {'date': {'firstDay': 0}}

    def test_widget(self):
        self.assertEqual(
            {
                'pattern': 'pickadate',
                'value': u'',
                'name': None,
                'pattern_options': {
                    'date': {
                        'firstDay': 0,
                        'min': [1914, 1, 1],
                        'max': [2034, 1, 1],
                        'clear': u'Clear',
                        'format': 'mmmm d, yyyy',
                        'monthsFull': [u'January', u'February', u'March',
                                       u'April', u'May', u'June', u'July',
                                       u'August', u'September', u'October',
                                       u'November', u'December'],
                        'weekdaysShort': [u'Sun', u'Mon', u'Tue', u'Wed',
                                          u'Thu', u'Fri', u'Sat'],
                        'weekdaysFull': [u'Sunday', u'Monday', u'Tuesday',
                                         u'Wednesday', u'Thursday', u'Friday',
                                         u'Saturday'],
                        'today': u'Today',
                        'selectYears': 200,
                        'placeholder': u'Enter date...',
                        'monthsShort': [u'Jan', u'Feb', u'Mar', u'Apr', u'May',
                                        u'Jun', u'Jul', u'Aug', u'Sep', u'Oct',
                                        u'Nov', u'Dec']
                    },
                    'time': {
                        'placeholder': u'Enter time...',
                        'today': u'Today',
                        'format': 'h:i a'
                    }
                }
            },
            self.widget._base_args(),
        )

    def test_data_converter(self):
        from plone.app.widgets.dx import DatetimeWidgetConverter
        converter = DatetimeWidgetConverter(self.field, self.widget)

        self.assertEqual(
            converter.toFieldValue(''),
            converter.field.missing_value,
        )

        self.assertEqual(
            converter.toFieldValue('2000-10-30 15:40'),
            datetime(2000, 10, 30, 15, 40),
        )

        self.assertEqual(
            converter.toFieldValue('21-10-30 15:40'),
            datetime(21, 10, 30, 15, 40),
        )

        self.assertEqual(
            converter.toWidgetValue(converter.field.missing_value),
            '',
        )

        self.assertEqual(
            converter.toWidgetValue(datetime(2000, 10, 30, 15, 40)),
            '2000-10-30 15:40',
        )

        self.assertEqual(
            converter.toWidgetValue(datetime(21, 10, 30, 15, 40)),
            '21-10-30 15:40',
        )

    def test_data_converter_timezone(self):
        from plone.app.widgets.dx import DatetimeWidgetConverter
        context = Mock()

        # Test for previously set datetime, without tzinfo and no timezone on
        # context.
        # Should not apply a timezone to the field value.
        dt = datetime(2013, 11, 13, 10, 20)
        setattr(context, self.field.getName(), dt)
        self.widget.context = context
        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            datetime(2013, 11, 13, 10, 20),
        )

        # Test for previously set datetime, with tzinfo but no timezone on
        # context.
        # Should apply UTZ zone to field value, to be able to be compared with
        # the timezone aware datetime from the context.
        import pytz
        nl = pytz.timezone('Europe/Amsterdam')
        dt = nl.localize(datetime(2013, 11, 13, 10, 20))
        setattr(context, self.field.getName(), dt)
        context.timezone = None
        self.widget.context = context
        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            pytz.utc.localize(datetime(2013, 11, 13, 10, 20)),
        )

        # Test for previously set datetime, with tzinfo and timezone one
        # context.
        # Should apply the zone based on "timezone" value to field value, to be
        # able to be CORRECTLY compared with the timezone aware datetime from
        # the context.
        nl = pytz.timezone('Europe/Amsterdam')
        dt = nl.localize(datetime(2013, 11, 13, 10, 20))
        setattr(context, self.field.getName(), dt)
        context.timezone = "Europe/Amsterdam"
        self.widget.context = context
        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            nl.localize(datetime(2013, 11, 13, 10, 20)),
        )

        # cleanup
        self.widget.context = None

    def test_fieldwidget(self):
        from plone.app.widgets.dx import DatetimeWidget
        from plone.app.widgets.dx import DatetimeFieldWidget
        field = Mock(__name__='field', title=u'', required=True)
        request = Mock()
        widget = DatetimeFieldWidget(field, request)
        self.assertTrue(isinstance(widget, DatetimeWidget))
        self.assertIs(widget.field, field)
        self.assertIs(widget.request, request)
class DatetimeWidgetTests(unittest.TestCase):

    def setUp(self):
        from plone.app.z3cform.widget import DatetimeWidget

        self.request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
        self.field = Datetime(__name__='datetimefield')
        self.widget = DatetimeWidget(self.request)
        self.widget.pattern_options = {
            'date': {'firstDay': 0},
            'time': {'interval': 15}
        }

    def test_widget(self):
        current_year = datetime.today().year
        self.assertEqual(
            {
                'pattern': 'pickadate',
                'value': u'',
                'name': None,
                'pattern_options': {
                    'date': {
                        'firstDay': 0,
                        'min': [current_year - 100, 1, 1],
                        'max': [current_year + 20, 1, 1],
                        'clear': u'Clear',
                        'format': 'mmmm d, yyyy',
                        'monthsFull': [u'January', u'February', u'March',
                                       u'April', u'May', u'June', u'July',
                                       u'August', u'September', u'October',
                                       u'November', u'December'],
                        'weekdaysShort': [u'Sun', u'Mon', u'Tue', u'Wed',
                                          u'Thu', u'Fri', u'Sat'],
                        'weekdaysFull': [u'Sunday', u'Monday', u'Tuesday',
                                         u'Wednesday', u'Thursday', u'Friday',
                                         u'Saturday'],
                        'today': u'Today',
                        'selectYears': 200,
                        'placeholder': u'Enter date...',
                        'monthsShort': [u'Jan', u'Feb', u'Mar', u'Apr', u'May',
                                        u'Jun', u'Jul', u'Aug', u'Sep', u'Oct',
                                        u'Nov', u'Dec']
                    },
                    'time': {
                        'placeholder': u'Enter time...',
                        'today': u'Today',
                        'format': 'h:i a',
                        'interval': 15
                    }
                }
            },
            self.widget._base_args(),
        )

    def test_data_converter(self):
        from plone.app.z3cform.widget import DatetimeWidgetConverter
        converter = DatetimeWidgetConverter(self.field, self.widget)

        self.assertEqual(
            converter.toFieldValue(''),
            converter.field.missing_value,
        )

        self.assertEqual(
            converter.toFieldValue('2000-10-30 15:40'),
            datetime(2000, 10, 30, 15, 40),
        )

        self.assertEqual(
            converter.toFieldValue('21-10-30 15:40'),
            datetime(21, 10, 30, 15, 40),
        )

        self.assertEqual(
            converter.toWidgetValue(converter.field.missing_value),
            '',
        )

        self.assertEqual(
            converter.toWidgetValue(datetime(2000, 10, 30, 15, 40)),
            '2000-10-30 15:40',
        )

        self.assertEqual(
            converter.toWidgetValue(datetime(21, 10, 30, 15, 40)),
            '21-10-30 15:40',
        )

    def test_data_converter__no_timezone(self):
        """When no timezone is set, don't apply one.
        """
        from plone.app.z3cform.widget import DatetimeWidgetConverter
        context = Mock()

        dt = datetime(2013, 11, 13, 10, 20)
        setattr(context, self.field.getName(), dt)
        self.widget.context = context
        self.widget.default_timezone = None

        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            datetime(2013, 11, 13, 10, 20),
        )

        # cleanup
        self.widget.context = None
        self.widget.default_timezone = None

    def test_data_converter__timezone_id(self):
        """When a (pytz) timezone id is set, use that.
        """
        from plone.app.z3cform.widget import DatetimeWidgetConverter
        context = Mock()

        dt = datetime(2013, 11, 13, 10, 20)
        setattr(context, self.field.getName(), dt)
        self.widget.context = context
        self.widget.default_timezone = 'Europe/Amsterdam'
        tz = pytz.timezone('Europe/Amsterdam')

        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            tz.localize(datetime(2013, 11, 13, 10, 20)),
        )

        # cleanup
        self.widget.context = None
        self.widget.default_timezone = None

    def test_data_converter__timezone_callback(self):
        """When a timezone callback is set, returning a (pytz) timezone id,
        use that.
        """
        from plone.app.z3cform.widget import DatetimeWidgetConverter
        context = Mock()

        dt = datetime(2013, 11, 13, 10, 20)
        setattr(context, self.field.getName(), dt)
        self.widget.context = context
        self.widget.default_timezone = lambda(context): 'Europe/Amsterdam'
        tz = pytz.timezone('Europe/Amsterdam')

        converter = DatetimeWidgetConverter(self.field, self.widget)
        self.assertEqual(
            converter.toFieldValue('2013-11-13 10:20'),
            tz.localize(datetime(2013, 11, 13, 10, 20)),
        )

        # cleanup
        self.widget.context = None
        self.widget.default_timezone = None

    def test_fieldwidget(self):
        from plone.app.z3cform.widget import DatetimeWidget
        from plone.app.z3cform.widget import DatetimeFieldWidget
        field = Mock(__name__='field', title=u'', required=True)
        request = Mock()
        widget = DatetimeFieldWidget(field, request)
        self.assertTrue(isinstance(widget, DatetimeWidget))
        self.assertIs(widget.field, field)
        self.assertIs(widget.request, request)