Esempio n. 1
0
def readMsg(request):
    msgs =  json.loads(request.POST['msgs'])
    for each in msgs:
        msg = Message.objects.get(id_code = each)
        Logics.readMsg(msg)
    response_data = {}
    response_data.success = 1
    response_data.message = '发送失败'
    return HttpResponse(json.dumps(response_data),content_type="application/json")
Esempio n. 2
0
def agreeInviteJoinTeam(request):
    response_data = {}
    user = User.objects.get(id_code=request.POST['id_code'])
    team = Team.objects.get(manager=user,status=1)
    msg = Message.objects.get(id_code=request.POST['msg_id_code'])
    player = request.user.player
    if Logics.checkNum(team,request.POST['r-number']):
        response_data['success'] = 0
        response_data['message'] = '号码已存在'
        return HttpResponse(json.dumps(response_data),content_type="application/json")
    result = Logics.joinTeam(player,team,request.POST['r-number'],request.POST['r-position'])
    if result:
        response_data['success'] = 1
        response_data['message'] = '保存成功'
        MsgLogics.readMsg(msg)
    return HttpResponse(json.dumps(response_data),content_type="application/json")
Esempio n. 3
0
def agreeInviteGame(request):
    response_data = {}
    postData = request.POST
    team_one = Team.objects.get(manager=User.objects.get(id_code=request.POST['id_code']),status=1)
    msg = Message.objects.get(id_code=request.POST['msg_id_code'])
    team_two = Team.objects.get(manager=request.user,status=1)
    game_date = postData['game-date']
    if len(Game.objects.filter(Q(team_one = team_one)|Q(team_two = team_one),game_date=game_date)) != 0:
        response_data['success'] = 0
        response_data['message'] = team_one.name+"当天有比赛.该邀请无效"
        return HttpResponse(json.dumps(response_data),content_type="application/json")
    if len(Game.objects.filter(Q(team_one = team_two)|Q(team_two = team_two),game_date=game_date)) != 0:
        response_data['success'] = 0
        response_data['message'] = "你的球队当天有比赛.该邀请无效"
        return HttpResponse(json.dumps(response_data),content_type="application/json")
    result = saveGame(team_one,team_two,game_date,postData['game-time'],postData['location'])
    if result:
        response_data['success'] = 1
        response_data['message'] = '生成比赛成功'
        MsgLogics.readMsg(msg)
    return HttpResponse(json.dumps(response_data),content_type="application/json")