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
BrokerQueryand redirects to theBrokerQuerylist.
- 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
BrokerQueryobject that corresponds with the ID in the query path.- Returns:
BrokerQueryobject- 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
BrokerQueryand redirects to theBrokerQuerylist.
- 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
BrokerQueryobjects.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(**kwargs)¶
View that handles the deletion of a saved
BrokerQuery. Requires authentication.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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_alertsmethod specific to the givenBrokerQueryand 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
Targetobjects from aBrokerQueryresult. 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
Targetfor each alert sent in the POST. Redirects to theTargetListViewif multiple targets were created, and theTargetUpdateViewif only one was created. Redirects to theRunQueryViewif noTargetobjects. 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
nextis provided in the query params, redirects tonext. IfHTTP_REFERERis present on theMETAproperty of the request, redirects toHTTP_REFERER. Else redirects to /.- Returns:
url to redirect to
- Return type:
str