recordtransfer.views - Views
Home
Views for the homepage and static pages navigable from the home page.
- class recordtransfer.views.home.Index(**kwargs)
The homepage.
Account
Views for creating and activating user accounts.
- class recordtransfer.views.account.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.
- get_form_class() type[BaseModelForm]
Return the appropriate form class based on environment.
- dispatch(request: HttpRequest, *args, **kwargs) HttpResponse
Redirect authenticated users to homepage.
- form_valid(form: BaseModelForm) HttpResponse
Save the new user and send them an activation email.
- form_invalid(form: BaseModelForm) HttpResponse
Handle invalid signup form submissions.
- class recordtransfer.views.account.ActivateAccount(**kwargs)
View for activating user accounts via email link.
- get(request: HttpRequest, uidb64: str, token: str) HttpResponse
Handle GET request for account activation.
- class recordtransfer.views.account.ActivationSent(**kwargs)
The page a user sees after creating an account.
- class recordtransfer.views.account.ActivationComplete(**kwargs)
The page a user sees when their account has been activated.
- class recordtransfer.views.account.ActivationInvalid(**kwargs)
The page a user sees if their account could not be activated.
- class recordtransfer.views.account.Login(**kwargs)
Custom LoginView that supports HTMX requests for login forms.
- form_valid(form: AuthenticationForm) HttpResponse
Handle successful login.
- form_invalid(form: AuthenticationForm) HttpResponse
Handle invalid login form submissions.
- recordtransfer.views.account.log_user_logout(sender: User, request: HttpRequest, user: User, **kwargs) None
Log when a user logs out.
- recordtransfer.views.account.lockout(request: HttpRequest, credentials: dict, *args, **kwargs) HttpResponse
Handle lockout due to too many failed login attempts.
- class recordtransfer.views.account.AsyncPasswordChangeView(**kwargs)
The page a user sees when they change their password.
Overrides PasswordChangeView to send an email notification asynchronously after successful password change.
- form_valid(form: PasswordChangeForm) HttpResponse
Handle successful password change.
- class recordtransfer.views.account.AsyncPasswordResetView(**kwargs)
The page a user sees when they request a password reset.
Overrides PasswordResetView to send an email notification asynchronously to the user after requesting a password reset.
- form_class
alias of
AsyncPasswordResetForm
- form_valid(form: AsyncPasswordResetForm) HttpResponse
Handle successful password reset request.
- class recordtransfer.views.account.AsyncPasswordResetConfirmView(**kwargs)
The page a user sees when they are setting a new password after a password reset.
Overrides PasswordResetConfirmView to send an email notification asynchronously after successful password reset.
- form_valid(form: SetPasswordForm) HttpResponse
Handle successful password reset confirmation.
Profile
Views to manage user profile information and view their submission history.
- class recordtransfer.views.profile.UserProfile(**kwargs)
Main profile page - handles GET requests only.
- get(request: HttpRequest) HttpResponse
Render the user profile page.
- class recordtransfer.views.profile.BaseUserProfileUpdateView(**kwargs)
Base view for updating user profile information.
- model
alias of
User
- dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse
Ensure requests are made with HTMX.
- get_object(queryset: QuerySet | None = None) User
Get the user object for the current request.
- form_valid(form: BaseModelForm) HttpResponse
Handle valid form submission, return updated form and trigger success event in response.
- form_invalid(form: BaseModelForm) HttpResponse
Handle invalid form submission.
- class recordtransfer.views.profile.AccountInfoUpdateView(**kwargs)
View to update user account information such as name and notification preferences.
- form_class
alias of
UserAccountInfoForm
- class recordtransfer.views.profile.ContactInfoUpdateView(**kwargs)
View to update user contact information such as email and phone number.
- form_class
alias of
UserContactInfoForm
- recordtransfer.views.profile.delete_in_progress_submission(request: HttpRequest, uuid: str) HttpResponse
Handle GET (show modal) and DELETE (delete submission) for in-progress submissions. Both requests must be made by HTMX, or else a 400 Error is returned.
- recordtransfer.views.profile.submission_group_table(request: HttpRequest) HttpResponse
Render the submission group table with pagination and sorting.
- recordtransfer.views.profile.in_progress_submission_table(request: HttpRequest) HttpResponse
Render the in-progress submission table with pagination.
- recordtransfer.views.profile.submission_table(request: HttpRequest) HttpResponse
Render the past submission table with pagination and sorting, optionally filtered by group.
- class recordtransfer.views.profile.SubmissionGroupModalCreateView(**kwargs)
Renders a modal form to create a new submission group. Handles GET requests to show the modal and POST requests to create the submission group. Both requests must be made by HTMX.
- model
alias of
SubmissionGroup
- form_class
alias of
SubmissionGroupForm
- dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse
Ensure requests are made with HTMX.
- get_form_kwargs() dict[str, Any]
Pass User instance to form to initialize it.
- form_valid(form: BaseModelForm) HttpResponse
Handle valid form submission.
- recordtransfer.views.profile.delete_submission_group(request: HttpRequest, uuid: str) HttpResponse
Handle GET (show delete confirmation modal) and DELETE (delete submission group). Both requests must be made by HTMX.
- recordtransfer.views.profile.assign_submission_group_modal(request: HttpRequest, uuid: str) HttpResponse
Display a modal that shows the submission group currently assigned to a submission and all available submission groups which the submission can be assigned to.
- Parameters:
request (HttpRequest) – The HTTP request object.
uuid (str) – The UUID of the submission.
- recordtransfer.views.profile.assign_submission_group(request: HttpRequest) HttpResponse
Assign a submission to a submission group or unassign it.
Media
Views for handling downloading media.
- recordtransfer.views.media.job_file(request: HttpRequest, job_uuid: str) HttpResponse
View to access the attached file associated with a job.
- Parameters:
request – The HTTP request
job_uuid – The UUID of the job
- Returns:
Redirects to the file’s media path if the job has an associated file.
- Return type:
HttpResponse
Pre-Submission
Views for the submission form and submission process, responsible for creating, saving, and deleting in-progress submissions, as well as handling the final submission.
- class recordtransfer.views.pre_submission.SubmissionSent(**kwargs)
The page a user sees when they finish a submission.
- class recordtransfer.views.pre_submission.InProgressSubmissionExpired(**kwargs)
The page a user sees when they try to access an expired submission.
- class recordtransfer.views.pre_submission.OpenSessions(**kwargs)
Show the user their current upload sessions.
- get_context_data(**kwargs) dict[str, Any]
Add context required by template and Javascript.
- recordtransfer.views.pre_submission.open_session_table(request: HttpRequest) HttpResponse
Render the open session table with pagination and sorting.
- class recordtransfer.views.pre_submission.SubmissionFormWizard(*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.
- class SubmissionStepMeta(template: str, title: str, form: type[SubmissionForm | BaseFormSet], info_message: str | None = None)
Metadata for each submission step, including the template to render, title, form class, and an optional info message to display on the page.
- property current_step: SubmissionStep
Returns the current step as a SubmissionStep enum value.
- dispatch(request: HttpRequest, *args, **kwargs) HttpResponse
Dispatch the request to the appropriate handler method.
- get(request: HttpRequest, *args, **kwargs) HttpResponse
Handle GET request to load a submission.
- load_form_data() None
Load form data from an InProgressSubmission instance.
- post(request: HttpRequest, *args, **kwargs) HttpResponse
Handle POST request to save a submission.
If the session limit is reached, save the current submission, and re-direct to the session limit page.
- save_form_data(request: HttpRequest) None
Save the current state of the form to the database.
- Parameters:
request – The HTTP request object.
- 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: BaseForm | BaseFormSet, **kwargs) HttpResponse
Render next step of form. Overrides parent method to clear errors from the form.
- trigger_contact_info_save_prompt(form: ContactInfoForm) HttpResponse
Trigger a prompt to save contact info using HTMX.
- classmethod format_step_data(step: SubmissionStep, 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.
- get_form_value(step: SubmissionStep, 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() list[str]
Override the parent method to return the template name to render 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 in-progress submission 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.
- get_upload_handle() str | None
Get a handle to enable uploading files.
The front-end should send the X-Upload-Handle header to this handle to be able to upload files.
- 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 submission as well.
- property form_started: bool
Check if the user has started the form. This is true if there is an in-progress submission, or if the user has submitted any data for the form.
- get_context_data(form: BaseForm | BaseFormSet, **kwargs) dict[str, Any]
Retrieve context data for the current form template, including context for the JavaScript files used alongside the template.
- Parameters:
form – The form to display to the user.
**kwargs – Additional keyword arguments.
- Returns:
A dictionary of context data to be used to render the form template.
- Return type:
dict
- done(form_list: list[BaseForm], **kwargs) HttpResponse
Retrieve all of the form data, and creates a Submission from it.
- Parameters:
form_list – A list of all the forms in the form wizard.
**kwargs – Additional keyword arguments.
- Returns:
A redirect to the submission sent page, or an error page if there was an unexpected issue creating the submission.
- Return type:
HttpResponse
Post-Submission
Views for completed submissions, and creating and managing submission groups.
- class recordtransfer.views.post_submission.SubmissionDetailView(**kwargs)
Generates a report for a given submission.
- model
alias of
Submission
- get_object(queryset: QuerySet | None = None) Submission
Retrieve the Submission object based on the UUID in the URL.
- get_queryset() QuerySet
Return queryset filtered by user permissions.
- get_context_data(**kwargs: Any) dict[str, Any]
Pass context variables to the template.
- recordtransfer.views.post_submission.submission_csv_export(request: HttpRequest, uuid: str) HttpResponse
Generate and download a CSV for a specific submission.
- recordtransfer.views.post_submission.submission_group_bulk_csv_export(request: HttpRequest, uuid: str) HttpResponse
Generate and download a CSV for all submissions in a submission group.
- class recordtransfer.views.post_submission.SubmissionGroupDetailView(**kwargs: Any)
Handles updating and viewing details of a submission group.
- model
alias of
SubmissionGroup
- form_class
alias of
SubmissionGroupForm
- get_object(queryset: QuerySet | None = None) SubmissionGroup
Return the SubmissionGroup for the given UUID, only if owned by the user. Raises 404 if not found or not owned.
- get_queryset() QuerySet
Restrict queryset to groups created by the current user.
- 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.
- recordtransfer.views.post_submission.get_user_submission_groups(request: HttpRequest) JsonResponse
Return a JSON response containing all submission groups created by the specified user.