Skip to content

Commit

Permalink
Merge pull request #414 from patfreeman/record_date
Browse files Browse the repository at this point in the history
honor record_date of posted drinks
  • Loading branch information
mik3y authored Jun 28, 2020
2 parents c662a37 + 790a987 commit ef3e871
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions pykeg/web/api/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pykeg/web/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef3e871

Please sign in to comment.