Skip to content

Commit

Permalink
minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed Jul 20, 2023
1 parent 6034dc7 commit 603c0ee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
52 changes: 26 additions & 26 deletions care/abdm/utils/api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ def fetch_modes(self, data):

payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"query": {
"id": data["healthId"],
Expand All @@ -438,8 +438,8 @@ def init(self, prev_request_id):

payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"query": {
"id": data["healthId"],
Expand All @@ -466,8 +466,8 @@ def confirm(self, transaction_id, prev_request_id):

payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"transactionId": transaction_id,
"credential": {
Expand All @@ -490,8 +490,8 @@ def auth_on_notify(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"acknowledgement": {"status": "OK"},
# "error": {"code": 1000, "message": "string"},
Expand All @@ -510,8 +510,8 @@ def add_contexts(self, data):

payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"link": {
"accessToken": data["access_token"],
Expand All @@ -538,8 +538,8 @@ def on_discover(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"transactionId": data["transaction_id"],
"patient": {
Expand Down Expand Up @@ -570,8 +570,8 @@ def on_link_init(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"transactionId": data["transaction_id"],
"link": {
Expand Down Expand Up @@ -601,8 +601,8 @@ def on_link_confirm(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"patient": {
"referenceNumber": data["patient_id"],
Expand Down Expand Up @@ -631,8 +631,8 @@ def on_notify(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"acknowledgement": {"status": "OK", "consentId": data["consent_id"]},
# "error": {"code": 1000, "message": "string"},
Expand All @@ -649,8 +649,8 @@ def on_data_request(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"hiRequest": {
"transactionId": data["transaction_id"],
Expand Down Expand Up @@ -696,8 +696,8 @@ def data_notify(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"notification": {
"consentId": data["consent_id"],
Expand Down Expand Up @@ -732,8 +732,8 @@ def patient_status_on_notify(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"acknowledgement": {"status": "OK"},
# "error": {"code": 1000, "message": "string"},
Expand All @@ -750,8 +750,8 @@ def patient_sms_notify(self, data):
request_id = str(uuid.uuid4())
payload = {
"requestId": request_id,
"timestamp": str(
datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
"timestamp": datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
),
"notification": {
"phoneNo": f"+91-{data['phone']}",
Expand Down
6 changes: 0 additions & 6 deletions care/utils/assetintegration/onvif.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class OnvifActions(enum.Enum):
GOTO_PRESET = "goto_preset"
ABSOLUTE_MOVE = "absolute_move"
RELATIVE_MOVE = "relative_move"
# STEP 1 | Part 1
# GET_STREAMING_TOKEN = "getStreamingToken"

def __init__(self, meta):
try:
Expand Down Expand Up @@ -56,8 +54,4 @@ def handle_action(self, action):
if action_type == self.OnvifActions.RELATIVE_MOVE.value:
return self.api_post(self.get_url("relativeMove"), request_body)

# STEP 1 | Part 3
# if action_type == self.OnvifActions.GET_STREAMING_TOKEN.value:
# return self.api_post(self.get_url("getStreamingToken"), request_body)

raise ValidationError({"action": "invalid action type"})
3 changes: 2 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.json("DJANGO_ALLOWED_HOSTS", default=["*"])
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("DJANGO_DEBUG", True)
DEBUG = env.bool("DJANGO_DEBUG", False)
# Local time zone. Choices are
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# though not all of them may be available with every OS.
Expand Down Expand Up @@ -358,6 +358,7 @@
"USER_ID_FIELD": "external_id",
}

# Celery (background tasks)
# ------------------------------------------------------------------------------
# https://docs.celeryq.dev/en/latest/userguide/configuration.html#std:setting-timezone
if USE_TZ:
Expand Down

0 comments on commit 603c0ee

Please sign in to comment.