recordtransfer.views - Views
- class recordtransfer.views.Index(**kwargs)
The homepage.
- template_name = 'recordtransfer/home.html'
- recordtransfer.views.media_request(request: HttpRequest, path: str) HttpResponse
Respond to whether a media request is allowed or not.
- class recordtransfer.views.TransferSent(**kwargs)
The page a user sees when they finish a transfer.
- template_name = 'recordtransfer/transfersent.html'
- class recordtransfer.views.SystemErrorPage(**kwargs)
The page a user sees when there is some system error.
- template_name = 'recordtransfer/systemerror.html'
- class recordtransfer.views.UserProfile(**kwargs)
View to show two things: - The user’s profile information - A list of the Submissions a user has created via transfer.
- template_name = 'recordtransfer/profile.html'
- paginate_by = 10
- form_class
alias of
UserProfileForm
- success_url = '/profile/'
- success_message = 'Preferences updated'
- password_change_success_message = 'Password updated'
- error_message = 'There was an error updating your preferences. Please try again.'
- get_object(queryset=None)
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- get_context_data(**kwargs) dict[str, Any]
Add context data for the user profile view.
- get_form_kwargs() dict[str, Any]
Pass User instance to form to initialize it.
- form_valid(form: BaseModelForm) HttpResponse
Handle valid form submission.
- form_invalid(form: BaseModelForm) HttpResponse
Handle invalid form submission.
- class recordtransfer.views.About(**kwargs)
About the application.
- template_name = 'recordtransfer/about.html'
- get_context_data(**kwargs)
- class recordtransfer.views.ActivationSent(**kwargs)
The page a user sees after creating an account.
- template_name = 'recordtransfer/activationsent.html'
- class recordtransfer.views.ActivationComplete(**kwargs)
The page a user sees when their account has been activated.
- template_name = 'recordtransfer/activationcomplete.html'
- class recordtransfer.views.ActivationInvalid(**kwargs)
The page a user sees if their account could not be activated.
- template_name = 'recordtransfer/activationinvalid.html'
- class recordtransfer.views.CreateAccount(**kwargs)
Allows a user to create a new account with the SignUpForm. When the form is submitted successfully, send an email to that user with a link that lets them activate their account.
- template_name = 'recordtransfer/signupform.html'
- form_class
alias of
SignUpForm
- success_url = '/createaccount/sent/'
- form_valid(form)
If the form is valid, redirect to the supplied URL.
- recordtransfer.views.activate_account(request, uidb64, token)
- class recordtransfer.views.TransferFormWizard(*args, **kwargs)
A multi-page form for collecting user metadata and uploading files. Uses a form wizard. For more info, visit this link: https://django-formtools.readthedocs.io/en/latest/wizard.html.
- property current_step: TransferStep
Returns the current step as a TransferStep enum value.
- dispatch(request: HttpRequest, *args, **kwargs) HttpResponse
Dispatch the request to the appropriate handler method.
- validate_transfer_request(request: HttpRequest) HttpResponse | None
Validate the transfer request and return an appropriate response if invalid.
- get(request, *args, **kwargs)
This method handles GET requests.
If a GET request reaches this point, the wizard assumes that the user just starts at the first step or wants to restart the process. The data of the wizard will be reset before rendering the first step
- post(request: HttpRequest, *args, **kwargs) HttpResponse
Handle POST request to save a transfer.
- save_current_step(form: BaseInlineFormSet | BaseModelFormSet | ModelForm) None
Save the data from the current step.
- render_goto_step(goto_step: str, *args, **kwargs) HttpResponse
Perform necessary validation and data saving before going to to desired step. Skips validation if the user is trying to go to a previous step. Otherwise, validates each form before the goto step, and takes user to the step with the first error if any form is invalid.
- render_next_step(form, **kwargs) HttpResponse
Render next step of form. Overrides parent method to clear errors from the form.
- load_transfer_data(transfer: InProgressSubmission) None
Load the transfer data from an InProgressSubmission instance.
- classmethod format_step_data(step: TransferStep, data: QueryDict) dict | list[dict]
Format form data for the current step to be saved for later.
- Parameters:
step – The current step of the form.
data – The data from the form.
- Returns:
The formatted step data. If this step represents a formset, the return object will be a list of dicts, otherwise, it will be a dict.
- save_transfer(data: dict) None
Save the current state of a transfer.
- Parameters:
user – The user who is saving the transfer.
data – The form data containing the submission data to save.
following (data is a dictionary containing the) –
save_form_step: The current step of the form.
step_data: The past and current data of the form.
submission (optional): The in-progress submission model object to update.
title: The accession title of the submission.
- Returns:
A JSON response indicating the result of the save operation.
- get_form_value(step: TransferStep, field: str) str | None
Get the value of a field in a form step.
- Parameters:
step – The step of the form to get the field value from.
field – The field to get the value of.
- Returns:
The value of the field in the form step, or None if the is not populated.
- get_template_names()
Retrieve the name of the template for the current step.
- get_name_of_user(user: User) str
Get the name of a user.
Tries to get the name from the User object first, and falls back to using the form data submitted in the contact info.
- get_form_initial(step: str) dict
Populate the initial state of the form.
Populate form with saved transfer data if a “resume” request was received. Fills in the user’s name and email automatically where possible.
- get_form_kwargs(step: str | None = None) dict
Add data to inject when initializing the form.
- get_forms_for_review() OrderedDict[str, BaseForm | BaseFormSet]
Retrieve the relevant forms to be processed for the review step. This method does not validate the forms, but populates the cleaned_data attribute of each form.
- property review_step_reached: bool
Check if the user has reached the review step at some point throughout this form. This check is valid for a resumed in-progress transfer as well.
- get_context_data(form, **kwargs)
Retrieve context data for the current form template.
- Parameters:
form – The form to display to the user.
- Returns:
A dictionary of context data to be used to render the form template.
- Return type:
dict
- property num_extra_forms: int
Compute the number of extra forms to generate if current step uses a formset.
- get_all_cleaned_data()
Clean data, and populate CAAIS fields that are deferred to being created until after the submission is completed.
- set_quantity_and_unit_of_measure(cleaned_data)
Create a summary for the quantity_and_unit_of_measure from the type of files submitted.
- Parameters:
cleaned_data (dict) – The cleaned data submitted by the user
- Returns:
The cleaned form data is modified in-place
- Return type:
(None)
- done(form_list, **kwargs)
Retrieve all of the form data, and creates a Submission from it.
- Returns:
Redirects the user to their User Profile page.
- Return type:
HttpResponseRedirect
- get_submission_group(cleaned_form_data: dict) SubmissionGroup | None
Get a submission group to associate the submission with, depending on how the user filled out the submission group section of the form.
- recordtransfer.views.get_in_progress_submission(user: User, uuid: str) InProgressSubmission | None
Retrieve an in-progress submission for a given user and UUID.
- recordtransfer.views.upload_file(request: HttpRequest) JsonResponse
Upload a single file to the server, and return a token representing the file upload session. If a token is passed in the request header using the Upload-Session-Token header, the uploaded file will be added to the corresponding session.
The file type is checked against this application’s ACCEPTED_FILE_FORMATS setting, if the file is not an accepted type, an error message is returned.
- Parameters:
request – The POST request sent by the user.
- Returns:
If the upload was successful, the session token is returned in ‘upload_session_token’. If not successful, the error description is returned in ‘error’.
- Return type:
JsonResponse
- recordtransfer.views.list_uploaded_files(request: HttpRequest, session_token: str) JsonResponse
Get a list of metadata for files uploaded in a given upload session.
- Parameters:
request – The HTTP request
session_token – The upload session token from the URL
- Returns:
List of uploaded files and their details, or error message
- Return type:
JsonResponse
- recordtransfer.views.uploaded_file(request: HttpRequest, session_token: str, file_name: str) HttpResponse
Get or delete a file that has been uploaded in a given upload session.
- Parameters:
request – The HTTP request
session_token – The upload session token from the URL
file_name – The name of the file to delete
- Returns:
In the case of deletion, returns a 204 response when successfully deleted. In the case of getting a file, redirects to the file’s media path in development, or returns an X-Accel-Redirect to the file’s media path if in production.
- Return type:
HttpResponse
- class recordtransfer.views.DeleteTransfer(**kwargs)
View to handle the deletion of an in-progress submission.
- template_name = 'recordtransfer/transfer_delete.html'
- success_message = 'In-progress submission deleted'
- error_message = 'There was an error deleting the in-progress submission'
- model
alias of
InProgressSubmission
- context_object_name = 'transfer'
- get_object(queryset=None) InProgressSubmission
Retrieve the InProgressSubmission object based on the UUID in the URL.
- get_context_data(**kwargs)
- post(request, *args, **kwargs)
- class recordtransfer.views.SubmissionDetail(**kwargs)
Generates a report for a given submission.
- model
alias of
Submission
- template_name = 'recordtransfer/submission_detail.html'
- context_object_name = 'submission'
- get_object(queryset=None) Submission
Retrieve the Submission object based on the UUID in the URL.
- test_func() bool
Check if the user is the creator of the submission group or is a staff member.
- handle_no_permission()
- get_context_data(**kwargs: Any) dict[str, Any]
Insert the single object into the context dict.
- class recordtransfer.views.SubmissionCsv(**kwargs)
Generates a CSV containing the submission and downloads that CSV.
- get_object()
- get_queryset()
- test_func()
- get(request, *args, **kwargs)
- class recordtransfer.views.SubmissionGroupDetailView(**kwargs)
Displays the associated submissions for a given submission group, and allows modification of submission group details.
- model
alias of
SubmissionGroup
- form_class
alias of
SubmissionGroupForm
- template_name = 'recordtransfer/submission_group_show_create.html'
- context_object_name = 'group'
- success_message = 'Group updated'
- error_message = 'There was an error updating the group'
- get_object()
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- test_func()
Check if the user is the creator of the submission group or is a staff member.
- handle_no_permission() HttpResponseForbidden
- get_context_data(**kwargs: Any) dict[str, Any]
Pass submissions associated with the group to the template.
- get_form_kwargs() dict[str, Any]
Pass User instance to form to initialize it.
- form_valid(form: BaseModelForm) HttpResponse
Handle valid form submission.
- form_invalid(form: BaseModelForm) HttpResponse
Handle invalid form submission.
- get_success_url() str
Redirect back to the same page after updating the group.
- class recordtransfer.views.SubmissionGroupCreateView(**kwargs)
Creates a new submission group.
- model
alias of
SubmissionGroup
- form_class
alias of
SubmissionGroupForm
- template_name = 'recordtransfer/submission_group_show_create.html'
- success_message = 'Group created'
- error_message = 'There was an error creating the group'
- test_func()
Check if the user is authenticated.
- handle_no_permission() HttpResponseForbidden
- get_context_data(**kwargs: Any) dict[str, Any]
Insert the form into the context dict.
- get_form_kwargs() dict[str, Any]
Pass User instance to form to initialize it.
- form_valid(form: BaseModelForm) HttpResponse
Handle valid form submission.
- form_invalid(form: BaseModelForm) HttpResponse
Handle invalid form submission.
- recordtransfer.views.get_user_submission_groups(request: HttpRequest, user_id: int) JsonResponse
Retrieve the groups associated with the current user.