class IAddBugTaskForm(ILinkPackaging): """Form for adding an upstream bugtask.""" # It is tempting to replace the first three attributes here with their # counterparts from IUpstreamBugTask and IDistroBugTask. # BUT: This will cause OOPSes with adapters, hence IAddBugTask reinvents # the wheel somewhat. There is a test to ensure that this remains so. product = Choice(title=_('Project'), required=True, vocabulary='Product') distribution = Choice(title=_("Distribution"), required=True, vocabulary='Distribution') sourcepackagename = Choice( title=_("Source Package Name"), required=False, description=_("The source package in which the bug occurs. " "Leave blank if you are not sure."), vocabulary='SourcePackageName') bug_url = StrippedTextLine( title=_('URL'), required=False, constraint=valid_remote_bug_url, description=_("The URL of this bug in the remote bug tracker."))
class ILibraryFileDownloadCount(Interface): """Download count of a given file in a given day.""" libraryfilealias = Reference( title=_('The file'), schema=ILibraryFileAlias, required=True, readonly=True) day = Date( title=_('The day of the downloads'), required=True, readonly=True) count = Int( title=_('The number of downloads'), required=True, readonly=False) country = Choice( title=_('Country'), required=False, vocabulary='CountryName')
class IBranchRef(Interface): """A branch reference '.bzr' directory. This interface is for use in the browser code to implement these directories. """ branch = Choice( title=_('Series Branch'), vocabulary='Branch', readonly=True, description=_("The Bazaar branch for this series."))
class IEventIfAdmUtilTicker(IEventIfSupernode): """ event interface of object """ eventOutObjs_1sec = Set( title = _("1sec. event ->"), value_type = Choice( title = _("objects"), vocabulary="AllEventInstances"), default = set([]), readonly = False, required = True) def eventOut_1sec(self): """ sends one-second event """
class IFormGroupChecker(IGroup): """Form group checker interface""" checker_fieldname = TextLine(title="Checker checkbox field name") checker_widget = Attribute("Checker checkbox field") checker_mode = Choice(title="Checker display mode", values=('hide', 'disable'), default='hide') checker_state = Attribute("Initial switcher state")
class IDropdownMenu(IViewletManager): """Dropdown menu viewlet manager interface""" label = TextLine(title="Menu label") status = Choice(title="Dropdown Bootstrap status", values=BOOTSTRAP_STATUS, default='light') css_class = TextLine(title="Menu CSS class") icon_class = TextLine(title="FontAwesome icon class, including prefix")
class IResourceRepresenterDirective(Interface): content_type = \ GlobalObject(title=u"The (MIME) content type the representer manages.", required=True) kind = \ Choice(values=(RESOURCE_KINDS.MEMBER.lower(), RESOURCE_KINDS.COLLECTION.lower()), title=u"Specifies the kind of resource the representer should " "be used for ('member' or 'collection'). If this is " "not provided, the representer is used for both " "resource kinds.", required=False)
class ISpecificationDependency(Interface): """A link between a specification and another specification on which it depends. """ specification = Int(title=_('Specification ID'), required=True, readonly=True) dependency = Choice(title=_('Depends On'), required=True, readonly=True, vocabulary='SpecificationDepCandidates')
class IBasicPerson(Interface): """Marker interface for a basic person.""" prefix = TextLine( title=_(u"Prefix"), required=False, ) first_name = TextLine( title=_(u"First name"), required=True, ) middle_name = TextLine( title=_(u"Middle name"), required=False, ) last_name = TextLine( title=_(u"Last name"), required=True, ) suffix = TextLine( title=_(u"Suffix"), required=False, ) preferred_name = TextLine( title=_(u"Preferred name"), required=False, ) gender = Choice( title=_(u"Gender"), vocabulary=vocabulary([ ('male', _('Male')), ('female', _('Female')), ]), required=False, ) birth_date = Date( title=_(u"Birth date"), description=_(u"(yyyy-mm-dd)"), required=False, ) advisors = Attribute("""Advisors of the person""") advisees = Attribute("""Advisees of the person""") levels = Attribute("""Levels of the student""")
class IGSCoreProfileRegister(IGSCoreProfile): joinable_groups = List(title=u'Joinable Groups', description=u'Groups on this site you can join.', required=False, value_type=Choice(title=u'Group', vocabulary='JoinableGroups'), unique=True, default=[]) came_from = URI( title=u'Came From', description=u'The page to return to after registration has finished', required=False)
def createProductField(self): """Create a Choice field to select one of the project's products.""" return form.Fields(Choice( __name__='product', vocabulary='ProjectProducts', title=_('Project'), description=_( '${context} is a group of projects, which specific ' 'project do you have a question about?', mapping=dict(context=self.context.title)), required=True), render_context=self.render_context)
class ISeance(IContainer): """interface of a seance """ name = TextLine(title=_(u'Title of the session')) start_date = Datetime(title=_(u'Date and time'), required=False) duration = Choice(title=_(u'Type'), source=DurationSource()) room = Choice(title=_(u'Room'), source=RoomSource(), required=False) description = Text(title=_(u'Description'), required=False) keywords = TextLine( title=_(u'Keywords'), description=_( u'Keywords describing your session, separated by a comma.'), required=False) audience = Choice( title=_(u'Audience'), # TODO configurable source values=('Debutant', 'Intermediaire', 'Avance', 'Tous niveaux')) authors = Attribute(_(u'Name of persons leading the session')) status = Choice(title=_(u'Statut'), values=('proposed', 'confirmed', 'cancelled')) unfolding = Text(title=_(u'Unfolding of the session'), required=False) benefits = Text(title=_(u'Benefits for attendees'), required=False)
class IMultiLanguageSelectionSchema(Interface): default_language = Choice( title=_(u"heading_site_language", default=u"Default site language"), description=_(u"description_site_language", default=u"The default language used for the content " u"and the UI of this site."), required=True, vocabulary="LinguaPlone.vocabularies.AllContentLanguageVocabulary") available_languages = Tuple( title=_(u"heading_available_languages", default=u"Available languages"), description=_(u"description_available_languages", default=u"The languages in which the site should be " u"translatable."), required=True, missing_value=set(), value_type=Choice( vocabulary="LinguaPlone.vocabularies.AllContentLanguageVocabulary"))
class IVCGECondition(Interface): """ Interface utilizada para descrever os elementos configuraveis desta condicao. """ skos = Set(title=_(u'VCGE'), description=_( u'Termos a serem procurados. Deixe em branco ' u'para selecionar conteúdos sem nenhum termo VCGE ' u'aplicado.'), required=False, value_type=Choice(vocabulary=VOCAB))
class IMirrorDistroSeriesSource(Interface): """The mirror of a given Distro Series""" distribution_mirror = Attribute(_("The Distribution Mirror")) distroseries = Choice(title=_('Series'), required=True, readonly=True, vocabulary='FilteredDistroSeries') freshness = Choice(title=_('Freshness'), required=True, readonly=False, vocabulary=MirrorFreshness) # Is it possible to use a Choice here without specifying a vocabulary? component = Int(title=_('Component'), required=True, readonly=True) pocket = Choice(title=_('Pocket'), required=True, readonly=True, vocabulary='PackagePublishingPocket') def getURLsToCheckUpdateness(): """Return a dict mapping each MirrorFreshness to a URL on this mirror.
class IDatetimeTest(Interface): 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))) d1 = Datetime(required=True, min=datetime(2003, 1, 1, tzinfo=tzinfo(0)), max=datetime(2020, 12, 31, tzinfo=tzinfo(0)))
class IEventIfEventIpNet(Interface): """ event interface of object """ eventInpObjs_inward_relaying_shutdown = Set( title=_("inward relaying shutdown <-"), value_type=Choice(title=_("objects"), vocabulary="AllEventInstances"), default=set([]), readonly=False, required=True) def eventInp_inward_relaying_shutdown(eventMsg): """
class IBugSubscription(Interface): """The relationship between a person and a bug.""" export_as_webservice_entry(publish_web_link=False, as_of="beta") 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="beta") bug = exported(Reference(Interface, title=_("Bug"), required=True, readonly=True), as_of="beta") # We mark this as doNotSnapshot() because it's a magically-generated # Storm attribute and it causes Snapshot to break. bugID = doNotSnapshot(Int(title=u"The bug id.", readonly=True)) bug_notification_level = exported(Choice( title=_("Bug notification level"), required=True, vocabulary=BugNotificationLevel, default=BugNotificationLevel.COMMENTS, description=_("The volume and type of bug notifications " "this subscription will generate."), ), as_of="devel") date_created = exported(Datetime(title=_('Date subscribed'), required=True, readonly=True), as_of="beta") subscribed_by = exported(PersonChoice( title=_('Subscribed by'), required=True, vocabulary='ValidPersonOrTeam', readonly=True, description=_("The person who created this subscription.")), as_of="beta") display_subscribed_by = Attribute("`subscribed_by` formatted for display.") display_duplicate_subscribed_by = Attribute( "duplicate bug `subscribed_by` formatted for display.") @call_with(user=REQUEST_USER) @export_read_operation() @operation_for_version("beta") def canBeUnsubscribedByUser(user): """Can the user unsubscribe the subscriber from the bug?"""
class IEventIfEventHost(IEventIfSupernode): """ event interface of object """ eventInpObjs_shutdown = Set(title=_("shutdown event <-"), value_type=Choice( title=_("objects"), vocabulary="AllEventInstances"), default=set([]), readonly=False, required=True) eventOutObjs_nagiosError = Set(title=_("nagiosError ->"), value_type=Choice( title=_("objects"), vocabulary="AllEventInstances"), default=set([]), readonly=False, required=False) def eventInp_shutdown(eventMsg): """ start the shutdown of the host """
class IWikiMarkupSchema(Interface): wiki_enabled_types = Tuple(title=_(u"Choose which types will have wiki " "behavior."), description=_(u"Each type chosen will have a " "wiki enabled primary text area. " "At least one type must be chosen " "to turn wiki behavior on."), required=False, missing_value=tuple(), value_type=Choice(vocabulary="plone.app.\ controlpanel.WickedPortalTypes"))
def setupPackageFilterRadio(self): if self.has_unique_parent: parent_name = "'%s'" % self.unique_parent.displayname else: parent_name = 'parent' return form.Fields(Choice( __name__='package_type', vocabulary=make_package_type_vocabulary( parent_name, self.search_higher_parent_option), default=DEFAULT_PACKAGE_TYPE, required=True))
class INewsItemSchema(Interface): """Schema for news item views. """ title = TextLine(title=_(u'Title'), readonly=True) text_format = Choice(title=_(u'Format'), vocabulary='cmf.AvailableTextFormats') description = Text(title=_(u'Lead-in'), required=False, missing_value=u'') text = Text(title=_(u'Body'), required=False, missing_value=u'')
class IThemeRelation(Interface): """ A theme can be related to other themes. """ related = List( title=u"Related themes", description=u"List of themes that this theme is related to.", required=False, max_length=5, value_type=Choice( title=u"Theme", vocabulary="Theme Centres", ))
class IPersonalPreferences(Interface): """ Provide schema for personalize form """ visible_ids = Bool( title=_(u'label_edit_short_names', default=u'Allow editing of Short Names'), description=_( u'help_display_names', default=(u'Determines if Short Names (also known ' u'as IDs) are changable when editing items. If Short ' u'Names are not displayed, they will be generated ' u'automatically.')), required=False) wysiwyg_editor = Choice( title=_(u'label_wysiwyg_editor', default=u'Wysiwyg editor'), description=_(u'help_wysiwyg_editor', default=u'Wysiwyg editor to use.'), vocabulary="plone.app.vocabularies.AvailableEditors", required=False, ) ext_editor = Bool( title=_(u'label_ext_editor', default=u'Enable external editing'), description=_(u'help_content_ext_editor', default=u'When checked, an option will be ' 'made visible on each page which allows you ' 'to edit content with your favorite editor ' 'instead of using browser-based editors. This ' 'requires an additional application, most often ' 'ExternalEditor or ZopeEditManager, installed ' 'client-side. Ask your administrator for more ' 'information if needed.'), ) language = Choice( title=_(u'label_language', default=u'Language'), description=_(u'help_preferred_language', u'Your preferred language.'), vocabulary="plone.app.vocabularies.AvailableContentLanguages", required=False)
class IDevice(Interface): """A device object.""" cpuType = TextLine(title=_(u'CPU type'), description=_(u'Text of CPU type'), required=False) memsize = Int(title=_(u'Memory size (MB)'), description=_(u'Memory size in MB'), required=False) interfaces = List( title=_(u"Interface"), value_type=Choice(vocabulary='AllUnusedOrUsedDeviceInterfaces'), required=False, default=[]) osoftwares = List( title=_(u"Operating software"), value_type=Choice( vocabulary='AllUnusedOrUsedDeviceOperatingSoftwares'), required=False, default=[]) appsoftwares = List( title=_(u"Application software"), value_type=Choice( vocabulary='AllUnusedOrUsedDeviceApplicationSoftwares'), required=False, default=[]) logicalDevices = List(title=_(u"Logical Devices"), value_type=Choice(vocabulary='AllLogicalDevices'), required=False, default=[]) physicalMedia = List(title=_(u"Physical Media"), value_type=Choice(vocabulary='AllPhysicalMedia'), required=False, default=[])
class IFbSchema(Interface): """ Facebook configurations """ fb_enabled = Bool( title=_(u"Enable Facebook button"), default=True, required=False, ) fb_typebutton = Choice( title=_(u"Choose the type of button you want"), required=True, default=u'like', vocabulary=buttonTypes, ) fbaction = Choice( title=_(u'Verb to display'), description=_( u'help_verb_display', default=u"The verb to display in the facebook button. " u"Currently only 'like' and 'recommend' are " u"supported." u"Only used for 'Like' button type.", ), required=True, default=u'like', vocabulary=verbs, ) fbadmins = TextLine( title=_(u'Admins'), description=_( u'help_admins', default=u"A comma-separated list of either the " u"Facebook IDs of page administrators or a " u"Facebook Platform application ID.", ), required=False, )
class ISkinnable(Interface): """Skinnable content interface""" can_inherit_skin = Attribute("Check if skin can be inherited") inherit_skin = Bool(title=_("Inherit parent skin?"), description=_("Should we reuse parent skin?"), required=True, default=False) no_inherit_skin = Bool(title=_("Don't inherit parent skin?"), description=_("Should we override parent skin?"), required=True, default=True) skin_parent = Attribute("Skin parent (local or inherited)") skin = Choice( title=_("Custom graphic theme"), description=_( "This theme will be used to handle graphic design (colors and " "images)"), vocabulary=USER_SKINS_VOCABULARY_NAME, required=False) @invariant def check_skin(self): """Check for required skin if not inherited""" if self.no_inherit_skin and not self.skin: raise Invalid( _("You must select a custom skin or inherit from parent!")) def get_skin(self, request=None): """Get skin matching this content""" custom_stylesheet = FileField( title=_("Custom stylesheet"), description=_("This custom stylesheet will be used to override " "selected theme styles"), required=False) editor_stylesheet = FileField( title=_("Editor stylesheet"), description=_("Styles defined into this stylesheet will be " "available into HTML editor"), required=False) custom_script = FileField( title=_("Custom script"), description=_("This custom javascript file will be used to add " "dynamic features to selected theme"), required=False)
def test_get_widgets_for_schema_fields(self): salutation = Choice(title=u'Salutation', values=("Mr.", "Mrs.", "Captain", "Don")) contactname = TextLine(title=u'Name') request = FakeRequest() salutation = salutation.bind(request) contactname = contactname.bind(request) view1 = getViewProviding(contactname, IInputWidget, request) self.assertEquals(view1.__class__, zope.app.form.browser.textwidgets.TextWidget) view2 = getViewProviding(salutation, IInputWidget, request) self.assertEquals(view2.__class__, zope.app.form.browser.itemswidgets.DropdownWidget)
def test_widget_extract(self): from plone.app.widgets.dx import SelectWidget widget = SelectWidget(self.request) widget.field = Choice( __name__='selectfield', values=['one', 'two', 'three'] ) widget.name = 'selectfield' self.request.form['selectfield'] = 'one' self.assertEquals(widget.extract(), ('one',)) widget.multiple = True self.request.form['selectfield'] = 'one;two' self.assertEquals(widget.extract(), ('one;two', ))
def createEntryStatusField(self, entry): """Create a field with a vocabulary with entry's import status. :return: A form.Fields instance containing the status field. """ name = 'status_%d' % entry.id self._initial_values[name] = entry.status.name return form.Fields(Choice(__name__=name, source=EntryImportStatusVocabularyFactory( entry, self.user), title=_('Select import status')), custom_widget=self.custom_widgets['status'], render_context=self.render_context)