Views#
alias of
PersistentShareSerializer
- class tom_targets.views.TargetAddRemoveGroupingView(**kwargs)[source]#
View that handles addition and removal of targets to target groups. Requires authentication.
- class tom_targets.views.TargetCreateView(**kwargs)[source]#
View for creating a Target. Requires authentication.
- form_valid(form)[source]#
Runs after form validation. Creates the
Target, and creates anyTargetNameorTargetExtraobjects, then runs thetarget_post_savehook and redirects to the success URL.- Parameters:
form (subclass of TargetCreateForm) – Form data for target creation
- get_context_data(**kwargs)[source]#
Inserts certain form data into the context dict.
- Returns:
Dictionary with the following keys:
type_choices:
tuple: Tuple of 2-tuples of strings containing available target types in the TOMextra_form:
FormSet: Django formset with fields for arbitrary key/value pairs- Return type:
dict
- get_default_target_type()[source]#
Returns the user-configured target type specified in
settings.py, if it exists, otherwise returns sidereal- Returns:
User-configured target type or global default
- Return type:
str
- get_form(*args, **kwargs)[source]#
Gets an instance of the
TargetCreateFormand populates it with the groups available to the current user.- Returns:
instance of creation form
- Return type:
subclass of TargetCreateForm
- get_form_class()[source]#
Return the form class to use in this view.
- Returns:
form class for target creation
- Return type:
subclass of TargetCreateForm
- get_initial()[source]#
Returns the initial data to use for forms on this view.
- Returns:
Dictionary with the following keys:
type:
str: Type of the target to be createdgroups:
QuerySet<Group>Groups available to the current user- Return type:
dict
- get_target_type()[source]#
Gets the type of the target to be created from the query parameters. If none exists, use the default target type specified in
settings.py.- Returns:
target type
- Return type:
str
- model#
alias of
BaseTarget
- class tom_targets.views.TargetDeleteView(**kwargs)[source]#
View for deleting a target. Requires authorization.
- get_queryset(*args, **kwargs)[source]#
Return the QuerySet that will be used to look up the object.
This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.
- model#
alias of
BaseTarget
- class tom_targets.views.TargetDetailView(**kwargs)[source]#
View that handles the display of the target details.
- get(request, *args, **kwargs)[source]#
Handles the GET requests to this view. If update_status is passed into the query parameters, calls the updatestatus management command to query for new statuses for
ObservationRecordobjects associated with this target.- Parameters:
request (HTTPRequest) – the request object passed to this view
- get_context_data(*args, **kwargs)[source]#
Adds the
DataProductUploadFormto the context and prepopulates the hidden fields.- Returns:
context object
- Return type:
dict
- get_queryset(*args, **kwargs)[source]#
Return the QuerySet that will be used to look up the object.
This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.
- model#
alias of
BaseTarget
- class tom_targets.views.TargetExportView(**kwargs)[source]#
View that handles the export of targets to a CSV. Only exports selected targets.
- class tom_targets.views.TargetFacilitySelectionView(**kwargs)[source]#
View to select targets suitable to observe from a specific facility/location, taking into account target visibility from that site, as well as other user-defined constraints.
- form_class#
alias of
TargetSelectionForm
- get(request, *args, **kwargs)[source]#
Handle GET requests: instantiate a blank version of the form.
- get_context_data(
- *args,
- **kwargs,
Adds the
TargetListShareFormto the context and prepopulates the hidden fields. :returns: context object :rtype: dict
- get_observable_targets(
- targets_page,
- window_start,
- observatory,
Handles POST requests to select targets suitable for observation from this facility
- Parameters:
targets_page – int Index of the page of targets to compute visbilities for
window_start – datetime object for the start of the time window to calculate for
observatory – str Full name of the observatory to compute for. This can refer to either a facility module or general facilty entry
- Returns:
HTTPRequest
- model#
alias of
BaseTarget
- class tom_targets.views.TargetGroupingCreateView(**kwargs)[source]#
View that handles the creation of
TargetListobjects, also known as target groups. Requires authentication.- form_valid(form)[source]#
Runs after form validation. Saves the target group and assigns the user’s permissions to the group.
- Parameters:
form (django.forms.ModelForm) – Form data for target creation
- model#
alias of
TargetList
- class tom_targets.views.TargetGroupingDeleteView(**kwargs)[source]#
View that handles the deletion of
TargetListobjects, also known as target groups. Requires authorization.- model#
alias of
TargetList
View for sharing a TargetList. Requires authorization.
alias of
TargetListShareForm
Adds errors to Django messaging framework in the case of an invalid form and redirects to the previous page.
If the form is valid, redirect to the supplied URL.
Adds the
TargetListShareFormto the context and prepopulates the hidden fields. :returns: context object :rtype: dict
Redirects to the target list page with the target list name as a query parameter.
- class tom_targets.views.TargetGroupingView(**kwargs)[source]#
View that handles the display of
TargetListobjects, also known as target groups. Requires authorization.- filterset_class#
alias of
TargetGroupFilterSet
- get_context_data(*args, **kwargs)[source]#
Adds
settings.DATA_SHARINGto the context to see if sharing has been configured. :returns: context object :rtype: dict
- model#
alias of
TargetList
- table_class#
alias of
TargetGroupTable
- class tom_targets.views.TargetImportView(**kwargs)[source]#
View that handles the import of targets from a CSV. Requires authentication.
- class tom_targets.views.TargetListView(**kwargs)[source]#
View for listing targets in the TOM. Only shows targets that the user is authorized to view. Requires authorization.
- filterset_class#
alias of
TargetFilterSet
- get_context_data(*args, **kwargs)[source]#
Adds the number of targets visible, the available
TargetListobjects if the user is authenticated, and the query string to the context object.- Returns:
context dictionary
- Return type:
dict
- get_queryset(*args, **kwargs)[source]#
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- model#
alias of
BaseTarget
- table_class#
alias of
TargetTable
- class tom_targets.views.TargetMergeView(**kwargs)[source]#
View that handles choosing the primary target in the process of merging targets
- form_class#
alias of
TargetMergeForm
- get(request, *args, **kwargs)[source]#
When called as a result of the Primary Target name_select field being changed, request.htmx will be True and this should update the target_field inclusiontag/partial (via render_to_string) according to the selected target.
If this is not an HTMX request, just call super().get.
- get_context_data(*args, **kwargs)[source]#
Adds the target information to the context. :returns: context object :rtype: dict
- class tom_targets.views.TargetNameSearchView(**kwargs)[source]#
View for searching by target name. If the search returns one result, the view redirects to the corresponding TargetDetailView. Otherwise, the view redirects to the TargetListView.
View for sharing a target. Requires authorization.
alias of
TargetShareForm
Adds errors to Django messaging framework in the case of an invalid form and redirects to the previous page.
Shares the target with the selected destination(s) and redirects to the target detail page.
Adds the target information to the context. :returns: context object :rtype: dict
Redirect to target detail page for shared target
- class tom_targets.views.TargetUpdateView(**kwargs)[source]#
View that handles updating a target. Requires authorization.
- form_valid(form)[source]#
Runs after form validation. Validates and saves the
TargetExtraandTargetNameformsets, then calls the superclass implementation ofform_valid, which saves theTarget. If any forms are invalid, rolls back the changes.Saving is done in this order to ensure that new names/extras are available in the
target_post_savehook.- Parameters:
form (subclass of TargetCreateForm) – Form data for target update
- get_context_data(**kwargs)[source]#
Adds formset for
TargetNameandTargetExtrato the context.- Returns:
context object
- Return type:
dict
- get_form(*args, **kwargs)[source]#
Gets an instance of the
TargetCreateFormand populates it with the groups available to the current user.- Returns:
instance of creation form
- Return type:
subclass of TargetCreateForm
- get_form_class()[source]#
Return the form class to use in this view.
- Returns:
form class for target update
- Return type:
subclass of TargetCreateForm
- get_initial()[source]#
Returns the initial data to use for forms on this view. For the
TargetUpdateView, adds the groups that the target is a member of.- Returns:
- Return type:
dict
- get_queryset(*args, **kwargs)[source]#
Returns the queryset that will be used to look up the Target by limiting the result to targets that the user is authorized to modify.
- Returns:
Set of targets
- Return type:
QuerySet
- model#
alias of
BaseTarget