From 790a987070d9c342ad1971e08764c3180282f5c8 Mon Sep 17 00:00:00 2001 From: Pat Freeman Date: Wed, 24 Jun 2020 21:16:07 -0500 Subject: [PATCH] honor record_date of posted drinks --- pykeg/web/api/forms.py | 1 + pykeg/web/api/views.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pykeg/web/api/forms.py b/pykeg/web/api/forms.py index d0f83f03..337d1108 100644 --- a/pykeg/web/api/forms.py +++ b/pykeg/web/api/forms.py @@ -15,6 +15,7 @@ class DrinkPostForm(forms.Form): ticks = forms.IntegerField() volume_ml = forms.FloatField(required=False) username = forms.RegexField(required=False, max_length=30, regex=USERNAME_REGEX) + record_date = forms.CharField(required=False) pour_time = forms.IntegerField(required=False) now = forms.IntegerField(required=False) duration = forms.IntegerField(required=False) diff --git a/pykeg/web/api/views.py b/pykeg/web/api/views.py index be9e2468..aaf96bb5 100644 --- a/pykeg/web/api/views.py +++ b/pykeg/web/api/views.py @@ -661,7 +661,9 @@ def _tap_detail_post(request, tap): if not form.is_valid(): raise kbapi.BadRequestError(_form_errors(form)) cd = form.cleaned_data - if cd.get("pour_time") and cd.get("now"): + if cd.get("record_date"): + pour_time = datetime.datetime.fromisoformat(cd.get("record_date")) + elif cd.get("pour_time") and cd.get("now"): pour_time = datetime.datetime.fromtimestamp(cd.get("pour_time")) pour_now = datetime.datetime.fromtimestamp(cd.get("now")) pour_time_ago = pour_now - pour_time