recordtransfer.views - Views
Home
Views for the homepage and static pages navigable from the home page.
- class recordtransfer.views.home.Index(**kwargs)
The homepage.
- class recordtransfer.views.home.SystemErrorPage(**kwargs)
The page a user sees when there is some system error.
- class recordtransfer.views.home.About(**kwargs)
About the application.
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.
- form_class
alias of
SignUpForm
- dispatch(request: HttpRequest, *args, **kwargs) HttpResponse
If the user is already authenticated, redirect them to the homepage.
- form_valid(form) HttpResponse
Save the new user and send them an activation email.
- 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.
Profile
Views to manage user profile information and view their submission history.
- class recordtransfer.views.profile.UserProfile(**kwargs)
View to show two things: - The user’s profile information - A list of the Submissions a user has made.
- form_class
alias of
UserProfileForm
- 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.
Media
Views for handling media requests, such as uploading and deleting files. This also includes viewing and listing uploaded files.
- recordtransfer.views.media.media_request(request: HttpRequest, path: str) HttpResponse
Respond to whether a media request is allowed or not.
- recordtransfer.views.media.create_upload_session(request: HttpRequest) JsonResponse
Create a new upload session and return the session token.
- Parameters:
request – The POST request sent by the user.
- Returns:
The session token of the newly created upload session.
- Return type:
JsonResponse
- recordtransfer.views.media.upload_or_list_files(request: HttpRequest, session_token: str) JsonResponse
Upload a single file to the server list the files uploaded in a given upload session. The file is added to the upload session using the session token passed as a parameter in the request. If a session token is invalid, an error message is returned.
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 HTTP GET or POST request
session_token – The upload session token from the URL
- Returns:
If the list or upload operation was successful, the session token uploadSessionToken is included in the response. If not successful, the error description error is included.
- Return type:
JsonResponse
- recordtransfer.views.media.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
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.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.
- 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.
- 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, **kwargs) HttpResponse
Render next step of form. Overrides parent method to clear errors from the form.
- 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.
- 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.
- get_context_data(form, **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, **kwargs) HttpResponseRedirect
Retrieve all of the form data, and creates a Submission from it.
- Returns:
Redirects the user to their User Profile page.
- Return type:
HttpResponseRedirect
- class recordtransfer.views.pre_submission.DeleteInProgressSubmission(*args, **kwargs)
View to handle the deletion of an in-progress submission.
- model
alias of
InProgressSubmission
- get_queryset() QuerySet
Filter submissions to only show the current user’s.
- get_object(queryset: QuerySet | None = None) InProgressSubmission
Retrieve the InProgressSubmission object based on the UUID in the URL.
- get_context_data(**kwargs) dict[str, Any]
Retrieve context data for the template.
- delete(request: HttpRequest, *args, **kwargs) HttpResponse
Override delete to add success message, and handle any errors.
Post-Submission
Views for completed submissions, and creating and managing submission groups.
- class recordtransfer.views.post_submission.SubmissionDetail(**kwargs)
Generates a report for a given submission.
- model
alias of
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()
Override to return 404 instead of 403. This is to prevent users from knowing that the submission exists if they do not have permission to view it.
- get_context_data(**kwargs: Any) dict[str, Any]
Insert the single object into the context dict.
- class recordtransfer.views.post_submission.SubmissionCsv(**kwargs)
Generates a CSV containing the submission and downloads that CSV.
- class recordtransfer.views.post_submission.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
- 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()
Override to return 404 instead of 403. This is to prevent users from knowing that the group exists if they do not have permission to view it.
- get_context_data(**kwargs: Any) dict[str, Any]
Pass submissions associated with the group to the template.
- delete(request: HttpRequest, *args, **kwargs) HttpResponse
Handle DELETE request to delete the submission group.
- 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.post_submission.SubmissionGroupCreateView(**kwargs)
Creates a new submission group.
- model
alias of
SubmissionGroup
- form_class
alias of
SubmissionGroupForm
- test_func()
Check if the user is authenticated.
- 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.post_submission.get_user_submission_groups(request: HttpRequest, user_id: int) JsonResponse
Retrieve the groups associated with the current user.