Skip to content

Commit 5c5c1f7

Browse files
authored
Fix Django CI issue (#340)
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
1 parent 945744a commit 5c5c1f7

File tree

5 files changed

+35
-33
lines changed

5 files changed

+35
-33
lines changed

.github/workflows/django.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ jobs:
2424
run: |
2525
python -m pip install --upgrade pip
2626
pip install -r requirements.txt
27-
- name: Create .secret file
28-
run: |
29-
echo "${{ secrets.PORTAL_USERDB_SECRET }}" > server/.secret
27+
3028
- name: Run Tests
3129
run: |
3230
python3.9 manage.py test

biocompute/apis.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ def post(self, request) -> Response:
244244
data=bco_results
245245
)
246246

247-
import pdb; pdb.set_trace()
248247
return Response(status=status.HTTP_200_OK, data=response_data)
249248

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

309308
# bco_results = validator.parse_and_validate(bco_instance.contents)
310-
# import pdb; pdb.set_trace()
311309
# identifier, results = bco_results.popitem()
312310

313311
# if results["number_of_errors"] > 0:
@@ -499,7 +497,7 @@ def post(self, request) -> Response:
499497
message=message,
500498
data=results
501499
))
502-
500+
503501
status_code = response_status(accepted_requests, rejected_requests)
504502
return Response(status=status_code, data=response_data)
505503

biocompute/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
]
2020

2121
class Bco(models.Model):
22-
"""BioComput Object Model.
22+
"""BioCompute Object Model.
2323
2424
Attributes:
2525
-----------

config/settings.py

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,35 @@
99
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1010

1111
# --- SECURITY SETTINGS --- #
12-
# Load the server config file.
13-
secrets = configparser.ConfigParser()
14-
secrets.read(BASE_DIR + "/.secrets")
15-
DEBUG = secrets["SERVER"]["DEBUG"]
16-
VERSION = secrets["SERVER"]["SERVER_VERSION"]
17-
# Set the anonymous user's key.
18-
ANON_KEY = secrets["DJANGO_KEYS"]["ANON_KEY"]
19-
ALLOWED_HOSTS = secrets["SERVER"]["ALLOWED_HOSTS"].split(',')
20-
# SECURITY WARNING: keep the secret key used in production secret!
21-
SECRET_KEY = secrets["DJANGO_KEYS"]["SECRET_KEY"]
22-
23-
# SECURITY WARNING: don't run with debug turned on in production!
24-
25-
# The publicly accessible hostname.
26-
HOSTNAME = secrets["SERVER"]["HOSTNAME"]
27-
# The human-readable hostname.
28-
HUMAN_READABLE_HOSTNAME = secrets["SERVER"]["HUMAN_READABLE_HOSTNAME"]
29-
# The publicly accessible hostname.
30-
PUBLIC_HOSTNAME = secrets["SERVER"]["PUBLIC_HOSTNAME"]
31-
32-
33-
CORS_ORIGIN_ALLOW_ALL = True
34-
CORS_ORIGIN_WHITELIST = ["*"]
12+
# Load the server .secrets file.
13+
try:
14+
secrets = configparser.ConfigParser()
15+
secrets.read(BASE_DIR + "/.secrets")
16+
DEBUG = secrets["SERVER"]["DEBUG"]
17+
VERSION = secrets["SERVER"]["SERVER_VERSION"]
18+
ANON_KEY = secrets["DJANGO_KEYS"]["ANON_KEY"]
19+
ALLOWED_HOSTS = secrets["SERVER"]["ALLOWED_HOSTS"].split(',')
20+
SECRET_KEY = secrets["DJANGO_KEYS"]["SECRET_KEY"]
21+
HOSTNAME = secrets["SERVER"]["HOSTNAME"]
22+
DATABASE=secrets["SERVER"]["DATABASE"]
23+
HUMAN_READABLE_HOSTNAME = secrets["SERVER"]["HUMAN_READABLE_HOSTNAME"]
24+
PUBLIC_HOSTNAME = secrets["SERVER"]["PUBLIC_HOSTNAME"]
25+
EMAIL_BACKEND = secrets["SERVER"]["EMAIL_BACKEND"]
26+
27+
except KeyError:
28+
SECRET_KEY="^2uql114+yy0d$xv6+lm8*#1=uxs_oa0zw0bvu^fpi4tc9x0i"
29+
ANON_KEY="627626823549f787c3ec763ff687169206626149"
30+
DEBUG=True
31+
ALLOWED_HOSTS="*"
32+
SERVER_VERSION="24.08.08"
33+
HOSTNAME="127.0.0.1:8000"
34+
HUMAN_READABLE_HOSTNAME="Local Test BCODB"
35+
PUBLIC_HOSTNAME="http://127.0.0.1:8000"
36+
SERVER_URL="http://localhost:3000"
37+
DATABASE="db.sqlite3"
38+
EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend"
39+
CORS_ORIGIN_ALLOW_ALL = True
40+
CORS_ORIGIN_WHITELIST = ["*"]
3541

3642
# Use the REST framework
3743
REST_FRAMEWORK = {
@@ -144,7 +150,7 @@
144150
DATABASES = {
145151
"default": {
146152
"ENGINE": "django.db.backends.sqlite3",
147-
"NAME": secrets["SERVER"]["DATABASE"],
153+
"NAME": DATABASE,
148154
}
149155
}
150156

@@ -178,7 +184,7 @@
178184
# Make the object naming accessible as a dictionary.
179185

180186
# emailing notifications
181-
EMAIL_BACKEND = secrets["SERVER"]["EMAIL_BACKEND"]
187+
EMAIL_BACKEND = EMAIL_BACKEND
182188
EMAIL_HOST = "localhost"
183189
EMAIL_PORT = 25
184190
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

config/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from rest_framework import permissions
1212
from biocompute.apis import DraftRetrieveApi, PublishedRetrieveApi
1313

14-
VERSION = settings.VERSION
14+
VERSION = settings.SERVER_VERSION
1515

1616
ShcemaView = get_schema_view(
1717
openapi.Info(

0 commit comments

Comments
 (0)