recordtransfer.views - Views
Home
Views for the homepage and static pages navigable from the home page.
- class recordtransfer.views.home.Index(**kwargs)
The homepage.
- template_name = 'recordtransfer/home.html'
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.
- 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.account.activate_account(request, uidb64, token)
- class recordtransfer.views.account.ActivationSent(**kwargs)
The page a user sees after creating an account.
- template_name = 'recordtransfer/activationsent.html'
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 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.
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
Transfer
Views for the transfer form and submission process, responsible for creating, saving, and deleting in-progress submissions, as well as handling the final submission of a transfer.
- class recordtransfer.views.transfer.TransferSent(**kwargs)
The page a user sees when they finish a transfer.
- template_name = 'recordtransfer/transfersent.html'
- class recordtransfer.views.transfer.InProgressSubmissionExpired(**kwargs)
The page a user sees when they try to access an expired submission.
- template_name = 'recordtransfer/in_progress_submission_expired.html'
- class recordtransfer.views.transfer.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.
- form_list: ClassVar[list[tuple]] = [('acceptlegal', <class 'recordtransfer.forms.transfer_forms.AcceptLegal'>), ('contactinfo', <class 'recordtransfer.forms.transfer_forms.ContactInfoForm'>), ('sourceinfo', <class 'recordtransfer.forms.transfer_forms.SourceInfoForm'>), ('recorddescription', <class 'recordtransfer.forms.transfer_forms.RecordDescriptionForm'>), ('rights', <class 'django.forms.formsets.RightsFormFormSet'>), ('otheridentifiers', <class 'django.forms.formsets.OtherIdentifiersFormFormSet'>), ('grouptransfer', <class 'recordtransfer.forms.transfer_forms.GroupTransferForm'>), ('uploadfiles', <class 'recordtransfer.forms.transfer_forms.UploadFilesForm'>), ('review', <class 'recordtransfer.forms.transfer_forms.ReviewForm'>)]
- 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.
- get(request: HttpRequest, *args, **kwargs) HttpResponse
Handle GET request to load a transfer.
- load_form_data() None
Load form data from an InProgressSubmission instance.
- post(request: HttpRequest, *args, **kwargs) HttpResponse
Handle POST request to save a transfer.
- 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: 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.
- 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() 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 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) 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.transfer.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)
Submission
Views for completed submissions, and creating and managing submission groups.
- class recordtransfer.views.submission.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()
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.submission.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.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
- 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()
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.
- 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.submission.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.submission.get_user_submission_groups(request: HttpRequest, user_id: int) JsonResponse
Retrieve the groups associated with the current user.