Admin Interface for RDMC

This section describes the customization and configuration of the admin interface for the RDMC project. The admin interface is a key part of the RDMC backend and allows administrators to manage models and upload content efficiently.

Admin Interface Models

The following models are configured for the Django admin interface in the RDMC project:

  1. User Admin Customization

    • The UserAdmin class is customized to include AccessLevel inline. This allows the admin to manage the AccessLevel model directly within the User model interface.

    • AccessLevelInline ensures that an AccessLevel instance is displayed and editable within the User form.

  2. Access Level Admin

    • AccessLevelAdmin allows the management of user access levels within the admin interface. The access level is linked to the User model.

  3. Upload Management

    • Models such as Upload, ResourceUpload, LinkUpload, and ResourceFolderUpload are configured to display essential information such as title, access type, container ID, and resource type in the admin interface.

  4. Questionnaire Management

    • QuestionnaireAdmin provides the functionality to manage questionnaires. It shows associated container ID, answers, and the questions linked to the questionnaire.

  5. Manifest Data & Configuration

    • The ManifestDataAdmin and ManifestConfigurationAdmin are used for managing manifest-related data, including schema versioning, context information, security layer data, and containerization information.

    • These models are highly useful for administrators to manage research artifacts and related manifest configurations.

  6. Custom Question Upload

    • CustomQuestionAdmin handles custom question uploads, including the ability to download questions as a YAML file.

    • Developers can upload questions in YAML format, and the system will validate the format against a predefined schema.

    • Questions are stored with version control, ensuring that only the latest version of each question is considered in the system.

Admin Model Customization

  • Search and Filtering:

    • Each model admin provides search functionality and list display options to facilitate quick access to relevant records.

    • Models such as ManifestDataAdmin, LinkUploadAdmin, and ResourceUploadAdmin include search_fields for filtering records by key attributes like container ID, title, or access type.

Important Developer Considerations

  1. Custom Validations for YAML Files:

    • When uploading YAML files for questions, it is essential that the file follows the required schema. The system uses JSON schema validation to ensure that the file is structured correctly.

    • Developers should ensure that the question_schema.json file is correctly maintained in the etc/manifest_question_template/ directory.

  2. Version Control for Questions:

    • Questions uploaded through the admin interface are versioned. Each question is associated with a version number, ensuring that the latest version of a question is used throughout the system.

  3. Custom Admin Templates:

    • The change_list_template attribute is used to specify custom admin templates. For example, CustomQuestionAdmin uses a custom template (admin/upload_questions.html) for rendering the question upload page.

  4. Extending the Admin Interface:

    • Developers can extend or modify the admin interface by overriding methods in the ModelAdmin classes. For instance, the changelist_view method in CustomQuestionAdmin handles custom logic for file uploads and validation.

    • Similarly, get_urls can be customized to add additional URLs to the admin interface.

Example of Custom ModelAdmin

class ResourceUploadAdmin(admin.ModelAdmin):
    list_display = ('upload', 'resource_upload_title', 'resource_upload_type', 'resource_upload_access', 'resource_upload_container_id')
    search_fields = ('resource_upload__title', 'resource_upload__type__name', 'resource_upload__access__name', 'resource_upload__container_id')

    @staticmethod
    def resource_upload_title(obj):
        return obj.resource_upload.title

    @staticmethod
    def resource_upload_type(obj):
        return obj.resource_upload.type

    @staticmethod
    def resource_upload_access(obj):
        return obj.resource_upload.access

    @staticmethod
    def resource_upload_container_id(obj):
        return obj.resource_upload.container_id