Пример #1
0
	def sendWinningMessage(self, match):
		winningTeam = None
		losingTeams = []

		for team in match.teams:
			if team.win:
				winningTeam = team
			else:
				losingTeams.append(team)

		player1 = winningTeam.players[0]
		player2 = losingTeams[0].players[0]
		player3 = losingTeams[1].players[0]
		player4 = losingTeams[2].players[0]

		winnerPoints = 9
		for score in winningTeam.scores:
			winnerPoints = winnerPoints - 1

		message = "<b>{} ({})</b> defeated {}, {}, and {} in Nines".format(player1.name, winnerPoints, player2.name, player3.name, player4.name)

		if winnerPoints == 9:
			message += "\n{} played a perfect match, but nobody really cares...".format(player1.name)

		message += '\n<a href="{}leaderboard/nines">Leaderboard Standings</a>'.format(request.url_root)

		notifications.send(message, match.officeId)
Пример #2
0
	def sendWinningMessage(self, match):
		winningTeam = None
		losingTeams = []

		for team in match.teams:
			if team.win:
				winningTeam = team
			else:
				losingTeams.append(team)

		player1 = winningTeam.players[0]
		player2 = losingTeams[0].players[0]
		player3 = losingTeams[1].players[0]
		player4 = losingTeams[2].players[0]

		winnerPoints = 9
		for score in winningTeam.scores:
			winnerPoints = winnerPoints - 1

		message = "<b>{} ({})</b> defeated {}, {}, and {} in Nines".format(player1.name, winnerPoints, player2.name, player3.name, player4.name)

		if winnerPoints == 9:
			message += "<br>{} played a perfect match, but nobody really cares...".format(player1.name)

		message += '<br><a href="{}leaderboard/nines">Leaderboard Standings</a>'.format(request.url_root)

		notifications.send(message)
Пример #3
0
def update(id):
    player = playerService.selectById(id)

    if player == None:
        abort(404)

    if not player.enabled and not current_user.is_authenticated:
        abort(404)

    hasErrors = playerForm.validate(id, session["office"]["id"], request.form)

    originalName = player.name

    if hasErrors:
        playerForm.load(player, request.form)
        return render_template("players/edit.html", player=player), 400

    else:
        updatedPlayer = playerService.update(id, request.form)
        newName = updatedPlayer.name

        uploaded, avatar, extension = util.uploadAvatar(updatedPlayer)
        if uploaded:
            playerService.avatar(player, avatar, extension)

        flash(
            "Player '{}' has been successfully updated.".format(
                updatedPlayer.name), "success")

        if originalName != newName:
            message = "<b>{}</b> is now known as <b>{}</b>.".format(
                originalName, newName)
            notifications.send(message)

        return redirect(url_for("playerController.index"))
Пример #4
0
def create(matchId):
    hasErrors = playerForm.validate(None, session["office"]["id"],
                                    request.form)

    if hasErrors:
        player = playerService.new()
        playerForm.load(player, request.form)
        return render_template("players/new.html",
                               player=player,
                               matchId=matchId), 400
    else:
        player = playerService.create(session["office"]["id"], request.form)

        uploaded, avatar, extension = util.uploadAvatar(player)
        if uploaded:
            playerService.avatar(player, avatar, extension)

        flash("Player '{}' has been successfully created.".format(player.name),
              "success")

        message = "<b>{}</b> has joined ping pong. Please consider adding them to the ping pong chat group.".format(
            player.name)
        notifications.send(message)

        if matchId != None:
            return redirect(url_for("matchController.players", id=matchId))
        else:
            return redirect(url_for("playerController.index"))
Пример #5
0
	def sendWinningMessage(self, match, winningTeam, winningSets, losingTeam, losingSets):
		winnerPlayer1 = winningTeam.players[0]
		winnerPlayer2 = winningTeam.players[1]
		losingPlayer1 = losingTeam.players[0]
		losingPlayer2 = losingTeam.players[1]

		message = "<b>{}</b> and <b>{}</b> defeated {} and {}, {} - {}".format(winnerPlayer1.name, winnerPlayer2.name, losingPlayer1.name, losingPlayer2.name, winningSets, losingSets)

		winnerScores = "\n"
		loserScores = "\n"

		for game in match.games:
			if game.completedAt == None:
				continue

			if game.winner == winningTeam.id:
				winnerScores += "<b>{}</b> \t".format(game.getFormattedWinnerScore())
				loserScores += "{} \t".format(game.getFormattedLoserScore())
			else:
				winnerScores += "{} \t".format(game.getFormattedLoserScore())
				loserScores += "<b>{}</b> \t".format(game.getFormattedWinnerScore())

		message += winnerScores
		message += loserScores

		message += '\n<a href="{}leaderboard/doubles">Leaderboard Standings</a>'.format(request.url_root)

		notifications.send(message, match.officeId)
