mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
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:
@@ -680,13 +680,6 @@ def to_not_negative_int_or_none(s: Text) -> Optional[int]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
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 to_utc_datetime(timestamp: Text) -> datetime.datetime:
|
def to_utc_datetime(timestamp: Text) -> datetime.datetime:
|
||||||
return timestamp_to_datetime(float(timestamp))
|
return timestamp_to_datetime(float(timestamp))
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from django.conf import settings
|
|||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
|
||||||
from zerver.decorator import authenticated_api_view, \
|
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.request import REQ, has_request_variables
|
||||||
from zerver.lib.response import json_success
|
from zerver.lib.response import json_success
|
||||||
from zerver.lib.validator import check_dict
|
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_NAME = 'zulip-test'
|
||||||
ZULIP_TEST_REPO_ID = 6893087
|
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:
|
def is_test_repository(repository: Mapping[Text, Any]) -> bool:
|
||||||
return repository['name'] == ZULIP_TEST_REPO_NAME and repository['id'] == ZULIP_TEST_REPO_ID
|
return repository['name'] == ZULIP_TEST_REPO_NAME and repository['id'] == ZULIP_TEST_REPO_ID
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user