示例#1
0
def saveTeam(user,postData):
    teams = Team.objects.filter(manager=user,status=1)
    if len(teams) > 0:
        return False
    else:
        team = Team()
        team.id_code = fileLogics.getIdCode("TEAM")
        team.manager = user
        user.status = 'manager'
        team.name = postData['name']
        team.profile = team.id_code
        # logo = postData['logo']
        team.school = postData['school']
        team.desc = postData['desc']
        teamProfile = TeamProfile()
        teamProfile = defaultProfile(teamProfile,team.id_code)
        teamProfile.save()
        team.save()
        try:
            user.player.team = team
            user.player.save() 
            user.status = 'manager'
        except:
            pass
        user.save()
        fileLogics.setIdCode("TEAM",int(team.id_code)+1)
        return True;
示例#2
0
def saveTeam(user,postData):
    teams = Team.objects.filter(user=user,status=1)
    if teams.length > 0:
        team = teams[0]
    else:
        team = Team()
        team.id_code = fileLogics.getTeamIdCode()
        team.manager = user
        user.status = 'manager'
        team.name = postData['name']
        profile = postData['name']
        logo = postData['logo']
    school = postData['school']
    desc = postData['desc']
    os.mkdir(os.path.join(setting.TEAM_PROFILE_DIR,team.name))
    with open(settings.TEAM_PROFILE_DIR+"/"+team.name+"/profile","wb+") as fp:
        fp.write("")
    team.save()
    user.save()
    fileLogics.setTeamIdCode(team.id_code+1)
    return True;