Skip to content

Commit

Permalink
run isort black and flake8 to fix some issues (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyuan99 committed Apr 26, 2024
1 parent 9887f5a commit fb62478
Show file tree
Hide file tree
Showing 98 changed files with 1,713 additions and 1,415 deletions.
2 changes: 1 addition & 1 deletion Music_Therapy_API/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Music_Therapy_API.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Music_Therapy_API.settings")

application = get_asgi_application()
134 changes: 67 additions & 67 deletions Music_Therapy_API/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

import os
from pathlib import Path

Expand All @@ -24,82 +25,81 @@
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-1e3^*@tzw_wx1-_g9a^yhklm+-jotva27k8c2aooo@4sdo7%_t'
SECRET_KEY = "django-insecure-1e3^*@tzw_wx1-_g9a^yhklm+-jotva27k8c2aooo@4sdo7%_t"

cloudinary.config(
cloud_name="hq8x4kz7x",
api_key="966542976818381",
api_secret="RG481KhaHu4VZzhqj2gPLhUZR0Y",
secure=True
secure=True,
)

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]

CSRF_TRUSTED_ORIGINS = ['https://sojoai.com', 'https://*.127.0.0.1']
CSRF_TRUSTED_ORIGINS = ["https://sojoai.com", "https://*.127.0.0.1"]

# Application definition

INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'crispy_forms',
'app',
'music_management',
'patient_management',
'email_service',
'chat',
'accounts',
'assessment',
'sheetRAS',
'sheet4AT',
'sheetCAM1',
'findatherapist',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"crispy_forms",
"app",
"music_management",
"patient_management",
"email_service",
"chat",
"accounts",
"assessment",
"sheetRAS",
"sheet4AT",
"sheetCAM1",
"findatherapist",
"sheetAAQII",
'sheetGAD',
'sheetPHQ',
'api'
"sheetGAD",
"sheetPHQ",
"api",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'Music_Therapy_API.urls'
ROOT_URLCONF = "Music_Therapy_API.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates']
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'Music_Therapy_API.wsgi.application'
WSGI_APPLICATION = "Music_Therapy_API.wsgi.application"

# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
Expand All @@ -112,13 +112,13 @@
# }

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'daojv8o34q3a95',
'USER': 'olqthjoopbooci',
'PASSWORD': 'b961d98493c514fd77ae961db38851f22eb4f940d5a458d70dee6b4e6a6c61d1',
'HOST': 'ec2-44-207-60-135.compute-1.amazonaws.com',
'PORT': '5432',
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "daojv8o34q3a95",
"USER": "olqthjoopbooci",
"PASSWORD": "b961d98493c514fd77ae961db38851f22eb4f940d5a458d70dee6b4e6a6c61d1",
"HOST": "ec2-44-207-60-135.compute-1.amazonaws.com",
"PORT": "5432",
}
}

Expand All @@ -127,25 +127,25 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]

# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -154,11 +154,11 @@
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

STATIC_URL = '/static/'
STATIC_URL = "/static/"
# STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STORAGES = {
"staticfiles": {
Expand All @@ -169,7 +169,7 @@
MEDIA_URL: str = "/media/"

STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, "static"),
# Add other static file paths if needed
]

Expand All @@ -180,11 +180,11 @@
CRISPY_TEMPLATE_PACK = "bootstrap4"

# Email Settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.office365.com'
EMAIL_HOST_USER = 'support@sojoai.com'
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.office365.com"
EMAIL_HOST_USER = "support@sojoai.com"
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = 'riseworks'
EMAIL_HOST_PASSWORD = "riseworks"
EMAIL_PORT = 587
EMAIL_USE_SSL = False
EMAIL_USE_TLS = True
Expand All @@ -196,5 +196,5 @@
cloudinary.config(
cloud_name="hq8x4kz7x",
api_key="966542976818381",
api_secret="RG481KhaHu4VZzhqj2gPLhUZR0Y"
api_secret="RG481KhaHu4VZzhqj2gPLhUZR0Y",
)
33 changes: 17 additions & 16 deletions Music_Therapy_API/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.db import router
from django.urls import include, path

# import patient_management

urlpatterns = [
path('', include('app.urls')),
path('email/', include('email_service.urls')),
path('admin/', admin.site.urls),
path('patient/', include('patient_management.urls')),
path('music/', include('music_management.urls')),
path('chat/', include('chat.urls')),
path('accounts/', include('accounts.urls')),
path('assessment/', include('assessment.urls')),
path('sheetRAS/', include('sheetRAS.urls')),
path('sheet4AT/', include('sheet4AT.urls')),
path("", include("app.urls")),
path("email/", include("email_service.urls")),
path("admin/", admin.site.urls),
path("patient/", include("patient_management.urls")),
path("music/", include("music_management.urls")),
path("chat/", include("chat.urls")),
path("accounts/", include("accounts.urls")),
path("assessment/", include("assessment.urls")),
path("sheetRAS/", include("sheetRAS.urls")),
path("sheet4AT/", include("sheet4AT.urls")),
# path('sheetCAM/', include('sheetCAM.urls')),
path('sheetCAM1/', include('sheetCAM1.urls')),
path('findatherapist/', include('findatherapist.urls')),
path('sheetAAQII/', include('sheetAAQII.urls')),
path('sheetGAD/', include('sheetGAD.urls')),
path('sheetPHQ/', include('sheetPHQ.urls')),
path('api/', include('api.urls')),
path("sheetCAM1/", include("sheetCAM1.urls")),
path("findatherapist/", include("findatherapist.urls")),
path("sheetAAQII/", include("sheetAAQII.urls")),
path("sheetGAD/", include("sheetGAD.urls")),
path("sheetPHQ/", include("sheetPHQ.urls")),
path("api/", include("api.urls")),
]
2 changes: 1 addition & 1 deletion Music_Therapy_API/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Music_Therapy_API.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Music_Therapy_API.settings")

application = get_wsgi_application()
4 changes: 2 additions & 2 deletions accounts/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class AccountConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'
default_auto_field = "django.db.models.BigAutoField"
name = "accounts"
4 changes: 2 additions & 2 deletions accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path('', include('django.contrib.auth.urls')),
path('profile/', views.display_profile, name="profile")
path("", include("django.contrib.auth.urls")),
path("profile/", views.display_profile, name="profile"),
]
4 changes: 2 additions & 2 deletions api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
default_auto_field = "django.db.models.BigAutoField"
name = "api"
4 changes: 2 additions & 2 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'username', 'email', 'groups']
fields = ["url", "username", "email", "groups"]


class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ['url', 'name']
fields = ["url", "name"]
12 changes: 6 additions & 6 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from api import views

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'songs', views.SongViewSet)
router.register(r'playlists', views.PlaylistViewSet)
router.register(r"users", views.UserViewSet)
router.register(r"groups", views.GroupViewSet)
router.register(r"songs", views.SongViewSet)
router.register(r"playlists", views.PlaylistViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
path("", include(router.urls)),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]

urlpatterns += router.urls
6 changes: 4 additions & 2 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('-date_joined')

queryset = User.objects.all().order_by("-date_joined")
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]

Expand All @@ -18,6 +19,7 @@ class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""

queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]
permission_classes = [permissions.IsAuthenticated]
4 changes: 2 additions & 2 deletions app/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class AppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app'
default_auto_field = "django.db.models.BigAutoField"
name = "app"
2 changes: 1 addition & 1 deletion app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path('', views.index, name='index'),
path("", views.index, name="index"),
]
Loading

0 comments on commit fb62478

Please sign in to comment.