Application enrichment

The enrichment application contains pages to collect other metadat to enrish the database.

Templates

The enrishment application contains 6 templates :

  • enrishment_dashboard.html : Dashboard representing the quantity of metadata submitted by the user to enrish the EMEGEN-DB metadata

  • task_monitoring.html : enrishment page to track the task that matched the EMERGEN-DB metadata with the one submitted by the user.

  • enrishment_doc.html : page conceived using EditorJs to allow the developper to write a documentation directly on the page.

  • import_enrishment_error.html : page called if the import is not succesfully loaded.

  • import_enrishment_sucecss.html : page called if the import is succesfully completed.

  • import_enrishment.html : the user interface to import the ebrishment metadata.

Key files of the « enrichment » application

admin.py

class apps.enrichment.admin.EnrichmentTableAdmin(model, admin_site)
has_add_permission(request)

The function has_add_permission always returns False.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the user. It contains information about the request, such as the method (GET, POST, etc.), headers, and any data sent with the request

Renvoie

False.

class apps.enrichment.admin.EnrichmentTableFieldAdmin(model, admin_site)
class apps.enrichment.admin.EnrichmentTableFileAdmin(model, admin_site)
has_add_permission(request)

The function has_add_permission always returns False.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the user. It contains information about the request, such as the method (GET, POST, etc.), headers, and any data sent with the request

Renvoie

False.

apps.enrichment.admin.delete_model_and_files_etf(modeladmin, request, queryset)

The function delete_model_and_files_etf deletes enrichment entries and associated files.

Paramètres
  • modeladmin – The model admin class that is calling this function. It provides access to various attributes and methods related to the admin interface

  • request – The request parameter is an object that represents the HTTP request made by the user. It contains information about the user’s request, such as the URL, headers, and any data sent with the request

  • queryset – The queryset parameter is a collection of objects that have been selected for deletion. It represents the set of objects that the user has chosen to delete

models.py

class apps.enrichment.models.EnrichmentTable(*args, **kwargs)

Enrichment table

exception DoesNotExist
exception MultipleObjectsReturned
clean()

Clean function to check some fields after database checks

class apps.enrichment.models.EnrichmentTableField(*args, **kwargs)

Enrichment field table

exception DoesNotExist
exception MultipleObjectsReturned
class apps.enrichment.models.EnrichmentTableFile(*args, **kwargs)

Enrichment table table

exception DoesNotExist
exception MultipleObjectsReturned

tests.py

class apps.enrichment.tests.enrichmentTestCase_data(methodName='runTest')

Test for enrichment with data

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

testEnrichment()

Test get enrichment page

view.py

apps.enrichment.views.download_enrichment_file(request, filename)

The function download_enrichment_file downloads an enrichment table file and returns a link to download it.

Paramètres
  • request – The request parameter is an object that represents the HTTP request made by the client. It contains information such as the request method, headers, and body

  • filename – The filename parameter is the name of the file that you want to download. It should include the file extension as well

Renvoie

an HttpResponse object.

apps.enrichment.views.enrichment_dashboard(request)

The function enrichment_dashboard renders the tasks monitoring page template for the enrichment module.

Paramètres

request – The request object represents the HTTP request that the user made to access the page. It contains information such as the user’s browser, IP address, and any data that was sent with the request

Renvoie

the rendered template “enrichment/enrichment_dashboard.html” with an empty context.

apps.enrichment.views.enrichment_documentation(request)

The function enrichment_documentation renders the tasks monitoring page template for the enrichment documentation.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the client. It contains information such as the request method, headers, and body. It is typically passed to view functions in Django to handle the request and generate a response. In this case, the request parameter is

Renvoie

a rendered HTML template called « enrichment/enrichment_doc.html » with the context variable « page » passed to it.

apps.enrichment.views.import_enrichment_page(request)

The function import_enrichment_page renders a page template for importing an enrichment table and handles the file upload and processing.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the client. It contains information such as the request method (GET, POST, etc.), the request headers, the request body, and other metadata related to the request. It is typically passed to view functions in Django to handle

Renvoie

a rendered HTML template. If the request method is POST and the “upload_file” key is present in the request.POST dictionary and the request.FILES dictionary is not empty, the function performs some operations and makes a request to an API endpoint. Depending on the response status code, the function renders different HTML templates. If the response status code is 202, the function renders the « en

apps.enrichment.views.task_monitoring_page(request, taskId)

The function task_monitoring_page renders a task monitoring page template and retrieves relevant data for the page.

Paramètres
  • request – The request parameter is an object that represents the HTTP request made by the user. It contains information such as the user’s session, the requested URL, and any data sent with the request

  • taskId – The taskId parameter is the unique identifier of a task. It is used to retrieve the corresponding TaskResult and EnrichmentTableFile objects from the database. These objects are then passed to the template for rendering the task monitoring page

Renvoie

a rendered HTML template with the task monitoring page. The template includes the task object, enrichment table file object, filename, and non-conformity list.