decorator: Move flexible_boolean to github webhook.

We don't really intend to use this hacky function elsewhere in the
codebase, so it's best to move it out of a core file.
This commit is contained in:
Tim Abbott
2018-04-25 21:54:51 -07:00
parent 2217285ac0
commit e78b11e920
2 changed files with 8 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ from django.conf import settings
from django.http import HttpRequest, HttpResponse
from zerver.decorator import authenticated_api_view, \
flexible_boolean, to_non_negative_int
to_non_negative_int
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success
from zerver.lib.validator import check_dict
@@ -22,6 +22,13 @@ from zerver.views.messages import send_message_backend
ZULIP_TEST_REPO_NAME = 'zulip-test'
ZULIP_TEST_REPO_ID = 6893087
def flexible_boolean(boolean: Text) -> bool:
"""Returns True for any of "1", "true", or "True". Returns False otherwise."""
if boolean in ("1", "true", "True"):
return True
else:
return False
def is_test_repository(repository: Mapping[Text, Any]) -> bool:
return repository['name'] == ZULIP_TEST_REPO_NAME and repository['id'] == ZULIP_TEST_REPO_ID