ticket.handler

Attributes

_LinkOrCallback

_H

_Q

Classes

Handler

Defines a generic handler, responsible for a subset of the tickets.

HandlerRegistry

Module Contents

ticket.handler._LinkOrCallback: typing_extensions.TypeAlias[source]
ticket.handler._H[source]
ticket.handler._Q[source]
class ticket.handler.Handler(ticket: onegov.ticket.model.Ticket, handler_id: UUID | str, handler_data: dict[str, Any])[source]

Defines a generic handler, responsible for a subset of the tickets.

onegov.ticket is meant to be a rather generic bucket of tickets, to which varying modules submit tickets with varying content and different actionables.

Each module wanting to submit tickets needs to implement a handler with a unique id and a unique short code. The short code is added in front of the ticket number.

Tickets submitted to the database are shown in a list, without handler involvement. When a ticket is displayed, the handler is called with whatever data the handler supplied during ticket submission.

The handler then uses the handler data to access whatever data it needs to display a summary as well as links to certain actions (possibly a link to the original item, links that change the state of the ticket as well as the data associated with the handler, etc.).

property session: sqlalchemy.orm.Session[source]
refresh() None[source]

Updates the current ticket with the latest data from the handler.

property email: str | None[source]
Abstractmethod:

Returns the email address behind the ticket request.

property submitter_name: str | None[source]

Returns the name of the submitter

property submitter_address: str | None[source]

Returns the address of the submitter

property submitter_phone: str | None[source]

Returns the phone of the submitter

property title: str[source]
Abstractmethod:

Returns the title of the ticket. If this title may change over time, the handler must call self.refresh() when there’s a change.

property subtitle: str | None[source]
Abstractmethod:

Returns the subtitle of the ticket. If this title may change over time, the handler must call self.refresh() when there’s a change.

property group: str | None[source]
Abstractmethod:

Returns the group of the ticket. If this group may change over time, the handler must call self.refresh() when there’s a change.

property deleted: bool[source]
Abstractmethod:

Returns true if the underlying model was deleted. It is best to never let that happen, as we want tickets to stay around forever.

However, this can make sense in certain scenarios. Note that if you do delete your underlying model, make sure to call onegov.ticket.models.Ticket.create_snapshot() beforehand!

property extra_data: Sequence[str][source]

An array of string values which are indexed in elasticsearch when the ticket is stored there.

property payment: Payment | None[source]

An optional link to a onegov.pay payment record.

property undecided: bool[source]

Returns true if there has been no decision about the subject of this handler.

For example, if a reservation ticket has been accepted, but the reservation has been neither confirmed nor cancelled, the ticket can be seen as undecided.

This is an optional flag that may be implemented by handlers. If a ticket is undecided, the UI might show a special icon and it might warn the user if he closes the ticket without making a decision.

By default, the ticket is assumed to be decided for backwards compatibility and for tickets where this does not make sense (a simple form submission may not have any way of knowing if there has been a decision or not).

classmethod handle_extra_parameters(session: sqlalchemy.orm.Session, query: _Q, extra_parameters: dict[str, Any]) _Q[source]

Takes a dictionary of extra parameters and uses it to optionally modifiy the query used for the collection.

Use this to add handler-defined custom filters with extra query parameters. Only called if the collection is already limited to the given handler. If all handlers are shown in the collection, this method is not called.

If no extra paramaters were given, this method is not called.

Returns the modified or unmodified query.

abstract get_summary(request: onegov.core.request.CoreRequest) str[source]

Returns the summary of the current ticket as a html string.

Returns the links associated with the current ticket in the following format:

[
    ('Link Title', 'http://link'),
    ('Link Title 2', 'http://link2'),
]

If the links are not tuples, but callables, they will be called with the request which should return the rendered link.

property ticket_deletable: bool[source]
prepare_delete_ticket() None[source]

The handler knows best what to do when a ticket is called for deletion.

class ticket.handler.HandlerRegistry[source]
_reserved_handler_codes[source]
registry: dict[str, type[Handler]][source]
get(handler_code: str) type[Handler][source]

Returns the handler registration for the given id. If the id does not exist, a KeyError is raised.

register(handler_code: str, handler_class: type[Handler]) None[source]

Registers a handler.

Handler_code:

Three characters long shortcode of the handler added in front of the ticket number. Must be globally unique and must not change!

Examples for good handler_codes:

FRM
ONS
RES
EVT
Handler_class:

A handler class inheriting from Handler.

registered_handler(handler_code: str) Callable[[type[_H]], type[_H]][source]

A decorator to register handles as follows:

@handlers.registered_handler('FOO')
class FooHandler(Handler):

pass