From e378f749fb65098d04e33313d61428515877d00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Adamczak?= Date: Sat, 28 Oct 2017 22:54:25 -0400 Subject: [PATCH] Don't require 'GITHUB_API_TOKEN' and 'ZENHUB_API_TOKEN' to be set --- CHANGELOG.md | 3 +++ src/zenboard/settings.py | 4 ++-- src/zenboard/utils.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b82059f..8ad79b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver]. ## [Unreleased][unreleased] +### Changed +- Don't require `GITHUB_API_TOKEN` and `ZENHUB_API_TOKEN` to be set and log a + warning message if they're not. ## [v0.1.1][v0.1.1] - 2017-10-28 ### Fixed diff --git a/src/zenboard/settings.py b/src/zenboard/settings.py index 841ae36..d08b314 100644 --- a/src/zenboard/settings.py +++ b/src/zenboard/settings.py @@ -126,8 +126,8 @@ # API tokens -GITHUB_TOKEN = config('GITHUB_API_TOKEN') -ZENHUB_API_TOKEN = config('ZENHUB_API_TOKEN') +GITHUB_TOKEN = config('GITHUB_API_TOKEN', default='') +ZENHUB_API_TOKEN = config('ZENHUB_API_TOKEN', default='') # Misc diff --git a/src/zenboard/utils.py b/src/zenboard/utils.py index 221218a..1087fc0 100644 --- a/src/zenboard/utils.py +++ b/src/zenboard/utils.py @@ -1,12 +1,17 @@ """ zenboard utils """ +import logging + from django.conf import settings from github3 import GitHub from zenhub_api import ZenHubAPI +logger = logging.getLogger(__name__) + + class ValidateModelMixin: """ DRF mixin that calls Django model validation @@ -18,10 +23,17 @@ def validate(self, attrs): return attrs +if not settings.GITHUB_TOKEN: + logging.warning("GitHub API token not found") + github_api = GitHub( token=settings.GITHUB_TOKEN, ) + +if not settings.GITHUB_TOKEN: + logging.warning("ZenHub API token not found") + zenhub_api = ZenHubAPI( token=settings.ZENHUB_API_TOKEN, )