Skip to content

Commit

Permalink
Gitpod config
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Aug 22, 2024
1 parent d2b8732 commit ee743c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/gitpod-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Comment with Gitpod link
env:
DJANGO_SETTINGS_MODULE: webapp.settings.dev
run: |
GITPOD_URL="https://gitpod.io/#${{ github.event.pull_request.head.ref }}@github.com/${{ github.repository }}"
echo "View the preview: [Gitpod]($GITPOD_URL)" > gitpod_comment.md
Expand Down
18 changes: 17 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: pip install -r requirements.txt
- name: install requirements
init: pip install -r requirements.txt
- name: set .env
init: |
echo "DJANGO_SECRET_KEY=secret
DB_NAME=webapp
DB_USER=webapp
DB_PASSWORD=secret
[email protected]
[email protected]
EMAIL_SUBJECT_PREFIX='GMS: '" > .env
- name: Start Django Server
env:
DJANGO_SETTINGS_MODULE: webapp.settings.dev
command: |
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
18 changes: 12 additions & 6 deletions webapp/webapp/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,23 @@
]


EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ['MAIL_HOSTNAME']
EMAIL_PORT = os.environ['MAIL_SMTP_PORT']
EMAIL_HOST_USER = os.getenv('MAIL_SMTP_USERNAME')
EMAIL_HOST_PASSWORD = os.getenv('MAIL_SMTP_PASSWORD')
EMAIL_USE_TLS = os.getenv('MAIL_USE_TLS').lower() in ('1', 'true')
EMAIL_FROM_ADDRESS = os.environ['MAIL_FROM_ADDRESS']
EMAIL_TO_ADDRESS = os.environ['MAIL_TO_ADDRESS']
SERVER_EMAIL = os.environ['MAIL_FROM_ADDRESS']
EMAIL_SUBJECT_PREFIX = os.getenv('EMAIL_SUBJECT_PREFIX', 'GMS: ')

if os.getenv('MAIL_HOSTNAME'):
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ['MAIL_HOSTNAME']
EMAIL_PORT = os.environ['MAIL_SMTP_PORT']
EMAIL_HOST_USER = os.getenv('MAIL_SMTP_USERNAME')
EMAIL_HOST_PASSWORD = os.getenv('MAIL_SMTP_PASSWORD')
EMAIL_USE_TLS = os.getenv('MAIL_USE_TLS').lower() in ('1', 'true')
else:
print("Warning: MAIL_HOSTNAME not set. Dispatched emails will be emitted"
" to the console.")
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Validating whether submitted email is valid Galaxy AU account
MOCK_GALAXY_INTERACTIONS = (
os.getenv('MOCK_GALAXY_INTERACTIONS')
Expand Down
5 changes: 3 additions & 2 deletions webapp/webapp/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"127.0.0.1",
]

INSTALLED_APPS.append('debug_toolbar')
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
if not os.getenv('GITPOD_WORKSPACE_ID'):
INSTALLED_APPS.append('debug_toolbar')
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')

DATABASES = {
'default': {
Expand Down
4 changes: 3 additions & 1 deletion webapp/webapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

import os
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.static import serve
Expand All @@ -35,7 +36,8 @@
re_path(r'^media/(?P<path>.*)$', serve, {
'document_root': settings.MEDIA_ROOT,
}),
path('__debug__/', include('debug_toolbar.urls')),
]
if not os.getenv('GITPOD_WORKSPACE_ID'):
urlpatterns.append(path('__debug__/', include('debug_toolbar.urls')))

handler400 = 'home.views.custom_400'

0 comments on commit ee743c2

Please sign in to comment.