Skip to content

Commit

Permalink
Fix Django CI issue (#340)
Browse files Browse the repository at this point in the history
biocompute-objects/portal_userdb#380

Changes to be committed:
	modified:   .github/workflows/django.yml
	modified:   biocompute/apis.py
	modified:   biocompute/models.py
	modified:   config/settings.py
	modified:   config/urls.py
  • Loading branch information
HadleyKing authored Aug 5, 2024
1 parent 945744a commit 5c5c1f7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Create .secret file
run: |
echo "${{ secrets.PORTAL_USERDB_SECRET }}" > server/.secret
- name: Run Tests
run: |
python3.9 manage.py test
4 changes: 1 addition & 3 deletions biocompute/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def post(self, request) -> Response:
data=bco_results
)

import pdb; pdb.set_trace()
return Response(status=status.HTTP_200_OK, data=response_data)

# for index, object in enumerate(data):
Expand Down Expand Up @@ -307,7 +306,6 @@ def post(self, request) -> Response:
# continue

# bco_results = validator.parse_and_validate(bco_instance.contents)
# import pdb; pdb.set_trace()
# identifier, results = bco_results.popitem()

# if results["number_of_errors"] > 0:
Expand Down Expand Up @@ -499,7 +497,7 @@ def post(self, request) -> Response:
message=message,
data=results
))

status_code = response_status(accepted_requests, rejected_requests)
return Response(status=status_code, data=response_data)

Expand Down
2 changes: 1 addition & 1 deletion biocompute/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]

class Bco(models.Model):
"""BioComput Object Model.
"""BioCompute Object Model.
Attributes:
-----------
Expand Down
56 changes: 31 additions & 25 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,35 @@
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# --- SECURITY SETTINGS --- #
# Load the server config file.
secrets = configparser.ConfigParser()
secrets.read(BASE_DIR + "/.secrets")
DEBUG = secrets["SERVER"]["DEBUG"]
VERSION = secrets["SERVER"]["SERVER_VERSION"]
# Set the anonymous user's key.
ANON_KEY = secrets["DJANGO_KEYS"]["ANON_KEY"]
ALLOWED_HOSTS = secrets["SERVER"]["ALLOWED_HOSTS"].split(',')
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = secrets["DJANGO_KEYS"]["SECRET_KEY"]

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

# The publicly accessible hostname.
HOSTNAME = secrets["SERVER"]["HOSTNAME"]
# The human-readable hostname.
HUMAN_READABLE_HOSTNAME = secrets["SERVER"]["HUMAN_READABLE_HOSTNAME"]
# The publicly accessible hostname.
PUBLIC_HOSTNAME = secrets["SERVER"]["PUBLIC_HOSTNAME"]


CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ["*"]
# Load the server .secrets file.
try:
secrets = configparser.ConfigParser()
secrets.read(BASE_DIR + "/.secrets")
DEBUG = secrets["SERVER"]["DEBUG"]
VERSION = secrets["SERVER"]["SERVER_VERSION"]
ANON_KEY = secrets["DJANGO_KEYS"]["ANON_KEY"]
ALLOWED_HOSTS = secrets["SERVER"]["ALLOWED_HOSTS"].split(',')
SECRET_KEY = secrets["DJANGO_KEYS"]["SECRET_KEY"]
HOSTNAME = secrets["SERVER"]["HOSTNAME"]
DATABASE=secrets["SERVER"]["DATABASE"]
HUMAN_READABLE_HOSTNAME = secrets["SERVER"]["HUMAN_READABLE_HOSTNAME"]
PUBLIC_HOSTNAME = secrets["SERVER"]["PUBLIC_HOSTNAME"]
EMAIL_BACKEND = secrets["SERVER"]["EMAIL_BACKEND"]

except KeyError:
SECRET_KEY="^2uql114+yy0d$xv6+lm8*#1=uxs_oa0zw0bvu^fpi4tc9x0i"
ANON_KEY="627626823549f787c3ec763ff687169206626149"
DEBUG=True
ALLOWED_HOSTS="*"
SERVER_VERSION="24.08.08"
HOSTNAME="127.0.0.1:8000"
HUMAN_READABLE_HOSTNAME="Local Test BCODB"
PUBLIC_HOSTNAME="http://127.0.0.1:8000"
SERVER_URL="http://localhost:3000"
DATABASE="db.sqlite3"
EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend"
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ["*"]

# Use the REST framework
REST_FRAMEWORK = {
Expand Down Expand Up @@ -144,7 +150,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": secrets["SERVER"]["DATABASE"],
"NAME": DATABASE,
}
}

Expand Down Expand Up @@ -178,7 +184,7 @@
# Make the object naming accessible as a dictionary.

# emailing notifications
EMAIL_BACKEND = secrets["SERVER"]["EMAIL_BACKEND"]
EMAIL_BACKEND = EMAIL_BACKEND
EMAIL_HOST = "localhost"
EMAIL_PORT = 25
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
2 changes: 1 addition & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rest_framework import permissions
from biocompute.apis import DraftRetrieveApi, PublishedRetrieveApi

VERSION = settings.VERSION
VERSION = settings.SERVER_VERSION

ShcemaView = get_schema_view(
openapi.Info(
Expand Down

0 comments on commit 5c5c1f7

Please sign in to comment.