Skip to content

Commit

Permalink
Merge pull request #3909 from airqo-platform/staging
Browse files Browse the repository at this point in the history
move to production
  • Loading branch information
Baalmart authored Nov 25, 2024
2 parents 8e64a1e + db11491 commit 6fe3060
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 14 deletions.
2 changes: 1 addition & 1 deletion k8s/analytics/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ images:
celeryWorker: eu.gcr.io/airqo-250220/airqo-analytics-celery-worker
reportJob: eu.gcr.io/airqo-250220/airqo-analytics-report-job
devicesSummaryJob: eu.gcr.io/airqo-250220/airqo-analytics-devices-summary-job
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
api:
name: airqo-analytics-api
label: analytics-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/auth-service/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-auth-api
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-device-registry-api
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-airqo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ app:
configmap: env-exceedance-production
image:
repository: eu.gcr.io/airqo-250220/airqo-exceedance-job
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
nameOverride: ''
fullnameOverride: ''
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-kcca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ app:
configmap: env-exceedance-production
image:
repository: eu.gcr.io/airqo-250220/kcca-exceedance-job
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
nameOverride: ''
fullnameOverride: ''
2 changes: 1 addition & 1 deletion k8s/predict/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ images:
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
tag: prod-eeb5fe06-1732531710
tag: prod-8e64a1e8-1732536341
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/website/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-website-api
tag: stage-415b0df1-1732531646
tag: stage-33e734c1-1732536251
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
15 changes: 15 additions & 0 deletions src/website/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,18 @@ def cloudinary_file_upload(file):
print(f"Media files are stored in: {MEDIA_ROOT}")
else:
print("Production mode is ON")


# Django Admin Configuration
LOGIN_URL = '/website/admin/login/'

SWAGGER_SETTINGS = {
'LOGIN_URL': '/website/admin/login/',
'LOGOUT_URL': '/website/admin/logout/',
'USE_SESSION_AUTH': True,
'SECURITY_DEFINITIONS': {
'basic': {
'type': 'basic'
}
},
}
34 changes: 27 additions & 7 deletions src/website/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.conf import settings
from django.conf.urls.static import static
from django.http import JsonResponse
from django.contrib.auth.decorators import login_required

# Swagger Imports
from rest_framework import permissions
Expand All @@ -29,12 +30,20 @@ def healthcheck(request):
license=openapi.License(name="BSD License"),
)

schema_view = get_schema_view(
# Public schema view for JSON and YAML (no authentication required)
public_schema_view = get_schema_view(
api_info,
public=True,
permission_classes=(permissions.AllowAny,),
)

# Protected schema view for Swagger and ReDoc (requires authentication)
protected_schema_view = get_schema_view(
api_info,
public=False,
permission_classes=(permissions.IsAuthenticated,),
)

urlpatterns = [
# Root URL
path('website/', core_views.index, name='index'),
Expand All @@ -58,12 +67,23 @@ def healthcheck(request):
path('website/', include('apps.africancities.urls')),

# Swagger URLs
re_path(r'^swagger(?P<format>\.json|\.yaml)$',
schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('website/swagger/', schema_view.with_ui('swagger',
cache_timeout=0), name='schema-swagger-ui'),
path('website/redoc/', schema_view.with_ui('redoc',
cache_timeout=0), name='schema-redoc'),
re_path(
r'^swagger(?P<format>\.json|\.yaml)$',
public_schema_view.without_ui(cache_timeout=0),
name='schema-json'
),
path(
'website/swagger/',
login_required(protected_schema_view.with_ui(
'swagger', cache_timeout=0)),
name='schema-swagger-ui'
),
path(
'website/redoc/',
login_required(protected_schema_view.with_ui(
'redoc', cache_timeout=0)),
name='schema-redoc'
),

# Healthcheck route
path('website/healthcheck/', healthcheck, name='healthcheck'),
Expand Down

0 comments on commit 6fe3060

Please sign in to comment.