Skip to content

Commit

Permalink
feat: read LMS URL from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
igobranco committed Oct 24, 2024
1 parent 59912f9 commit 3393503
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config.sample.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Or alternatively use `OPENEDX_LMS_URL` configuration or `OPENEDX_LMS_URL` environment variable
LMS_SERVER_URL: https://lms.ENV.nau.fccn.pt

DIGITAL_SIGNATURE:
CERTIFICATE_P12_PATH: ./digital_signature_dev/sign-pdf.dev.nau.fccn.pt.p12
CERTIFICATE_P12_PASSWORD: "1234"
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ services:
- ./digital_signature_dev:/app/digital_signature_dev
ports:
- "5000:5000"

environment:
- OPENEDX_LMS_URL=https://lms.dev.nau.fccn.pt
5 changes: 4 additions & 1 deletion nau/course/certificate/course_certificate_to_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from nau.course.certificate.cut_pdf import cut_pdf_limit_pages
from requests.auth import HTTPBasicAuth
from nau.course.certificate.digital_sign_pdf import digital_sign_pdf
import os

from urllib.parse import parse_qs

Expand Down Expand Up @@ -47,7 +48,9 @@ def __init__(self, config: Configuration, path: str, query_string: str):
self._language = language_query_values[0] if language_query_values else None

# https://lms.dev.nau.fccn.pt
lms_server_url = self._config['LMS_SERVER_URL']
lms_server_url = self._config.get('LMS_SERVER_URL', self._config.get('OPENEDX_LMS_URL', os.getenv('OPENEDX_LMS_URL')))
if not lms_server_url:
raise Exception("Bad configuration, configure `LMS_SERVER_URL` or `OPENEDX_LMS_URL` on the config.yml or alternatively `OPENEDX_LMS_URL` environment variable.")
self._url = lms_server_url + '/' + path
if query_string and len(query_string) > 0:
self._url += "?" + query_string.decode('ascii')
Expand Down

0 comments on commit 3393503

Please sign in to comment.