def create_team(request, tournament_id): tournament = Tournament.objects.get(pk=int(tournament_id)) # if this is a POST request we need to process the form data if request.method == "POST": # create a form instance and populate it with data from the request: form = TeamForm(request.POST) # check whether it"s valid: if form.is_valid(): team = Team.create(form.cleaned_data["name"], tournament) for player_name in form.cleaned_data["members"].split(","): summoner = Summoner.find_or_create(player_name) team.summoners.add(summoner) return redirect('tournament', tournament_id=tournament_id) else: form = TeamForm() return render(request, "team/create.html", {"form": form, "action":reverse("create_team", args=[tournament.id])})
def auth(): data = json.loads(request.data) if 'login' and 'password' in data: if Summoner.authenticate(data['login'], data['password']): return jsonify(data) return authenticate()
def decorated(*args, **kwargs): auth = request.authorization if not auth or not Summoner.authenticate(auth.username, auth.password): return authenticate() return f(*args, **kwargs)