ticket.collection

Attributes

ExtendedTicketState

Classes

TicketCollectionPagination

Provides collections with pagination, if they implement a few

TicketCount

TicketCollection

Provides collections with pagination, if they implement a few

ArchivedTicketCollection

Provides collections with pagination, if they implement a few

Module Contents

ticket.collection.ExtendedTicketState: typing_extensions.TypeAlias[source]
class ticket.collection.TicketCollectionPagination(session: sqlalchemy.orm.Session, page: int = 0, state: ExtendedTicketState = 'open', handler: str = 'ALL', group: str | None = None, owner: str = '*', extra_parameters: dict[str, Any] | None = None)[source]

Bases: onegov.core.collection.Pagination[onegov.ticket.model.Ticket]

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

__eq__(other: object) bool[source]

Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages.

subset() Query[Ticket][source]

Returns an SQLAlchemy query containing all records that should be considered for pagination.

property page_index: int[source]

Returns the current page index (starting at 0).

page_by_index(index: int) typing_extensions.Self[source]

Returns the page at the given index. A page here means an instance of the class inheriting from the Pagination base class.

available_groups(handler: str = '*') tuple[str, Ellipsis][source]
for_state(state: ExtendedTicketState) typing_extensions.Self[source]
for_handler(handler: str) typing_extensions.Self[source]
for_group(group: str) typing_extensions.Self[source]
for_owner(owner: str | uuid.UUID) typing_extensions.Self[source]
class ticket.collection.TicketCount[source]

Bases: NamedTuple

open: int = 0[source]
pending: int = 0[source]
closed: int = 0[source]
archived: int = 0[source]
class ticket.collection.TicketCollection(session: sqlalchemy.orm.Session, page: int = 0, state: ExtendedTicketState = 'open', handler: str = 'ALL', group: str | None = None, owner: str = '*', extra_parameters: dict[str, Any] | None = None)[source]

Bases: TicketCollectionPagination

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

query() Query[Ticket][source]
random_number(length: int) int[source]
random_ticket_number(handler_code: str) str[source]
is_existing_ticket_number(ticket_number: str) bool[source]
issue_unique_ticket_number(handler_code: str) str[source]

Randomly generates a new ticket number, ensuring it is unique for the given handler_code.

The resulting code is of the following form:

XXX-0000-1111

Where XXX is the handler_code and the rest is a 12 character sequence of random numbers separated by dashes.

This gives us 10^8 or 100 million ticket numbers for each handler.

Though we’ll never reach that limit, there is an increasing chance of conflict with existing ticket numbers, so we have to check against the database.

Still, this number is not unguessable (say in an URL) - there we have to rely on the internal ticket id, which is a uuid.

In a social engineering setting, where we don’t have the abilty to quickly try out thousands of numbers, the ticket number should be pretty unguessable however.

open_ticket(handler_code: str, handler_id: str, **handler_data: Any) onegov.ticket.model.Ticket[source]

Opens a new ticket using the given handler.

by_handler_code(handler_code: str) list[onegov.ticket.model.Ticket][source]
by_id(id: uuid.UUID, ensure_handler_code: str | None = None) onegov.ticket.model.Ticket | None[source]
by_handler_id(handler_id: str) onegov.ticket.model.Ticket | None[source]
get_count(excl_archived: bool = True) TicketCount[source]
by_handler_data_id(handler_data_id: str | uuid.UUID) Query[Ticket][source]
class ticket.collection.ArchivedTicketCollection(session: sqlalchemy.orm.Session, page: int = 0, state: ExtendedTicketState = 'open', handler: str = 'ALL', group: str | None = None, owner: str = '*', extra_parameters: dict[str, Any] | None = None)[source]

Bases: TicketCollectionPagination

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

query() Query[Ticket][source]