示例#1
0
文件: order.py 项目: yyaadet/mealing
 def get_status(self):
     """ to get readable status
     """
     if is_today(datetime.datetime(1, 1, 1).fromtimestamp(self.add_timestamp)) is False:
         return u"已过期"
     elif self.notify_number > 0:
         return u"餐已经到了"
     else:
         return u"未到"
示例#2
0
 def add_order_number(self, number = 1):
     """ add order number
     """
     last_order_date = datetime.datetime(1, 1, 1).fromtimestamp(self.last_order_timestamp)
     if is_today(last_order_date):
         self.order_number += number
         self.order_number_today += number
         self.last_order_timestamp = int(time.time())
     else:
         self.order_number += number
         self.order_number_today = number
         self.last_order_timestamp = int(time.time())
示例#3
0
文件: order.py 项目: yyaadet/mealing
def delete(request, order_id = 0):
    """ to delete order by self, who is sponsor
    """
    order = Order.objects.get(pk = order_id)
    if not order:
        raise Http404
    if order.sponsor != request.user:
        messages.warning(request, u"订单不是你发起的,无权删除")
        return redirect("/user/")
    config = Config.get_default()
    if _is_order_shutdown(request, config) is True:
        messages.warning(request, u"订餐系统关闭中,暂时不能删除")
        return redirect("/user/")
    if is_today(datetime.datetime(1, 1, 1).fromtimestamp(order.add_timestamp)) is False:
        logging.debug("order %d is out of time" % order.id)
        messages.warning(request, u"订单已经过期,不允许删除,请联系管理员")
        return redirect("/user/")
    order.delete()
    return redirect("/user/")