Management Commands for the Record Transfer App

This module contains Django management commands for the Record Transfer Application.

reset

class recordtransfer.management.commands.reset.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Command to reset the database by removing and recreating the schema.

add_arguments(parser: CommandParser) None

Add arguments for the command.

handle(*args, **options) None

Handle the command.

setup_uploaded_files() bool

Copy the files specified in seed_data.json to the appropriate locations for both temporary and permanent uploaded files.

Returns: True if successful, False otherwise.

setup_uploaded_file(model: dict) None

Set up the uploaded file in the appropriate location based on the model type.

schedule_jobs

recordtransfer.management.commands.schedule_jobs.clear_scheduled_jobs() None

Delete any existing jobs in the scheduler when the app starts up.

recordtransfer.management.commands.schedule_jobs.register_scheduled_jobs() None

Register jobs to be run on a schedule.

class recordtransfer.management.commands.schedule_jobs.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Command to schedule jobs for the recordtransfer app.

handle(*args, **kwargs) None

Handle the command to schedule jobs.

send_test_email

class recordtransfer.management.commands.send_test_email.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Command to send a test email to a specified address using a given email ID.

add_arguments(parser: ArgumentParser) None

Add command-line arguments to the parser.

handle(*args, **options) None

Handle the command to send a test email.

Parameters:
  • *args – Variable length argument list.

  • **options – Arbitrary keyword arguments containing ‘to_email’ and ‘email_id’.

get_test_user(email: str, language: str | None = None) User

Retrieve or create a test user with the given email address.

Parameters:
  • email – The email address of the test user.

  • language – The language code for the test user.

Returns:

A User instance that has not been saved to the database.

Return type:

User

create_test_submission(user: User) Submission

Create and return a test Submission instance for the given user.

Parameters:

user (User) – The user for whom the submission is created.

Returns:

A Submission instance that has not been saved to the database.

Return type:

Submission

create_test_in_progress_submission(user: User) InProgressSubmission

Create and return a test InProgressSubmission instance for the given user.

send_email(email_id: str, user: User, form_data: dict, submission: Submission, in_progress: InProgressSubmission, language: str | None = None) None

Send a test email based on the provided email ID.

Parameters:
  • email_id (str) – The ID of the email to send (email function name).

  • user (User) – The user object to whom the email is related.

  • form_data (dict) – Form data to be passed to the email function.

  • submission (Submission) – A test submission instance.

  • in_progress (InProgressSubmission) – A test in-progress submission instance.

  • language – Optional language code to use for the email.

Raises:

CommandError – If no handler is implemented for the given email ID.

set_domain

class recordtransfer.management.commands.set_domain.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Set the domain of the current site.

add_arguments(parser: ArgumentParser) None

Add arguments to the command.

handle(*args, **options) None

Set the domain of the current site.

verify_settings

class recordtransfer.management.commands.verify_settings.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Verify application settings defined in the DJANGO_SETTINGS_MODULE.

handle(*args, **options) None

Verify application settings.

recordtransfer.management.commands.verify_settings.verify_clamav_settings() None

Verify clamav service settings.

  • CLAMAV_ENABLED

  • CLAMAV_HOST

  • CLAMAV_PORT

recordtransfer.management.commands.verify_settings.verify_date_format() None

Verify the setting.

  • APPROXIMATE_DATE_FORMAT

Raises:

ImproperlyConfigured – If the setting does not contain “{date}”.

recordtransfer.management.commands.verify_settings.verify_checksum_settings() None

Verify the setting.

  • BAG_CHECKSUMS

Raises:

ImproperlyConfigured – If the setting is empty or contains unsupported checksum algorithms.

recordtransfer.management.commands.verify_settings.verify_storage_folder_settings() None

Verify the settings.

  • UPLOAD_STORAGE_FOLDER

  • TEMP_STORAGE_FOLDER

Creates the directories if they do not exist.

Raises:
  • ImproperlyConfigured – If the directories could not be created, or if they already exist

  • exception if the directories could not be created, or if they already exist but as file.

recordtransfer.management.commands.verify_settings.verify_max_upload_size() None

Verify the settings.

  • MAX_TOTAL_UPLOAD_SIZE_MB

  • MAX_SINGLE_UPLOAD_SIZE_MB

  • MAX_TOTAL_UPLOAD_COUNT

Raises:
  • ImproperlyConfigured – If any are less than or equal to zero, or if the single upload size

  • is greater than the total upload size.

recordtransfer.management.commands.verify_settings.verify_accepted_file_formats() None

Verify the setting.

  • ACCEPTED_FILE_FORMATS

Raises:
  • ImproperlyConfigured exception if there are any issues with the formatting of the setting

  • or the file extensions in the setting.

recordtransfer.management.commands.verify_settings.verify_upload_session_settings() None

Verify the settings.

Raises:

ImproperlyConfigured – If the expiry schedule is not a valid cron string, or if the expiry settings are invalid.

recordtransfer.management.commands.verify_settings.verify_site_id() None

Verify that the SITE_ID setting is valid.

recordtransfer.management.commands.verify_settings.verify_axes_settings() None

Verify Axes settings.

recordtransfer.management.commands.verify_settings.verify_security_settings() None

Verify SECRET_KEY value is set.

recordtransfer.management.commands.verify_settings.verify_recaptcha_settings() None

Verify Recaptcha settings.

wait_for_db

class recordtransfer.management.commands.wait_for_db.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Wait for the database to become available.

add_arguments(parser: CommandParser) None

Add command line arguments for the command.

handle(*args, **options) None

Handle the command execution.