Views#

class tom_targets.views.PersistentShareManageFormView(**kwargs)[source]#
serializer_class#

alias of PersistentShareSerializer

class tom_targets.views.PersistentShareManageTable(**kwargs)[source]#
class tom_targets.views.TargetAddRemoveGroupingView(**kwargs)[source]#

View that handles addition and removal of targets to target groups. Requires authentication.

post(request, *args, **kwargs)[source]#

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.TargetCreateView(**kwargs)[source]#

View for creating a Target. Requires authentication.

form_valid(form)[source]#

Runs after form validation. Creates the Target, and creates any TargetName or TargetExtra objects, then runs the target_post_save hook 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 TOM

extra_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 TargetCreateForm and 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 created

groups: 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 ObservationRecord objects associated with this target.

Parameters:

request (HTTPRequest) – the request object passed to this view

get_context_data(*args, **kwargs)[source]#

Adds the DataProductUploadForm to 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.

render_to_response(
context,
**response_kwargs,
)[source]#

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.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,
)[source]#

Adds the TargetListShareForm to the context and prepopulates the hidden fields. :returns: context object :rtype: dict

get_observable_targets(
targets_page,
window_start,
observatory,
)[source]#

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

post(request, *args, **kwargs)[source]#

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

class tom_targets.views.TargetGroupingCreateView(**kwargs)[source]#

View that handles the creation of TargetList objects, 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 TargetList objects, also known as target groups. Requires authorization.

model#

alias of TargetList

class tom_targets.views.TargetGroupingShareView(**kwargs)[source]#

View for sharing a TargetList. Requires authorization.

form_class#

alias of TargetListShareForm

form_invalid(form)[source]#

Adds errors to Django messaging framework in the case of an invalid form and redirects to the previous page.

form_valid(form)[source]#

If the form is valid, redirect to the supplied URL.

get_context_data(*args, **kwargs)[source]#

Adds the TargetListShareForm to the context and prepopulates the hidden fields. :returns: context object :rtype: dict

get_success_url()[source]#

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 TargetList objects, also known as target groups. Requires authorization.

filterset_class#

alias of TargetGroupFilterSet

get_context_data(*args, **kwargs)[source]#

Adds settings.DATA_SHARING to 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.

post(request)[source]#

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.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 TargetList objects 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

get_name_select_choices(pk1, pk2)[source]#

Puts user selected targets in a choice field on the target_merge.html page, using the target pk’s.

post(request, *args, **kwargs)[source]#

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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.

class tom_targets.views.TargetPersistentShareManageFormView(**kwargs)[source]#
class tom_targets.views.TargetPersistentShareManageTable(**kwargs)[source]#
class tom_targets.views.TargetSeedView(**kwargs)[source]#
class tom_targets.views.TargetShareView(**kwargs)[source]#

View for sharing a target. Requires authorization.

form_class#

alias of TargetShareForm

form_invalid(form)[source]#

Adds errors to Django messaging framework in the case of an invalid form and redirects to the previous page.

form_valid(form)[source]#

Shares the target with the selected destination(s) and redirects to the target detail page.

get_context_data(*args, **kwargs)[source]#

Adds the target information to the context. :returns: context object :rtype: dict

get_success_url()[source]#

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 TargetExtra and TargetName formsets, then calls the superclass implementation of form_valid, which saves the Target. 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_save hook.

Parameters:

form (subclass of TargetCreateForm) – Form data for target update

get_context_data(**kwargs)[source]#

Adds formset for TargetName and TargetExtra to the context.

Returns:

context object

Return type:

dict

get_form(*args, **kwargs)[source]#

Gets an instance of the TargetCreateForm and 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