def handle_failed_ride(sender, signal_type, ride, status, **kwargs): from ordering.enums import RideStatus from ordering.models import FAILED from fleet.fleet_manager import cancel_ride from sharing.station_controller import send_ride_in_risk_notification from notification.api import notify_passenger if ride.status == RideStatus.FAILED: logging.info("handling FAILED ride: %s" % ride.id) current_lang = translation.get_language() # cancel ride cancel_ride(ride) # notify us send_ride_in_risk_notification(u"Ride failed because it was not accepted in time", ride.id) # cancel orders and notify passengers for order in ride.orders.all(): order.change_status(new_status=FAILED) translation.activate(order.language_code) notify_passenger(order.passenger, _("We're sorry but we couldn't find a taxi for you this time. (Order: %s)") % order.id) translation.activate(current_lang)
def handle_price_updates(sender, signal_type, order, joined_passenger, old_price, new_price, **kwargs): from notification.api import notify_passenger logging.info("order [%s] price changed: %s -> %s" % (order.id, old_price, new_price)) if old_price and new_price: savings = "%g" % (old_price - new_price) if savings > 0: notify_passenger(order.passenger, _(u"%(name)s joined your taxi - you save %(savings)s NIS!") % {"name": joined_passenger.name, "savings": savings})
def handle_price_updates(sender, signal_type, order, joined_passenger, old_price, new_price, **kwargs): from notification.api import notify_passenger logging.info("order [%s] price changed: %s -> %s" % (order.id, old_price, new_price)) if old_price and new_price: savings = "%g" % (old_price - new_price) if savings > 0: notify_passenger( order.passenger, _(u"%(name)s joined your taxi - you save %(savings)s NIS!") % { "name": joined_passenger.name, "savings": savings })
def send_ride_notifications(ride): ride_orders = ride.orders.all() for order in ride_orders: notify_passenger(order.passenger, get_order_msg(ride, order), force_sms=True)