Views¶
- class tom_alerts.views.BrokerQueryCreateView(**kwargs)¶
View for creating a new query to a broker. Requires authentication.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_broker_name()¶
Returns the broker specified in the request
- Returns:
Broker name
- Return type:
str
- get_form_class()¶
Returns the form class to use in this view. The form class will be the one defined in the specific broker module for which a new query is being created.
- get_form(form_class=None)¶
Returns an instance of the form to be used in this view.
- Returns:
Form instance
- Return type:
django.forms.Form
- get_initial()¶
Returns the initial data to use for forms on this view.
- Returns:
dict of initial values
- Return type:
dict
- form_valid(form)¶
Saves the associated
BrokerQuery
and redirects to theBrokerQuery
list.
- class tom_alerts.views.BrokerQueryUpdateView(**kwargs)¶
View that handles the modification of a previously saved
BrokerQuery
. Requires authentication.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_object()¶
Returns the
BrokerQuery
object that corresponds with the ID in the query path.- Returns:
BrokerQuery
object- Return type:
BrokerQuery
- get_form_class()¶
Returns the form class to use in this view. The form class will be the one defined in the specific broker module for which the query is being updated.
- get_form(form_class=None)¶
Returns an instance of the form to be used in this view.
- Returns:
Form instance
- Return type:
django.forms.Form
- get_initial()¶
Returns the initial data to use for forms on this view. Initial data for this form consists of the name of the broker that the query is for.
- Returns:
dict of initial values
- Return type:
dict
- form_valid(form)¶
Saves the associated
BrokerQuery
and redirects to theBrokerQuery
list.
- class tom_alerts.views.BrokerQueryFilter(data=None, queryset=None, *, request=None, prefix=None)¶
Defines the available fields for filtering the list of broker queries.
- class tom_alerts.views.BrokerQueryListView(**kwargs)¶
View that displays all saved
BrokerQuery
objects.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- model¶
alias of
BrokerQuery
- filterset_class¶
alias of
BrokerQueryFilter
- get_context_data(*args, **kwargs)¶
Adds the brokers available to the TOM to the context dictionary.
- Returns:
context
- Return type:
dict
- class tom_alerts.views.BrokerQueryDeleteView(*args, **kwargs)¶
View that handles the deletion of a saved
BrokerQuery
. Requires authentication.- model¶
alias of
BrokerQuery
- class tom_alerts.views.RunQueryView(**kwargs)¶
View that handles the running of a specific
BrokerQuery
.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_template_names() List[str] ¶
Override the base class method to ask the broker if it has specified a Broker-specific template to use. If so, put it at the front of the returned list of template_names.
- get_context_data(*args, **kwargs)¶
Runs the
fetch_alerts
method specific to the givenBrokerQuery
and adds the matching alerts to the context dictionary.- Returns:
context
- Return type:
dict
- class tom_alerts.views.CreateTargetFromAlertView(**kwargs)¶
View that handles the creation of
Target
objects from aBrokerQuery
result. Requires authentication.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- post(request, *args, **kwargs)¶
Handles the POST requests to this view. Creates a
Target
for each alert sent in the POST. Redirects to theTargetListView
if multiple targets were created, and theTargetUpdateView
if only one was created. Redirects to theRunQueryView
if noTarget
objects. were successfully created.
- class tom_alerts.views.SubmitAlertUpstreamView(**kwargs)¶
View used to submit alerts to an upstream broker, such as SCIMMA’s Hopskotch or the Transient Name Server.
While this view handles the query parameters for target_id and observation_record_id by default, it will send any additional query parameters to the broker, allowing a broker to use any arbitrary parameters.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_redirect_url()¶
If
next
is provided in the query params, redirects tonext
. IfHTTP_REFERER
is present on theMETA
property of the request, redirects toHTTP_REFERER
. Else redirects to /.- Returns:
url to redirect to
- Return type:
str