Пример #6
0
def update(id):
	player = playerService.selectById(id)

	if player == None:
		abort(404)

	if not player.enabled and not current_user.is_authenticated:
		abort(404)

	hasErrors = playerForm.validate(id, session["office"]["id"], request.form)

	originalName = player.name

	if hasErrors:
		playerForm.load(player, request.form)
		return render_template("players/edit.html", player = player), 400

	else:
		updatedPlayer = playerService.update(id, request.form)
		newName = updatedPlayer.name

		uploaded, avatar, extension = util.uploadAvatar(updatedPlayer)
		if uploaded:
			playerService.avatar(player, avatar, extension)

		flash("Player '{}' has been successfully updated.".format(updatedPlayer.name), "success")

		if originalName != newName:
			message = "<b>{}</b> is now known as <b>{}</b>.".format(originalName, newName)
			notifications.send(message, session["office"]["id"])

		return redirect(url_for("playerController.index"))
Пример #7
0
	def play(self, match):
		matchService.play(match)

		player1 = match.teams[0].players[0]
		player2 = match.teams[1].players[0]

		message = '<a href="{}matches/{}">{} is playing {} in a best of {}</a>'.format(request.url_root, match.id, player1.name, player2.name, match.numOfGames)

		notifications.send(message, match.officeId)
Пример #8
0
	def play(self, match):
		matchService.play(match)

		player1 = match.teams[0].players[0]
		player2 = match.teams[1].players[0]
		player3 = match.teams[2].players[0]
		player4 = match.teams[3].players[0]

		message = '<a href="{}matches/{}">{}, {}, {} and {} are playing nines</a>'.format(request.url_root, match.id, player1.name, player2.name, player3.name, player4.name)
		notifications.send(message)
Пример #9
0
	def play(self, match):
		matchService.play(match)

		player1 = match.teams[0].players[0]
		player2 = match.teams[1].players[0]
		player3 = match.teams[2].players[0]
		player4 = match.teams[3].players[0]

		message = '<a href="{}matches/{}">{}, {}, {} and {} are playing nines</a>'.format(request.url_root, match.id, player1.name, player2.name, player3.name, player4.name)
		notifications.send(message, match.officeId)
Пример #10
0
    def play(self, match):
        matchService.play(match)

        player1 = match.teams[0].players[0]
        player2 = match.teams[1].players[0]

        message = '<a href="{}matches/{}">{} is playing {} in a best of {}</a>'.format(
            request.url_root, match.id, player1.name, player2.name,
            match.numOfGames)

        notifications.send(message)
Пример #11
0
	def play(self, match):
		matchService.play(match)

		t1p1 = match.teams[0].players[0]
		t1p2 = match.teams[0].players[1]
		t2p1 = match.teams[1].players[0]
		t2p2 = match.teams[1].players[1]

		message = '<a href="{}matches/{}">{} and {} are playing {} and {} in a best of {}</a>'.format(request.url_root, match.id, t1p1.name, t1p2.name, t2p1.name, t2p2.name, match.numOfGames)

		notifications.send(message, match.officeId)
Пример #12
0
def send_message():
	message = util.paramForm("message")
	officeIds = request.form.getlist("officeId")

	if message != None and len(message) > 0 and len(officeIds) > 0:
		notifications.send(message, officeIds)
		flash("Message has been sent.", "success")
	else:
		flash("Message was malformed and was not be sent.", "danger")

	return redirect(url_for("adminController.index"))
Пример #13
0
def send_message():
	message = util.paramForm("message")
	officeIds = request.form.getlist("officeId")

	if message != None and len(message) > 0 and len(officeIds) > 0:
		notifications.send(message)
		flash("Message has been sent.", "success")
	else:
		flash("Message was malformed and was not be sent.", "danger")

	return redirect(url_for("adminController.index"))
Пример #14
0
    def play(self, match):
        matchService.play(match)

        t1p1 = match.teams[0].players[0]
        t1p2 = match.teams[0].players[1]
        t2p1 = match.teams[1].players[0]
        t2p2 = match.teams[1].players[1]

        message = '<a href="{}matches/{}">{} and {} are playing {} and {} in a best of {}</a>'.format(
            request.url_root, match.id, t1p1.name, t1p2.name, t2p1.name,
            t2p2.name, match.numOfGames)

        notifications.send(message)
