Views¶
-
class
tom_targets.views.TargetListView(**kwargs)¶ View for listing targets in the TOM. Only shows targets that the user is authorized to view. Requires authorization.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.Target
-
get_context_data(*args, **kwargs)¶ 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
-
-
class
tom_targets.views.TargetCreateView(**kwargs)¶ View for creating a Target. Requires authentication.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.Target
-
get_default_target_type()¶ 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_target_type()¶ 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
-
get_initial()¶ 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_context_data(**kwargs)¶ 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_form_class()¶ Return the form class to use in this view.
- Returns
form class for target creation
- Return type
subclass of TargetCreateForm
-
form_valid(form)¶ 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_form(*args, **kwargs)¶ 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
-
-
class
tom_targets.views.TargetUpdateView(**kwargs)¶ View that handles updating a target. Requires authorization.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.Target
-
get_context_data(**kwargs)¶ Adds formset for
TargetNameandTargetExtrato the context.- Returns
context object
- Return type
dict
-
form_valid(form)¶ 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_queryset(*args, **kwargs)¶ 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
-
get_form_class()¶ Return the form class to use in this view.
- Returns
form class for target update
- Return type
subclass of TargetCreateForm
-
get_initial()¶ 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_form(*args, **kwargs)¶ 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
-
-
class
tom_targets.views.TargetDeleteView(**kwargs)¶ View for deleting a target. Requires authorization.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.Target
-
-
class
tom_targets.views.TargetDetailView(**kwargs)¶ View that handles the display of the target details. Requires authorization.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.Target
-
get_context_data(*args, **kwargs)¶ Adds the
DataProductUploadFormto the context and prepopulates the hidden fields.- Returns
context object
- Return type
dict
-
get(request, *args, **kwargs)¶ 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
-
-
class
tom_targets.views.TargetImportView(**kwargs)¶ View that handles the import of targets from a CSV. Requires authentication.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
post(request)¶ Handles the POST requests to this view. Creates a StringIO object and passes it to
import_targets.- Parameters
request (HTTPRequest) – the request object passed to this view
-
-
class
tom_targets.views.TargetExportView(**kwargs)¶ View that handles the export of targets to a CSV. Only exports selected targets.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
render_to_response(context, **response_kwargs)¶ Returns a response containing the exported CSV of selected targets.
- Parameters
context (dict) – Context object for this view
- Returns
response class with CSV
- Return type
StreamingHttpResponse
-
-
class
tom_targets.views.TargetAddRemoveGroupingView(**kwargs)¶ View that handles addition and removal of targets to target groups. 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. Routes the information from the request and query parameters to the appropriate utility method in
groups.py.- Parameters
request (HTTPRequest) – the request object passed to this view
-
-
class
tom_targets.views.TargetGroupingView(**kwargs)¶ View that handles the display of
TargetListobjects, also known as target groups. Requires authorization.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.TargetList
-
-
class
tom_targets.views.TargetGroupingDeleteView(**kwargs)¶ View that handles the deletion of
TargetListobjects, also known as target groups. Requires authorization.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.TargetList
-
-
class
tom_targets.views.TargetGroupingCreateView(**kwargs)¶ View that handles the creation of
TargetListobjects, also known as target groups. Requires authentication.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
model¶ alias of
tom_targets.models.TargetList
-
form_valid(form)¶ 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
-