USER_QUERY = Term(CONTENTTYPE, CONTENTTYPE_USER) TICKET_QUERY = Term(ITEMTYPE, ITEMTYPE_TICKET) Rating = SmallNatural.using(optional=True).with_properties(lower=1, upper=5) def get_itemid_short_summary(rev): return '{itemid} ({summary})'.format(itemid=rev.meta[ITEMID][:4], summary=rev.meta[SUMMARY][:50]) def get_name(rev): return rev.meta[NAME][0] OptionalTicketReference = Reference.to(TICKET_QUERY, ).using( optional=True, ).with_properties(label_getter=get_itemid_short_summary, ) OptionalUserReference = Reference.to(USER_QUERY, ).using( optional=True, ).with_properties( empty_label='(Nobody)', label_getter=get_name, ) class AdvancedSearchForm(Form): q = Search summary = Text.using(label=L_("Summary"), optional=False).with_properties \ (widget=WIDGET_SEARCH, placeholder=L_("Find Tickets")) effort = Rating.using(label=L_("Effort")) difficulty = Rating.using(label=L_("Difficulty")) severity = Rating.using(label=L_("Severity")) priority = Rating.using(label=L_("Priority"))
Rating = SmallNatural.using(optional=True).with_properties(lower=1, upper=5) def get_itemid_short_summary(rev): return '{itemid} ({summary})'.format(itemid=rev.meta[ITEMID][:4], summary=rev.meta[SUMMARY][:50]) def get_name(rev): return rev.meta[NAME][0] OptionalTicketReference = Reference.to( TICKET_QUERY, ).using( optional=True, ).with_properties( label_getter=get_itemid_short_summary, ) OptionalUserReference = Reference.to( USER_QUERY, ).using( optional=True, ).with_properties( empty_label='(Nobody)', label_getter=get_name, ) class AdvancedSearchForm(Form): q = Search
Reference, BackReference, SelectSubmit) from MoinMoin.storage.middleware.protecting import AccessDenied from MoinMoin.constants.keys import (ITEMTYPE, CONTENTTYPE, ITEMID, CURRENT, SUPERSEDED_BY, SUBSCRIPTIONS, DEPENDS_ON) from MoinMoin.constants.contenttypes import CONTENTTYPE_USER from MoinMoin.items import Item, Contentful, register, BaseModifyForm from MoinMoin.items.content import NonExistentContent ITEMTYPE_TICKET = u'ticket' USER_QUERY = Term(CONTENTTYPE, CONTENTTYPE_USER) TICKET_QUERY = Term(ITEMTYPE, ITEMTYPE_TICKET) Rating = SmallNatural.using(optional=True).with_properties(lower=1, upper=5) OptionalTicketReference = Reference.to(TICKET_QUERY).using(optional=True) OptionalUserReference = Reference.to(USER_QUERY).using(optional=True).with_properties(empty_label='(Nobody)') class TicketMetaForm(Form): summary = OptionalText.using(label=L_("Summary")).with_properties(placeholder=L_("One-line summary of the item")) effort = Rating.using(label=L_("Effort")) difficulty = Rating.using(label=L_("Difficulty")) severity = Rating.using(label=L_("Severity")) priority = Rating.using(label=L_("Priority")) tags = Tags.using(optional=True) assigned_to = OptionalUserReference.using(label=L_("Assigned To")) superseded_by = OptionalTicketReference.using(label=L_("Superseded By")) depends_on = OptionalTicketReference.using(label=L_("Depends On"))