Skip to content

Commit

Permalink
Better handling of missing 3rd party settings
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault committed Oct 2, 2023
1 parent 8d60c81 commit ce2ae89
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
16 changes: 0 additions & 16 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,3 @@
# ------------------------------------------------------------------------------

ENV_NAME = env("ENV_NAME")


# Third party integration settings

MATTERMOST_ENDPOINT = env("DJANGO_MATTERMOST_ENDPOINT")

NOTION_SECRET = env("DJANGO_NOTION_SECRET")
NOTION_DATABASE_ID = env("DJANGO_NOTION_DATABASE_ID")

MATOMO_SECURITY_TOKEN = env("MATOMO_SECURITY_TOKEN")

CRISP_TOKEN_ID = env("DJANGO_CRISP_TOKEN_ID")
CRISP_TOKEN_KEY = env("DJANGO_CRISP_TOKEN_KEY")
CRISP_WEBSITE_ID = env("DJANGO_CRISP_WEBSITE_ID")

MAKE_COM_WEBHOOK = env("DJANGO_MAKE_COM_WEBHOOK")
1 change: 1 addition & 0 deletions envergo/evaluations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def post_evalreq_to_automation(request_id, host):
logger.info(f"Sending data to make.com {request_id} {host}")
webhook_url = settings.MAKE_COM_WEBHOOK
if not webhook_url:
logger.warning("No make.com webhook configured. Doing nothing.")
return

request = Request.objects.get(id=request_id)
Expand Down
3 changes: 3 additions & 0 deletions envergo/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def get_context_data(self, **kwargs):

def check_links(self):
token = settings.MATOMO_SECURITY_TOKEN
if not token:
raise RuntimeError("No matomo token configured")

today = date.today()
data_url = f"https://stats.data.gouv.fr/index.php?module=API&format=JSON&idSite=186&period=month&date={today:%Y-%m-%d}&method=Actions.getOutlinks&flat=1&token_auth={token}&filter_limit=100" # noqa
data = requests.get(data_url).json()
Expand Down
4 changes: 4 additions & 0 deletions envergo/utils/notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def post_request(request, host):

secret = settings.NOTION_SECRET
database_id = settings.NOTION_DATABASE_ID
if not all((secret, database_id)):
logger.warning("Notion not configured. Doing nothing.")
return

headers = {
"Accept": "application/json",
"Notion-Version": "2022-06-28",
Expand Down

0 comments on commit ce2ae89

Please sign in to comment.