agency.models.ticket
====================

.. py:module:: agency.models.ticket


Classes
-------

.. autoapisummary::

   agency.models.ticket.AgencyMutationTicket
   agency.models.ticket.PersonMutationTicket
   agency.models.ticket.AgencyMutationHandler
   agency.models.ticket.PersonMutationHandler


Module Contents
---------------

.. py:class:: AgencyMutationTicket

   Bases: :py:obj:`onegov.org.models.ticket.OrgTicketMixin`, :py:obj:`onegov.ticket.Ticket`


   Adds additional methods to the ticket, needed by the organisations
   implementation of it. Strictly limited to things that
   do not belong into onegov.ticket.



   .. py:attribute:: __mapper_args__


   .. py:attribute:: es_type_name
      :value: 'agency_tickets'


      Returns the unique type name of the model. 



   .. py:property:: handler
      :type: AgencyMutationHandler


      Returns an instance of the handler associated with this ticket. 



   .. py:method:: reference_group(request: onegov.org.request.OrgRequest) -> str


.. py:class:: PersonMutationTicket

   Bases: :py:obj:`onegov.org.models.ticket.OrgTicketMixin`, :py:obj:`onegov.ticket.Ticket`


   Adds additional methods to the ticket, needed by the organisations
   implementation of it. Strictly limited to things that
   do not belong into onegov.ticket.



   .. py:attribute:: __mapper_args__


   .. py:attribute:: es_type_name
      :value: 'person_tickets'


      Returns the unique type name of the model. 



   .. py:property:: handler
      :type: PersonMutationHandler


      Returns an instance of the handler associated with this ticket. 



   .. py:method:: reference_group(request: onegov.org.request.OrgRequest) -> str


.. py:class:: AgencyMutationHandler(ticket: onegov.ticket.model.Ticket, handler_id: uuid.UUID | str, handler_data: dict[str, Any])

   Bases: :py:obj:`onegov.ticket.Handler`


   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.).



   .. py:attribute:: handler_title


   .. py:attribute:: code_title


   .. py:property:: collection
      :type: onegov.agency.collections.ExtendedAgencyCollection



   .. py:property:: agency
      :type: onegov.agency.models.ExtendedAgency | None



   .. py:property:: mutation
      :type: onegov.agency.models.AgencyMutation | None



   .. py:property:: deleted
      :type: bool


      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
      :meth:`onegov.ticket.models.Ticket.create_snapshot` beforehand!




   .. py:property:: email
      :type: str


      Returns the email address behind the ticket request. 



   .. py:property:: message
      :type: str



   .. py:property:: proposed_changes
      :type: dict[str, Any]



   .. py:property:: state
      :type: str | None



   .. py:property:: title
      :type: str


      Returns the title of the ticket. If this title may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:property:: subtitle
      :type: str


      Returns the subtitle of the ticket. If this title may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:property:: group
      :type: str


      Returns the group of the ticket. If this group may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:method:: get_summary(request: onegov.agency.request.AgencyRequest) -> markupsafe.Markup

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



   .. py:method:: get_links(request: onegov.agency.request.AgencyRequest) -> list[onegov.core.elements.Link]

      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.



.. py:class:: PersonMutationHandler(ticket: onegov.ticket.model.Ticket, handler_id: uuid.UUID | str, handler_data: dict[str, Any])

   Bases: :py:obj:`onegov.ticket.Handler`


   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.).



   .. py:attribute:: handler_title


   .. py:attribute:: code_title


   .. py:property:: collection
      :type: onegov.agency.collections.ExtendedPersonCollection



   .. py:property:: person
      :type: onegov.agency.models.ExtendedPerson | None



   .. py:property:: mutation
      :type: onegov.agency.models.PersonMutation | None



   .. py:property:: deleted
      :type: bool


      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
      :meth:`onegov.ticket.models.Ticket.create_snapshot` beforehand!




   .. py:property:: email
      :type: str


      Returns the email address behind the ticket request. 



   .. py:property:: message
      :type: str



   .. py:property:: proposed_changes
      :type: dict[str, Any]



   .. py:property:: state
      :type: str | None



   .. py:property:: title
      :type: str


      Returns the title of the ticket. If this title may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:property:: subtitle
      :type: str


      Returns the subtitle of the ticket. If this title may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:property:: group
      :type: str


      Returns the group of the ticket. If this group may change over
      time, the handler must call :meth:`self.refresh` when there's a change.




   .. py:method:: get_summary(request: onegov.agency.request.AgencyRequest) -> markupsafe.Markup

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



   .. py:method:: get_links(request: onegov.agency.request.AgencyRequest) -> list[onegov.core.elements.Link]

      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.