Exemple #1
0
def sendMsg(request):
    response_data = {}
    response_data.success = 0
    response_data.message = '发送失败'
    sender = request.user
    receiver = User.objects.get(username=request.POST['receiver'])
    content = request.POST['content']
    msg_type = request.POST['type']
    result = Logics.saveMsg(sender,receiver,content,msg_type)
    if result:
        response_data.success = 1
        response_data.message = '发送成功'
    return HttpResponse(json.dumps(response_data),content_type="application/json")
Exemple #2
0
def inviteJoinTeam(request):
    response_data = {}
    sender = request.user
    if len(request.user.team.all()) == 0:
        response_data['success'] = 0
        response_data['message'] = '你还不是球员,不能加入球队'
    else:
        # team = Team.objects.get(id_code=request.POST['id_code'])
        receiver = Player.objects.get(id_code=request.POST['id_code']).user
        title = sender.team.all()[0].name+"邀请你加入其球队"
        content = request.POST['content']
        msg_type = MSG_TYPE['invite_join_team']
        result = Logics.saveMsg(sender,receiver,title,content,msg_type)
        if result:
            response_data['success'] = 1
            response_data['message'] = '邀请成功'
    return HttpResponse(json.dumps(response_data),content_type="application/json")
Exemple #3
0
def applyJoinTeam(request):
    response_data = {}
    sender = request.user
    if sender.player is None:
        response_data['success'] = 0
        response_data['message'] = '你还不是球员,不能加入球队'
    else:
        team = Team.objects.get(id_code=request.POST['id_code'])
        receiver = team.manager
        title = sender.first_name+"请求加入球队"
        content = request.POST['content']
        msg_type = MSG_TYPE['apply_join_team']
        result = Logics.saveMsg(sender,receiver,title,content,msg_type)
        if result:
            response_data['success'] = 1
            response_data['message'] = '申请成功'
    return HttpResponse(json.dumps(response_data),content_type="application/json")
Exemple #4
0
def inviteGame(request):
    response_data = {}
    sender = request.user
    team = Team.objects.get(id_code=request.POST['id_code'])
    game_date = request.POST['game_date']
    # game_time = request.POST['game-time']
    # location = request.POST['location']
    receiver = team.manager
    if len(Game.objects.filter(Q(team_one = team)|Q(team_two = team),game_date=game_date)) != 0:
        response_data['success'] = 0
        response_data['message'] = '该球队当天有比赛'
    else:
        # team = Team.objects.get(id_code=request.POST['id_code'])
        title = sender.team.all()[0].name+"邀请你们球队进行比赛"
        content = request.POST['content']
        msg_type = MSG_TYPE['invite_game']
        result = Logics.saveMsg(sender,receiver,title,content,msg_type)
        if result:
            response_data['success'] = 1
            response_data['message'] = '邀请成功'
    return HttpResponse(json.dumps(response_data),content_type="application/json")