From 2158d24af88405cd2df21d79b47c036af9b9665e Mon Sep 17 00:00:00 2001 From: Ryan R Rogers Date: Tue, 14 Nov 2023 09:08:39 -0500 Subject: [PATCH] seperate matters of concern --- .../views/listMeds/urls.py => api/__init__.py} | 0 server/api/admin.py | 3 +++ server/api/apps.py | 6 ++++++ .../listMeds/views.py => api/migrations/__init__.py} | 0 server/api/models.py | 3 +++ server/api/tests.py | 3 +++ server/{balancer_backend => api}/views/chatgpt/urls.py | 2 +- .../{balancer_backend => api}/views/chatgpt/views.py | 0 server/{balancer_backend => api}/views/jira/urls.py | 2 +- server/{balancer_backend => api}/views/jira/views.py | 0 .../{balancer_backend => api}/views/listDrugs/urls.py | 2 +- .../{balancer_backend => api}/views/listDrugs/views.py | 0 server/api/views/listMeds/urls.py | 0 server/api/views/listMeds/views.py | 0 server/{balancer_backend => api}/views/risk/urls.py | 2 +- server/{balancer_backend => api}/views/risk/views.py | 0 server/balancer_backend/settings.py | 3 ++- server/balancer_backend/urls.py | 10 ++++++---- .../urls/auth_urls.py => user_management/urls.py} | 0 server/user_management/views.py | 2 +- 20 files changed, 28 insertions(+), 10 deletions(-) rename server/{balancer_backend/views/listMeds/urls.py => api/__init__.py} (100%) create mode 100644 server/api/admin.py create mode 100644 server/api/apps.py rename server/{balancer_backend/views/listMeds/views.py => api/migrations/__init__.py} (100%) create mode 100644 server/api/models.py create mode 100644 server/api/tests.py rename server/{balancer_backend => api}/views/chatgpt/urls.py (83%) rename server/{balancer_backend => api}/views/chatgpt/views.py (100%) rename server/{balancer_backend => api}/views/jira/urls.py (89%) rename server/{balancer_backend => api}/views/jira/views.py (100%) rename server/{balancer_backend => api}/views/listDrugs/urls.py (69%) rename server/{balancer_backend => api}/views/listDrugs/views.py (100%) create mode 100644 server/api/views/listMeds/urls.py create mode 100644 server/api/views/listMeds/views.py rename server/{balancer_backend => api}/views/risk/urls.py (69%) rename server/{balancer_backend => api}/views/risk/views.py (100%) rename server/{balancer_backend/urls/auth_urls.py => user_management/urls.py} (100%) diff --git a/server/balancer_backend/views/listMeds/urls.py b/server/api/__init__.py similarity index 100% rename from server/balancer_backend/views/listMeds/urls.py rename to server/api/__init__.py diff --git a/server/api/admin.py b/server/api/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/server/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/server/api/apps.py b/server/api/apps.py new file mode 100644 index 00000000..66656fd2 --- /dev/null +++ b/server/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'api' diff --git a/server/balancer_backend/views/listMeds/views.py b/server/api/migrations/__init__.py similarity index 100% rename from server/balancer_backend/views/listMeds/views.py rename to server/api/migrations/__init__.py diff --git a/server/api/models.py b/server/api/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/server/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/server/api/tests.py b/server/api/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/server/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/server/balancer_backend/views/chatgpt/urls.py b/server/api/views/chatgpt/urls.py similarity index 83% rename from server/balancer_backend/views/chatgpt/urls.py rename to server/api/views/chatgpt/urls.py index 6a2d2e4c..8aba0c7b 100644 --- a/server/balancer_backend/views/chatgpt/urls.py +++ b/server/api/views/chatgpt/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from balancer_backend.views.chatgpt import views +from api.views.chatgpt import views urlpatterns = [ path("chatgpt/extract_text/", views.extract_text, name="post_web_text"), diff --git a/server/balancer_backend/views/chatgpt/views.py b/server/api/views/chatgpt/views.py similarity index 100% rename from server/balancer_backend/views/chatgpt/views.py rename to server/api/views/chatgpt/views.py diff --git a/server/balancer_backend/views/jira/urls.py b/server/api/views/jira/urls.py similarity index 89% rename from server/balancer_backend/views/jira/urls.py rename to server/api/views/jira/urls.py index cbb49de7..068b50e2 100644 --- a/server/balancer_backend/views/jira/urls.py +++ b/server/api/views/jira/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from balancer_backend.views.jira import views +from api.views.jira import views urlpatterns = [ path("jira/create_new_feedback/", views.create_new_feedback, name="create_new_feedback"), diff --git a/server/balancer_backend/views/jira/views.py b/server/api/views/jira/views.py similarity index 100% rename from server/balancer_backend/views/jira/views.py rename to server/api/views/jira/views.py diff --git a/server/balancer_backend/views/listDrugs/urls.py b/server/api/views/listDrugs/urls.py similarity index 69% rename from server/balancer_backend/views/listDrugs/urls.py rename to server/api/views/listDrugs/urls.py index 7f29aab8..593c276b 100644 --- a/server/balancer_backend/views/listDrugs/urls.py +++ b/server/api/views/listDrugs/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from balancer_backend.views.listDrugs import views +from api.views.listDrugs import views urlpatterns = [ path("chatgpt/list_drugs", views.medication, name="listDrugs") diff --git a/server/balancer_backend/views/listDrugs/views.py b/server/api/views/listDrugs/views.py similarity index 100% rename from server/balancer_backend/views/listDrugs/views.py rename to server/api/views/listDrugs/views.py diff --git a/server/api/views/listMeds/urls.py b/server/api/views/listMeds/urls.py new file mode 100644 index 00000000..e69de29b diff --git a/server/api/views/listMeds/views.py b/server/api/views/listMeds/views.py new file mode 100644 index 00000000..e69de29b diff --git a/server/balancer_backend/views/risk/urls.py b/server/api/views/risk/urls.py similarity index 69% rename from server/balancer_backend/views/risk/urls.py rename to server/api/views/risk/urls.py index 8d16e94e..30e53424 100644 --- a/server/balancer_backend/views/risk/urls.py +++ b/server/api/views/risk/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from balancer_backend.views.risk import views +from api.views.risk import views urlpatterns = [ path("chatgpt/risk", views.medication, name="risk") diff --git a/server/balancer_backend/views/risk/views.py b/server/api/views/risk/views.py similarity index 100% rename from server/balancer_backend/views/risk/views.py rename to server/api/views/risk/views.py diff --git a/server/balancer_backend/settings.py b/server/balancer_backend/settings.py index 2858c542..45d3e3f8 100644 --- a/server/balancer_backend/settings.py +++ b/server/balancer_backend/settings.py @@ -40,7 +40,8 @@ 'django.contrib.staticfiles', 'registration', 'balancer_backend', - 'user_management' + 'user_management', + 'api' ] MIDDLEWARE = [ diff --git a/server/balancer_backend/urls.py b/server/balancer_backend/urls.py index d6351be5..10d7553d 100644 --- a/server/balancer_backend/urls.py +++ b/server/balancer_backend/urls.py @@ -1,13 +1,15 @@ from django.contrib import admin +from user_management import urls as user_management_urls from django.urls import path, include import importlib -subfolders = ['auth', 'chatgpt', 'jira', 'listDrugs', 'listMeds', 'risk'] +urls = ['chatgpt', 'jira', 'listDrugs', 'listMeds', 'risk'] urlpatterns = [ path("admin/", admin.site.urls), + path("api/", include(user_management_urls)), ] -for subfolder in subfolders: - url_module = importlib.import_module(f'balancer_backend.views.{subfolder}.urls') - urlpatterns += getattr(url_module, 'urlpatterns', []) \ No newline at end of file +for url in urls: + url_module = importlib.import_module(f'api.views.{url}.urls') + urlpatterns += getattr(url_module, 'urlpatterns', []) diff --git a/server/balancer_backend/urls/auth_urls.py b/server/user_management/urls.py similarity index 100% rename from server/balancer_backend/urls/auth_urls.py rename to server/user_management/urls.py diff --git a/server/user_management/views.py b/server/user_management/views.py index 32d15f3e..82d1d35f 100644 --- a/server/user_management/views.py +++ b/server/user_management/views.py @@ -5,7 +5,7 @@ from rest_framework.decorators import api_view from django.http import JsonResponse from django.contrib.auth.models import User -from balancer_backend.models.users.registrationprofile.models import RegistrationProfile +from .models import RegistrationProfile import requests import json import os