Utility Functions
This page provides essential utility functions for working with containers in RDMC.
Get Container ID
from rdmc.helpers.step_configs import GlobalVariables
container_id = GlobalVariables.get_or_create_container_id(request)
Get Container Details
from rdmc.helpers.step_configs import GlobalVariables
container_detail = GlobalVariables.get_container_detail(container_id)
Get Manifest Paths
Returns the path of the container’s manifest.rdmc file, or None when the container is not found.
from rdmc.helpers.step_configs import get_manifest_paths
manifest_path = get_manifest_paths(container_id)
Get Container View Context
from rdmc.helpers.common import get_container_view_context
container_more_detail = get_container_view_context(request)
Get Metadata
from rdmc_metadata.helpers.metadata_services import get_container_metadata
metadata = get_container_metadata(container_id=container_id)
Get Uploads
from rdmc.upload_helpers.container_uploads import ContainerUploadsHandler
target_files, target_links, target_folder = ContainerUploadsHandler.get_target_uploads(container_id)
Get Manifest Content
from rdmc_metadata.handlers.manifest_handler import view_manifest_content
manifest_content = view_manifest_content(container_id)
Get Missing Required Manifest Fields
Returns a dictionary of fields required by the database that are missing or empty in the manifest, in the form "Section.Subsection.field": "message".
import yaml
from rdmc.helpers.step_configs import get_manifest_paths
from rdmc.models import Question
from rdmc_metadata.handlers.manifest_handler import DatabaseService
from rdmc_metadata.helpers.manifest_validation_helper import ManifestValidationService
manifest_path = get_manifest_paths(container_id)
with open(manifest_path, encoding="utf-8") as manifest_file:
manifest_content = yaml.safe_load(manifest_file)
latest_version = DatabaseService.get_latest_version()
manifest_data_level = Question.objects.filter(version=latest_version)
missing_fields = ManifestValidationService.validate_manifest_content(manifest_content, manifest_data_level)
Get Active Project Version
from rdmc.models import ProjectVersion
version_number = ProjectVersion.get_active_version_number()
Get Container Listing Entry
Returns the container’s listing data (manifest path, share URLs, whether the files exist, status, sealed state, and allowed download formats).
from rdmc.helpers.index_helper import build_container_entry
from rdmc.helpers.step_configs import GlobalVariables
container = GlobalVariables.get_container_detail(container_id)
container_entry = build_container_entry(container)
Get Publication Info
Returns the container’s current publication record (None when never published), the human-readable platform name, and its status. Platform-specific details are available on the related objects zenodo_details, dataverse_details, coscine_details, and custom_details.
from rdmc.helpers.step_configs import GlobalVariables
from rdmc_publish.helpers.publication_policy import current_publication, platform_label
container = GlobalVariables.get_container_detail(container_id)
publication = current_publication(container)
if publication:
platform = platform_label(publication.publish_type) # e.g., "Zenodo"
status = publication.status
zenodo_url = publication.zenodo_details.zenodo_url if publication.publish_type == "zenodo" else None