Admin Interface

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

Admin Interface Classes and Models

The following ModelAdmin classes and models are configured for the admin interface:

  1. User Admin Customization

    • The UserAdmin class is customized to include AccessLevel inline. This allows an administrator 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 manages user access levels within the admin interface, where each 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 the title, access type, container ID, and resource type in the admin interface.

  4. Questionnaire Management

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

  5. Manifest Data & Configuration

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

    • These admin classes are highly useful for administrators managing research artifacts and related manifest configurations.

  6. Custom Question Upload

    • CustomQuestionAdmin handles custom question uploads and allows administrators to download questions as a YAML file.

    • Administrators can upload questions in YAML format, and the system validates their structure against a predefined schema.

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

Admin Class Customization

  • Search and Filtering:

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

    • Admin classes 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 each 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 using a version number so that the system always uses the most recent version.

  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) to render 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 a 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