Пример #15
0
    def sendWinningMessage(self, match, winningTeam, winningSets, losingTeam,
                           losingSets):
        winnerPlayer = winningTeam.players[0]
        losingPlayer = losingTeam.players[0]

        message = "<b>{}</b> defeated {}, {} - {}".format(
            winnerPlayer.name, losingPlayer.name, winningSets, losingSets)

        winnerScores = "<br>"
        loserScores = "<br>"

        for game in match.games:
            if game.completedAt == None:
                continue

            if game.winner == winningTeam.id:
                winnerScores += "<b>{}</b> &emsp;".format(
                    game.getFormattedWinnerScore())
                loserScores += "{} &emsp;".format(
                    game.getFormattedLoserScore())
            else:
                winnerScores += "{} &emsp;".format(
                    game.getFormattedLoserScore())
                loserScores += "<b>{}</b> &emsp;".format(
                    game.getFormattedWinnerScore())

        elo = "({}, {}{})"
        winnerElo = leaderboardService.eloResult(match.officeId, match.id,
                                                 winnerPlayer.id)
        loserElo = leaderboardService.eloResult(match.officeId, match.id,
                                                losingPlayer.id)

        message += winnerScores

        if winnerElo != None:
            message += elo.format(int(round(winnerElo["current"])),
                                  "+" if winnerElo["change"] > 0 else "",
                                  int(round(winnerElo["change"])))

        message += loserScores

        if loserElo != None:
            message += elo.format(int(round(loserElo["current"])),
                                  "+" if loserElo["change"] > 0 else "",
                                  int(round(loserElo["change"])))

        message += '<br><a href="{}leaderboard/singles">Leaderboard Standings</a>'.format(
            request.url_root)

        notifications.send(message)
Пример #16
0
def create(matchId):
	hasErrors = playerForm.validate(None, session["office"]["id"], request.form)

	if hasErrors:
		player = playerService.new()
		playerForm.load(player, request.form)
		return render_template("players/new.html", player = player, matchId = matchId), 400
	else:
		player = playerService.create(session["office"]["id"], request.form)

		uploaded, avatar, extension = util.uploadAvatar(player)
		if uploaded:
			playerService.avatar(player, avatar, extension)

		flash("Player '{}' has been successfully created.".format(player.name), "success")

		message = "<b>{}</b> has joined ping pong. Please consider adding them to the ping pong chat group.".format(player.name)
		notifications.send(message, session["office"]["id"])

		if matchId != None:
			return redirect(url_for("matchController.players", id = matchId))
		else:
			return redirect(url_for("playerController.index"))
Пример #17
0
	def sendWinningMessage(self, match, winningTeam, winningSets, losingTeam, losingSets):
		winnerPlayer = winningTeam.players[0]
		losingPlayer = losingTeam.players[0]

		message = "<b>{}</b> defeated {}, {} - {}".format(winnerPlayer.name, losingPlayer.name, winningSets, losingSets)

		winnerScores = "\n"
		loserScores = "\n"

		for game in match.games:
			if game.completedAt == None:
				continue

			if game.winner == winningTeam.id:
				winnerScores += "<b>{}</b> \t".format(game.getFormattedWinnerScore())
				loserScores += "{} \t".format(game.getFormattedLoserScore())
			else:
				winnerScores += "{} \t".format(game.getFormattedLoserScore())
				loserScores += "<b>{}</b> \t".format(game.getFormattedWinnerScore())

		elo = "({}, {}{})"
		winnerElo = leaderboardService.eloResult(match.officeId, match.id, winnerPlayer.id)
		loserElo = leaderboardService.eloResult(match.officeId, match.id, losingPlayer.id)

		message += winnerScores

		if winnerElo != None:
			message += elo.format(int(round(winnerElo["current"])), "+" if winnerElo["change"] > 0 else "", int(round(winnerElo["change"])))

		message += loserScores

		if loserElo != None:
			message += elo.format(int(round(loserElo["current"])), "+" if loserElo["change"] > 0 else "", int(round(loserElo["change"])))

		message += '\n<a href="{}leaderboard/singles">Leaderboard Standings</a>'.format(request.url_root)

		notifications.send(message, match.officeId)
Пример #18
0
    def sendWinningMessage(self, match, winningTeam, winningSets, losingTeam,
                           losingSets):
        winnerPlayer1 = winningTeam.players[0]
        winnerPlayer2 = winningTeam.players[1]
        losingPlayer1 = losingTeam.players[0]
        losingPlayer2 = losingTeam.players[1]

        message = "<b>{}</b> and <b>{}</b> defeated {} and {}, {} - {}".format(
            winnerPlayer1.name, winnerPlayer2.name, losingPlayer1.name,
            losingPlayer2.name, winningSets, losingSets)

        winnerScores = "<br>"
        loserScores = "<br>"

        for game in match.games:
            if game.completedAt == None:
                continue

            if game.winner == winningTeam.id:
                winnerScores += "<b>{}</b> &emsp;".format(
                    game.getFormattedWinnerScore())
                loserScores += "{} &emsp;".format(
                    game.getFormattedLoserScore())
            else:
                winnerScores += "{} &emsp;".format(
                    game.getFormattedLoserScore())
                loserScores += "<b>{}</b> &emsp;".format(
                    game.getFormattedWinnerScore())

        message += winnerScores
        message += loserScores

        message += '<br><a href="{}leaderboard/doubles">Leaderboard Standings</a>'.format(
            request.url_root)

        notifications.send(message)