当前位置: 首页>>代码示例>>Python>>正文


Python Team.set_password方法代码示例

本文整理汇总了Python中models.Team.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python Team.set_password方法的具体用法?Python Team.set_password怎么用?Python Team.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Team的用法示例。


在下文中一共展示了Team.set_password方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import set_password [as 别名]
def register(request):
    if request.method == 'POST':
        data = request.POST
        print data
        myDict = dict(data.iterlists())
        players = []
        for n in range(5):
            name = myDict['name'][n]
            email = myDict['email'][n]
            print name, email
            if not Riot.is_riot_user(name, email):
                return HttpResponse("Player "+name+" is not in the db of riot")
            role = myDict['role'][n]
            print role
            player = Player(name=name, email=email, role=role)
            players.append(player)
        team_name = myDict['team_name'][0]
        Riot.is_top_team(team_name)
        team_email = myDict['team_email'][0]
        team = Team(name= team_name, email= team_email)
        team.save()
        team.set_password(myDict['password'][0])
        team.save()
        group = Group.objects.get(name='Team')
        team.group.add(group)
        team.save()
        for player in players:
            player.set_team(team)
            player.save()
        data_email = {'type': "confirmation",'team':team_name, 'players':players}
        Riot.send_email(team_email, data_email)
        #log in
        team = authenticate(username=team_name, password=myDict['password'][0])
        if team:
            if team.is_active:
                login(request, team)
                return HttpResponseRedirect('/team/'+team_name)
            else:
                return HttpResponse("Your account is disabled")
        else:
            print "Invalid log details: {0}, {1}".format(team_name, myDict['password'][0])
            return HttpResponse("Invalid log details")
    else:
        team_form = TeamForm()
        player_form = PlayerForm()
        return render(request, 'Register.html', {'team_form': team_form, 'player_form': player_form})
开发者ID:xavics,项目名称:ManageLol,代码行数:48,代码来源:views.py


注:本文中的models.Team.set_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。