From 7fab472fc4c92c17becace28b5437266c5c6c95d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 13 Mar 2019 12:49:54 -0500 Subject: [PATCH] Add "time ago" for "product already receieved" alert on mobile --- tailbone/views/purchasing/receiving.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 15680ede..ff5b0c5a 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -30,13 +30,14 @@ import re import logging import six +import humanize import sqlalchemy as sa from rattail import pod from rattail.db import model, api, Session as RattailSession from rattail.db.util import maxlen from rattail.gpc import GPC -from rattail.time import localtime +from rattail.time import localtime, make_utc from rattail.util import pretty_quantity, prettify, OrderedDict from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser from rattail.threads import Thread @@ -1561,7 +1562,9 @@ class ReceivingBatchView(PurchasingBatchView): default=False) if alert_received: if self.handler.get_units_confirmed(row): - self.request.session.flash("You have already received some of this product.", 'receiving-warning') + msg = "You have already received some of this product; last update was {}.".format( + humanize.naturaltime(make_utc() - row.modified)) + self.request.session.flash(msg, 'receiving-warning') return self.render_to_response('receive_row', context, mobile=True)