Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions backend/apps/ifc_validation_bff/views_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from apps.ifc_validation.tasks import ifc_file_validation_task

from core.settings import MEDIA_ROOT, MAX_FILES_PER_UPLOAD
from core.settings import DEVELOPMENT, LOGIN_URL, USE_WHITELIST
from core.settings import DEVELOPMENT, PREVIEW
from core.settings import LOGIN_URL, USE_WHITELIST
from core.settings import FEATURE_URL, MAX_OUTCOMES_PER_RULE

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -61,7 +62,7 @@ def get_current_user(request):
return user

# only used for local development
elif DEVELOPMENT and not USE_WHITELIST:
elif (DEVELOPMENT or PREVIEW) and not USE_WHITELIST:

username = 'development'
user = UserAdditionalInfo.find_user_by_username(username)
Expand Down Expand Up @@ -109,7 +110,10 @@ def get_feature_filename(feature_code):
def get_feature_url(feature_code):
"""
Get the URL for the corresponding feature filename
In DEV, we return the filename in the 'development' branch of the repository and 'main' for PROD.
We return the filename in the relevant branch of the repositoy, eg.
- 'development' for DEV
- 'preview' for PREVIEW
- 'main' for MAIN
"""
feature_files = get_feature_filename(feature_code)

Expand Down
10 changes: 5 additions & 5 deletions backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = ast.literal_eval(os.environ.get("DEBUG", 'False'))
DEVELOPMENT = os.environ.get('ENV', 'PROD').upper() in ('DEV', 'DEVELOP', 'DEVELOPMENT')
STAGING = os.environ.get('ENV', 'PROD').upper() in ('STAGE', 'STAGING', 'QA')
PREVIEW = os.environ.get('ENV', 'PROD').upper() in ('PREV', 'PREVIEW', 'STAGE', 'STAGING', 'QA')
PRODUCTION = os.environ.get('ENV', 'PROD').upper() in ('PROD', 'PRODUCTION', 'PRD')
ENVIRONMENT = 'DEVELOPMENT' if DEVELOPMENT else 'STAGING' if STAGING else 'PRODUCTION'
ENVIRONMENT = 'DEVELOPMENT' if DEVELOPMENT else 'PREVIEW' if PREVIEW else 'PRODUCTION'
PUBLIC_URL = os.getenv('PUBLIC_URL').strip('/') if os.getenv('PUBLIC_URL') is not None else None

# URL for rule hyperlinks; determine the branch based on the environment
FEATURE_BRANCH = "development" if DEVELOPMENT else "main"
FEATURE_BRANCH = 'development' if DEVELOPMENT else 'preview' if PREVIEW else 'main'
FEATURE_URL = os.getenv(
"FEATURE_URL", f"https://buildingsmart.github.io/ifc-gherkin-rules/branches/{FEATURE_BRANCH}/features/"
)
Expand Down Expand Up @@ -78,7 +78,7 @@
"django_cleanup.apps.CleanupConfig" # to automatically remove unlinked files
]

if DEVELOPMENT:
if DEVELOPMENT or PREVIEW:
INSTALLED_APPS += [
"debug_toolbar",
]
Expand All @@ -99,7 +99,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

if DEVELOPMENT:
if DEVELOPMENT or PREVIEW:
MIDDLEWARE += [
"debug_toolbar.middleware.DebugToolbarMiddleware",
]
Expand Down
5 changes: 3 additions & 2 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from .views_auth import login, logout, callback, whoami

from core.settings import MEDIA_ROOT, MEDIA_URL, STATIC_URL, STATIC_ROOT, DEVELOPMENT
from core.settings import MEDIA_ROOT, MEDIA_URL, STATIC_URL, STATIC_ROOT
from core.settings import DEVELOPMENT, PREVIEW


def redirect_root(request):
Expand Down Expand Up @@ -80,7 +81,7 @@ def redirect_to_v1(request, resource, suffix=None):
path('callback/', callback, name='callback'),
]

if DEVELOPMENT:
if DEVELOPMENT or PREVIEW:
urlpatterns += [
# redirect root to admin
path("", lambda request: HttpResponseRedirect("/admin/")),
Expand Down
Loading