Coverage for backend/django/CoreRoot/urls.py: 93%

40 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-03-26 20:57 +0000

1""" 

2URL configuration for CoreRoot project. 

3 

4The `urlpatterns` list routes URLs to views. For more information please see: 

5 https://docs.djangoproject.com/en/4.2/topics/http/urls/ 

6Examples: 

7Function views 

8 1. Add an import: from my_app import views 

9 2. Add a URL to urlpatterns: path('', views.home, name='home') 

10Class-based views 

11 1. Add an import: from other_app.views import Home 

12 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 

13Including another URLconf 

14 1. Import the include() function: from django.urls import include, path 

15 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 

16""" 

17from PinchAnalysis.views.PinchAnalysisView import pinch_analysis_view 

18from core.auxiliary.views.CompoundSuggestionViews import get_suggestions 

19from core.auxiliary.views.HealthChecks import get_api_status, check_db_connectivity 

20from core.auxiliary.viewsets.MLViewSet import process_ml_training_event 

21from core.auxiliary.views.SolveView import cancel_idaes_solve_handler, solve_idaes, process_idaes_solve_completion_event, \ 

22 process_failed_idaes_solve_event, cancel_idaes_solve, process_dispatch_multi_solve 

23from core.auxiliary.views.UploadMSSData import upload_data 

24from core.auxiliary.views.DownloadMSSData import download_data, download_mss_results 

25from core.auxiliary.views.DeleteMSSData import delete_data 

26from core.auxiliary.views.ExtractSegmentDataFromFS import extract_stream_data 

27from core.auxiliary.views.LiveSolarData import get_solar_data 

28from core.auxiliary.views.CopyFlowsheetView import copy_flowsheet 

29 

30from core.auxiliary.views.GenerateIDAESPython import generate_idaes_python 

31from core.plots.plot_router import router as plot_router 

32from core.validation import validate_urlpatterns, validate_models, validate_routers 

33from diagnostics import views as diagnostics_views 

34# TEMPORARY -> Will instead be called by a general "Pinch Analysis" view instead 

35 

36import core.routers 

37from django.contrib import admin 

38from django.urls import path, include 

39from django.contrib.staticfiles.urls import staticfiles_urlpatterns 

40from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView 

41 

42import authentication.routers 

43import flowsheetInternals.unitops.routers 

44import flowsheetInternals.graphicData.routers 

45import flowsheetInternals.propertyPackages.routers 

46import PinchAnalysis.routers 

47from CoreRoot.settings import DEBUG, PROFILING_ENABLED 

48from notifications.views.broadcast_view import broadcast_message_to_user 

49unvalidated_urlpatterns = [ 

50 path('api/authentication/', include(authentication.routers.urlpatterns)), 

51] 

52 

53# VIEWSETS ROUTERS ONLY!!! already validated at router level 

54viewset_urlpatterns = [ 

55 path("api/graphics", include(flowsheetInternals.graphicData.routers.router.urls)), 

56 path("api/unitops/", include(flowsheetInternals.unitops.routers.router.urls)), 

57 path('api/core/', include(core.routers.router.urls)), 

58 path('api/property_packages/', include(flowsheetInternals.propertyPackages.routers.router.urls)), 

59 path("api/pinch/", include(PinchAnalysis.routers.router.urls)), 

60 path('api/core/plots/',include(plot_router.urls),name='plots'), 

61] 

62 

63# API_VIEWS_ONLY!!! 

64api_views_url_patterns = [ 

65 # Custom API urls for compound/flowsheet manipulation 

66 path('api/idaes/solve/', solve_idaes, name='solve_idaes'), 

67 path('api/idaes/generate-python-code/', generate_idaes_python, name='generate_python_code'), 

68 path('api/idaes/cancel-solve/', cancel_idaes_solve_handler, name='cancel_idaes_solve'), 

69 path('api/mss/upload', upload_data, name='upload_mss_data'), 

70 path('api/mss/delete', delete_data, name='delete_mss_data'), 

71 path('api/mss/download', download_data, name='download_mss_data'), 

72 path('api/mss/download_results', download_mss_results, name='download_mss_results'), 

73 path('api/flowsheet/copy', copy_flowsheet, name='copy_flowsheet'), 

74 

75 # TEMPORARY 

76 path("api/pinch/calculate", pinch_analysis_view, name="pinch_analysis"), 

77 path("api/pinch/extract/", extract_stream_data, name="extract_stream_data"), 

78 #Compound API  

79 path("api/compoundsuggestions/", get_suggestions, name="compound_suggestions"), 

80 

81 # Live Solar 

82 path("api/solar/", get_solar_data, name="get_solar_data"), 

83 

84 # Diagnostics 

85 path("api/diagnostics/rules/properties/<int:simulation_object_id>", diagnostics_views.evaluate_object_property_rules, name="diagnostics_evaluate_object_property_rules"), 

86 path("api/diagnostics/rules/flowsheet/<int:flowsheet_id>", diagnostics_views.evaluate_flowsheet_property_rules, name="diagnostics_evaluate_flowsheet_property_rules"), 

87 

88] 

89 

90internal_urlpatterns = [ 

91# Health Check/s 

92 path("api/status/", get_api_status, name="get_status"), 

93 path("api/connectivity/", check_db_connectivity, name="get_db_connectivity"), 

94 path("api/idaes/process-solve-completion/", process_idaes_solve_completion_event, name='process_idaes_solve_response'), 

95 path("api/idaes/process-solve-failure/", process_failed_idaes_solve_event, name='process_idaes_solve_failure'), 

96 path("api/idaes/process-ml-training-completion/", process_ml_training_event, name='process_ml_training_event'), 

97 path("api/idaes/dispatch-multi-solve/", process_dispatch_multi_solve, name='process_dispatch_multi_solve'), 

98 path("api/notifications/broadcast/", broadcast_message_to_user, name="broadcast_message_to_user"), 

99] 

100 

101# Validate all api_views, viewsets and models for access control. 

102validate_urlpatterns(api_views_url_patterns) 

103validate_models() 

104validate_routers() 

105 

106urlpatterns = ( 

107 unvalidated_urlpatterns + 

108 viewset_urlpatterns + 

109 api_views_url_patterns + 

110 internal_urlpatterns 

111) 

112 

113if DEBUG: 113 ↛ exitline 113 didn't exit the module because the condition on line 113 was always true

114 # use these endpoints to view the api schema in a web browser 

115 # Openapi schema definitions - generated by drf-spectacular 

116 urlpatterns += [ 

117 path("api/schema/", SpectacularAPIView.as_view(), name="schema"), 

118 path( 

119 "api/schema/swagger-ui/", 

120 SpectacularSwaggerView.as_view(url_name="schema"), 

121 name="swagger-ui", 

122 ), 

123 path( 

124 "api/schema/redoc/", 

125 SpectacularRedocView.as_view(url_name="schema"), 

126 name="redoc", 

127 ) 

128 ] 

129 urlpatterns += staticfiles_urlpatterns() 

130 

131 if PROFILING_ENABLED: 131 ↛ 132line 131 didn't jump to line 132 because the condition on line 131 was never true

132 urlpatterns += [path('silk/', include('silk.urls', namespace='silk'))]