Views¶
-
class
tom_observations.views.
ObservationFilter
(data=None, queryset=None, *, request=None, prefix=None)¶ Defines the available fields for filtering the list of
ObservationRecord
objects.
-
class
tom_observations.views.
ObservationListView
(**kwargs)¶ View that displays all
ObservationRecord
objects.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
filterset_class
¶ alias of
ObservationFilter
-
model
¶
-
get_queryset
(*args, **kwargs)¶ Gets the set of
ObservationRecord
objects associated with the targets that the user is authorized to view.- Returns
set of ObservationRecords
- Return type
QuerySet
-
get
(request, *args, **kwargs)¶ Handles the GET requests to this view. If update_status is passed in the query parameters, calls the updatestatus management command to query for new statuses for
ObservationRecord
objects.- Parameters
request (HTTPRequest) – request object for this GET request
-
-
class
tom_observations.views.
ObservationCreateView
(**kwargs)¶ View for creation/submission of an observation. Requries authentication.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
get_target_id
()¶ Parses the target id for the given observation from the query parameters.
- Returns
id of the target for observing
- Return type
int
-
get_target
()¶ Gets the target for observing from the database
- Returns
target for observing
- Return type
-
get_facility
()¶ Gets the facility from which the target is being observed from the query parameters
- Returns
facility name
- Return type
str
-
get_facility_class
()¶ Gets the facility interface class
- Returns
facility class name
- Return type
str
-
get_observation_type
()¶ Gets the observation type from the query parameters of the request.
- Returns
observation type
- Return type
str
-
get_context_data
(**kwargs)¶ Adds the available observation types for the observing facility to the context object.
- Returns
context dictionary
- Return type
dict
-
get_form_class
()¶ Gets the observation form class for the facility and selected observation type in the query parameters.
- Returns
observation form
- Return type
subclass of GenericObservationForm
-
get_form
()¶ Gets an instance of the form appropriate for the request.
- Returns
observation form
- Return type
subclass of GenericObservationForm
-
get_initial
()¶ Populates the observation form with initial data including the id of the target to be observed, the facility at which the observation will take place, and the observation type desired.
- Returns
initial form data
- Return type
dict
-
form_valid
(form)¶ Runs after form validation. Submits the observation to the desired facility and creates an associated
ObservationRecord
, then redirects to the detail page of the target to be observed.- Parameters
form (subclass of GenericObservationForm) – form containing observating request parameters
-
-
class
tom_observations.views.
ManualObservationCreateView
(**kwargs)¶ View for associating a pre-existing observation with a target. Requires authentication.
This view is not currently exposed in the out-of-the-box TOM Toolkit.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
get_target_id
()¶ Gets the id of the target of the observation from the query parameters.
- Returns
target id
- Return type
int
-
get_initial
()¶ Populates the
ManualObservationForm
hidden field for target id with the id from the specified target.- Returns
initial form data
- Return type
dict
-
get_target
()¶ Gets the
Target
associated with the specified target_id from the database.- Returns
target instance to be associated with an observation
- Return type
-
form_valid
(form)¶ Runs after form validation. Creates a new
ObservationRecord
associated with the specified target and facility.
-
-
class
tom_observations.views.
ObservationRecordDetailView
(**kwargs)¶ View for displaying the details of an
ObservationRecord
object.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model
¶
-
get_queryset
(*args, **kwargs)¶ Gets the set of
ObservationRecord
objects associated with targets that the current user is authorized to view.- Returns
set of ObservationRecords
- Return type
QuerySet
-
get_context_data
(*args, **kwargs)¶ Adds a number of items to the context object for this view, including the form for adding resulting
DataProduct
objects to aDataProductGroup
, theDataProduct
objects associated with theObservationRecord
, and the most recent image from thisObservationRecord
. It also populates theDataProductUploadForm
hidden fields with initial data.- Returns
context dictionary
- Return type
dict
-