irongit

Enhanced time synchronization for drf views.

using strings for types

huncholanehuncholaneauthored
parent 3168c2bcommit f765ef697ae965553946867b4c1d1d64a9555841Browse files

2 files changed, +11 -7

+2-0.gitignore
@@ -25,3 +25,5 @@ db.sqlite3
2525 .coverage
2626 .pytest_cache/
2727
28+/app
29+
+9-7plusrequest/settings.py
@@ -5,7 +5,7 @@ from django.conf import settings
55 from plusrequest.types import MissingAction
66
77
8-def env(type: type, key: str, default: str):
8+def env(type: str, key: str, default: str):
99 return getattr(e, str(type))(f"PLUSREQUEST_{key}", default)
1010
1111
@@ -13,17 +13,19 @@ def env(type: type, key: str, default: str):
1313 class PlusRequestConf:
1414 """Dataclass for configuring PlusRequest"""
1515
16- header_timestamp_field: str = env(str, "HEADER_TIMESTAMP_FIELD", "lastUpdated")
16+ header_timestamp_field: str = env("str", "HEADER_TIMESTAMP_FIELD", "lastUpdated")
1717 """Field in headers to use for client timestamp"""
18- body_timestamp_field: str = env(str, "BODY_TIMESTAMP_FIELD", "lastUpdated")
18+ body_timestamp_field: str = env("str", "BODY_TIMESTAMP_FIELD", "lastUpdated")
1919 """Field in request body to use for client timestamp"""
20- instance_timestamp_field: str = env(str, "INSTANCE_TIMESTAMP_FIELD", "lastUpdated")
20+ instance_timestamp_field: str = env(
21+ "str", "INSTANCE_TIMESTAMP_FIELD", "lastUpdated"
22+ )
2123 """Field in model instance to use for server timestamp"""
22- noupdate_code: str = env(str, "NOUPDATE_CODE", "418")
24+ noupdate_code: str = env("str", "NOUPDATE_CODE", "418")
2325 """Status code for when the client is newer on a GET or client is older on a POST"""
24- missing_action: MissingAction = env(str, "MISSING_ACTION", "noupdate")
26+ missing_action: MissingAction = env("str", "MISSING_ACTION", "noupdate")
2527 """What do do when the client does not provide a timestamp"""
26- datetime_format: str = env(str, "DATETIME_FORMAT", "%Y-%m-%dT%H:%M:%S%z")
28+ datetime_format: str = env("str", "DATETIME_FORMAT", "%Y-%m-%dT%H:%M:%S%z")
2729
2830
2931 if hasattr(settings, "PLUSREQUEST_CONF"):