From aacdd815aa5d9d3badf92b9aa89f8e858c6ed475 Mon Sep 17 00:00:00 2001 From: Shettland Date: Tue, 23 Jul 2024 09:05:21 +0200 Subject: [PATCH] Refactor relecov_documentation --- relecov_dashboard/utils/met_sequencing.py | 6 +- relecov_documentation/apps.py | 1 + relecov_documentation/urls.py | 47 ++++----- .../{markdown_handling.py => markdown.py} | 0 relecov_documentation/views.py | 99 +++++++++---------- 5 files changed, 77 insertions(+), 76 deletions(-) rename relecov_documentation/utils/{markdown_handling.py => markdown.py} (100%) diff --git a/relecov_dashboard/utils/met_sequencing.py b/relecov_dashboard/utils/met_sequencing.py index d12800b1..cc38b02b 100644 --- a/relecov_dashboard/utils/met_sequencing.py +++ b/relecov_dashboard/utils/met_sequencing.py @@ -1,11 +1,9 @@ # Generic imports from statistics import mean - import pandas as pd # Local imports -import relecov_core.utils.rest_api_handling -import relecov_core.utils.schema_handling +import relecov_core.utils.rest_api import relecov_dashboard.utils.generic_graphic_data import relecov_dashboard.utils.plotly import relecov_dashboard.utils.generic_process_data @@ -60,7 +58,7 @@ def get_pre_proc_data(graphic_name, out_format): def fetch_sequencing_data(project_field, columns): # get stats utilization fields from LIMS - lims_data = relecov_core.utils.rest_api_handling.get_stats_data( + lims_data = relecov_core.utils.rest_api.get_stats_data( { "sample_project_name": "Relecov", "project_field": project_field, diff --git a/relecov_documentation/apps.py b/relecov_documentation/apps.py index a5a1d59f..c5ba2624 100644 --- a/relecov_documentation/apps.py +++ b/relecov_documentation/apps.py @@ -1,3 +1,4 @@ +# Generic imports from django.apps import AppConfig diff --git a/relecov_documentation/urls.py b/relecov_documentation/urls.py index c93ae44e..0f4509d8 100644 --- a/relecov_documentation/urls.py +++ b/relecov_documentation/urls.py @@ -1,52 +1,55 @@ +# Generic imports from django.urls import path from django.conf import settings -from relecov_documentation import views from django.conf.urls.static import static +# Local imports +import relecov_documentation + urlpatterns = [ - path("", views.index, name="index"), - path("description", views.description, name="description"), - path("relecovInstall/", views.relecov_install, name="relecov_install"), - path("configuration/", views.configuration, name="configuration"), - path("metadata/", views.metadata, name="metadata"), - path("metadataLabExcel/", views.metadata_lab_excel, name="metadata_lab_excel"), - path("relecovTools/", views.relecov_tools, name="relecov_tools"), - path("intranetOverview/", views.intranet_overview, name="intranet_overview"), + path("", relecov_documentation.views.index, name="index"), + path("description", relecov_documentation.views.description, name="description"), + path("relecovInstall/", relecov_documentation.views.relecov_install, name="relecov_install"), + path("configuration/", relecov_documentation.views.configuration, name="configuration"), + path("metadata/", relecov_documentation.views.metadata, name="metadata"), + path("metadataLabExcel/", relecov_documentation.views.metadata_lab_excel, name="metadata_lab_excel"), + path("relecovTools/", relecov_documentation.views.relecov_tools, name="relecov_tools"), + path("intranetOverview/", relecov_documentation.views.intranet_overview, name="intranet_overview"), path( "intranetContactData/", - views.intranet_contact_data, + relecov_documentation.views.intranet_contact_data, name="intranet_contact_data", ), path( "intranetSampleSearch/", - views.intranet_sample_search, + relecov_documentation.views.intranet_sample_search, name="intranet_sample_search", ), path( "intranetReceivedSamples/", - views.intranet_received_samples, + relecov_documentation.views.intranet_received_samples, name="intranet_received_samples", ), path( "intranetUploadMetadata/", - views.intranet_upload_metadata, + relecov_documentation.views.intranet_upload_metadata, name="intranet_upload_metadata", ), - path("variantDashboard/", views.variant_dashboard, name="variant_dashboard"), + path("variantDashboard/", relecov_documentation.views.variant_dashboard, name="variant_dashboard"), path( "methodologyDashboard/", - views.methodology_dashboard, + relecov_documentation.views.methodology_dashboard, name="methodology_dashboard", ), - path("nextstrainInstall/", views.nextstrain_install, name="nextstrain_install"), - path("howtoNextstrain/", views.howto_nextstrain, name="howto_nextstrain"), - path("uploadToEna/", views.upload_to_ena, name="upload_to_ena"), - path("uploadToGisaid/", views.upload_to_gisaid, name="upload_to_gisaid"), - path("apiSchema/", views.api_schema, name="api_schema"), - path("howtoApi/", views.howto_api, name="howto_api"), + path("nextstrainInstall/", relecov_documentation.views.nextstrain_install, name="nextstrain_install"), + path("howtoNextstrain/", relecov_documentation.views.howto_nextstrain, name="howto_nextstrain"), + path("uploadToEna/", relecov_documentation.views.upload_to_ena, name="upload_to_ena"), + path("uploadToGisaid/", relecov_documentation.views.upload_to_gisaid, name="upload_to_gisaid"), + path("apiSchema/", relecov_documentation.views.api_schema, name="api_schema"), + path("howtoApi/", relecov_documentation.views.howto_api, name="howto_api"), path( "createNewUser/", - views.create_new_user, + relecov_documentation.views.create_new_user, name="create_new_user", ), ] diff --git a/relecov_documentation/utils/markdown_handling.py b/relecov_documentation/utils/markdown.py similarity index 100% rename from relecov_documentation/utils/markdown_handling.py rename to relecov_documentation/utils/markdown.py diff --git a/relecov_documentation/views.py b/relecov_documentation/views.py index 0b070ce6..2ac9596b 100644 --- a/relecov_documentation/views.py +++ b/relecov_documentation/views.py @@ -1,18 +1,17 @@ +# Generic imports from django.shortcuts import render from django.contrib.auth.decorators import login_required -from relecov_documentation.utils.markdown_handling import ( - markdown_to_html, - fix_img_folder, -) +# Local imports +import relecov_documentation.utils.markdown @login_required def index(request): - converted_to_html = markdown_to_html("index.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("index.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -22,10 +21,10 @@ def index(request): @login_required def description(request): - converted_to_html = markdown_to_html("description.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("description.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -35,10 +34,10 @@ def description(request): @login_required def relecov_install(request): - converted_to_html = markdown_to_html("relecov_install.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("relecov_install.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -48,10 +47,10 @@ def relecov_install(request): @login_required def configuration(request): - converted_to_html = markdown_to_html("configuration.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("configuration.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -61,10 +60,10 @@ def configuration(request): @login_required def metadata(request): - converted_to_html = markdown_to_html("metadata.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("metadata.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -74,10 +73,10 @@ def metadata(request): @login_required def metadata_lab_excel(request): - converted_to_html = markdown_to_html("metadata_lab_excel.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("metadata_lab_excel.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -87,10 +86,10 @@ def metadata_lab_excel(request): @login_required def relecov_tools(request): - converted_to_html = markdown_to_html("relecov_tools.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("relecov_tools.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -100,10 +99,10 @@ def relecov_tools(request): @login_required def intranet_overview(request): - converted_to_html = markdown_to_html("intranet_overview.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("intranet_overview.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -113,10 +112,10 @@ def intranet_overview(request): @login_required def intranet_contact_data(request): - converted_to_html = markdown_to_html("intranet_contact_data.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("intranet_contact_data.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -126,10 +125,10 @@ def intranet_contact_data(request): @login_required def intranet_sample_search(request): - converted_to_html = markdown_to_html("intranet_sample_search.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("intranet_sample_search.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -139,10 +138,10 @@ def intranet_sample_search(request): @login_required def intranet_received_samples(request): - converted_to_html = markdown_to_html("intranet_received_samples.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("intranet_received_samples.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -152,10 +151,10 @@ def intranet_received_samples(request): @login_required def intranet_upload_metadata(request): - converted_to_html = markdown_to_html("intranet_upload_metadata.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("intranet_upload_metadata.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -165,10 +164,10 @@ def intranet_upload_metadata(request): @login_required def variant_dashboard(request): - converted_to_html = markdown_to_html("variant_dashboard.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("variant_dashboard.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -178,10 +177,10 @@ def variant_dashboard(request): @login_required def methodology_dashboard(request): - converted_to_html = markdown_to_html("methodology_dashboard.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("methodology_dashboard.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -191,10 +190,10 @@ def methodology_dashboard(request): @login_required def nextstrain_install(request): - converted_to_html = markdown_to_html("nextstrain_install.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("nextstrain_install.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -204,10 +203,10 @@ def nextstrain_install(request): @login_required def howto_nextstrain(request): - converted_to_html = markdown_to_html("howto_nextstrain.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("howto_nextstrain.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -217,10 +216,10 @@ def howto_nextstrain(request): @login_required def upload_to_ena(request): - converted_to_html = markdown_to_html("upload_to_ena.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("upload_to_ena.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -230,10 +229,10 @@ def upload_to_ena(request): @login_required def upload_to_gisaid(request): - converted_to_html = markdown_to_html("upload_to_gisaid.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("upload_to_gisaid.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -243,10 +242,10 @@ def upload_to_gisaid(request): @login_required def create_new_user_account(request): - converted_to_html = markdown_to_html("createNewUserAccount.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("createNewUserAccount.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -256,10 +255,10 @@ def create_new_user_account(request): @login_required def upload_metadata(request): - converted_to_html = markdown_to_html("uploadMetadata.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("uploadMetadata.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -269,10 +268,10 @@ def upload_metadata(request): @login_required def api_schema(request): - converted_to_html = markdown_to_html("api_schema.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("api_schema.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -282,10 +281,10 @@ def api_schema(request): @login_required def howto_api(request): - converted_to_html = markdown_to_html("howto_api.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("howto_api.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html", @@ -295,10 +294,10 @@ def howto_api(request): @login_required def create_new_user(request): - converted_to_html = markdown_to_html("createNewUserAccount.md") + converted_to_html = relecov_documentation.utils.markdown.markdown_to_html("createNewUserAccount.md") if isinstance(converted_to_html, dict): return render(request, "relecov_documentation/error_404.html") - converted_to_html = fix_img_folder(converted_to_html) + converted_to_html = relecov_documentation.utils.markdown.fix_img_folder(converted_to_html) return render( request, "relecov_documentation/base.html",