Skip to content

Commit

Permalink
Updated staticfiles settings for GCP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Lippold authored and Ken Lippold committed Nov 1, 2024
1 parent 8922c75 commit 20816a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
42 changes: 14 additions & 28 deletions hydroserver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@
'OPTIONS': {'location': 'static'}
}
}
elif DEPLOYMENT_BACKEND == 'gcp':
GS_BUCKET_NAME = config('GS_BUCKET_NAME', default=None)
GS_PROJECT_ID = config('GS_PROJECT_ID', default=None)
GS_CUSTOM_ENDPOINT = PROXY_BASE_URL
STORAGES = {
'default': {
'BACKEND': 'storages.backends.gcloud.GoogleCloudStorage',
'OPTIONS': {'location': 'photos'}
},
'staticfiles': {
'BACKEND': 'storages.backends.gcloud.GoogleCloudStorage',
'OPTIONS': {'location': 'static'}
}
}
else:
STORAGES = {
'default': {
Expand Down Expand Up @@ -250,31 +264,3 @@
ST_API_PREFIX = 'api/sensorthings'
ST_API_ID_QUALIFIER = "'"
ST_API_ID_TYPE = UUID


# # We need to patch Django Ninja's OpenAPISchema "methods" method to create a unique operationId for endpoints
# # that allow multiple methods on the same view function (such as GET and HEAD in this case). Without this patch,
# # our GET and HEAD methods in the Swagger docs will have the same ID and behave inconsistently. This is probably an
# # unintentional bug with the Django Ninja router.api_operation method when using it for multiple HTTP methods.
#
# from ninja.openapi.schema import OpenAPISchema
#
#
# def _methods_patch(self, operations: list) -> DictStrAny:
# result = {}
# for op in operations:
# if op.include_in_schema:
# operation_details = self.operation_details(op)
# for method in op.methods:
# # Update the operationId of HEAD methods to avoid conflict with corresponding GET methods.
# # Original code:
# # result[method.lower()] = operation_details
# result[method.lower()] = {
# **operation_details,
# 'operationId': operation_details['operationId'] + '_head'
# if method.lower() == 'head' else operation_details['operationId']
# }
# return result
#
#
# OpenAPISchema.methods = _methods_patch
1 change: 1 addition & 0 deletions hydroserver/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
call_command('migrate')
call_command('setup_admin_user')
call_command('setup_observations')
call_command('collectstatic', '--noinput')

0 comments on commit 20816a8

Please sign in to comment.