Beispiel #1
0
def push_msg(request):
    data = Checker.request(request, ['user', 'content'])
    user = Member.objects.get(name=data['user'])
    msg = Message()
    msg.user = user
    msg.content = data['content']
    msg.time = current_time()
    msg.save()
    return HttpResponse(encode({"code": 100, "log": "Normal", "data": None}))
Beispiel #2
0
def report_bug(request):
    data = Checker.request(request, ['src', 'desc', 'reptr'])
    bug = Bug()
    bug.source = Api.objects.get(name=data['src'])
    bug.reporter = Member.objects.get(name=data['reptr'])
    bug.description = data['desc']
    bug.time = current_time()
    bug.checked = True
    bug.save()
    return HttpResponse(encode({"code":100, "log": "Normal", "data": None}))
Beispiel #3
0
def accepted_order(request):
    result = {'code': 100, 'log': 'Order has been accepted successfully.'}
    re_data = None
    try:
        #result = {'code': 100, 'log': 'Order has been accepted successfully.'}
        data = Checker.request(request, ['orderID', 'phone', 'distance'])
        time_ = current_time()
        order = OrderProxy(int(data['orderID']))
        if order.accepted:
            raise OrderHasAccepted
        order = order.update(bar_phone=data['phone'], time_=time_, accepted=True).get_dict()
        barber = BarberProxy(data['phone'])
        order['distance'], order['shop'], order['address'] = data['distance'], barber.shop, barber.address
        notify_cus_order_accepted(order)
    except JianyueError as e:
        result = e.info
    finally:
        result['data'] = re_data
        return HttpResponse(encode(result))
Beispiel #4
0
def comment(request):
    result = {'code': 100, 'log': 'Comment submit successfully'}
    re_data = None
    #从request中取出customer信息
    #获取评论内容
    #获取评级
    #获取当前时间
    #添加信息到数据库
    try:
        data = Checker.request(request, ['cus_phone', 'bar_phone', 'content', 'rank'])
        CommentManager.add_comment(content=data['content'],
                                   cus_phone=data['cus_phone'],
                                   bar_phone=data['bar_phone'],
                                   rank=data['rank'],
                                   time=current_time())
    except JianyueError as e:
        result = e.info
    finally:
        result['data'] = re_data;
        return HttpResponse(encode(result))