Exemple #1
0
  def get(self):
    tournament = Tournament.get(self.request.get("key"))
    member_count = TournamentMembership.all().ancestor(tournament).count()

    html = ["<input type='hidden' name='tournament_key' value='%s' />" % tournament.key()]
    html.append("<p>Provide each team with a unique seed ranging from 1 to %s:</p>"
        % member_count)
    for member in TournamentMembership.all().ancestor(tournament):
      html.append("%s: <input type='text' name='seed_%s'><br />" % (
        member.team.key().name(), member.key()))

    self.response.out.write("\n".join(html))
Exemple #2
0
    def post(self):
        tournament = Tournament.get(self.request.get("tournament_key"))
        member_count = TournamentMembership.all().ancestor(tournament).count()

        for arg in self.request.arguments():
            if arg.startswith("seed_"):
                member_key = arg.split("_")[1]
                member = TournamentMembership.get(member_key)

                seed = int(self.request.get(arg)) - 1
                assert seed >= 0 and seed < member_count
                member.seed = seed
                member.put()

        tournament.schedule()
        views.Tournaments.clear()
Exemple #3
0
    def get(self):
        tournament = Tournament.get(self.request.get("key"))
        member_count = TournamentMembership.all().ancestor(tournament).count()

        html = [
            "<input type='hidden' name='tournament_key' value='%s' />" %
            tournament.key()
        ]
        html.append(
            "<p>Provide each team with a unique seed ranging from 1 to %s:</p>"
            % member_count)
        for member in TournamentMembership.all().ancestor(tournament):
            html.append("%s: <input type='text' name='seed_%s'><br />" %
                        (member.team.key().name(), member.key()))

        self.response.out.write("\n".join(html))
Exemple #4
0
  def post(self):
    tournament = Tournament.get(self.request.get("tournament_key"))
    member_count = TournamentMembership.all().ancestor(tournament).count()

    for arg in self.request.arguments():
      if arg.startswith("seed_"):
        member_key = arg.split("_")[1]
        member = TournamentMembership.get(member_key)

        seed = int(self.request.get(arg)) - 1
        assert seed >= 0 and seed < member_count
        member.seed = seed
        member.put()

    tournament.schedule()
    views.Tournaments.clear()
Exemple #5
0
  def post(self):
    tournament_key = db.Key(self.request.get("tournament_key"))

    db.delete(TournamentMembership.all(keys_only=True).ancestor(tournament_key))
    db.delete(TournamentMatchUp.all(keys_only=True).ancestor(tournament_key))
    db.delete(TournamentMatchUpMembership.all(keys_only=True).ancestor(tournament_key))
    db.delete(tournament_key)
    views.Tournaments.clear()
Exemple #6
0
    def post(self):
        tournament = Tournament.get(self.request.get("tournament_key"))
        team = Team.get(self.request.get("team_key"))

        member_count = TournamentMembership.all().ancestor(tournament).count()

        if member_count < tournament.max_enrollment:
            TournamentMembership(parent=tournament, team=team,
                                 active=True).put()
            #Unretire team if retired.
            if team.retired:
                misc.unretire_team(team)

            if (member_count + 1 == tournament.max_enrollment
                    and tournament.seed_by != "Custom"):
                tournament.schedule()

        views.Tournaments.clear()
Exemple #7
0
    def post(self):
        tournament_key = db.Key(self.request.get("tournament_key"))

        db.delete(
            TournamentMembership.all(keys_only=True).ancestor(tournament_key))
        db.delete(
            TournamentMatchUp.all(keys_only=True).ancestor(tournament_key))
        db.delete(
            TournamentMatchUpMembership.all(
                keys_only=True).ancestor(tournament_key))
        db.delete(tournament_key)
        views.Tournaments.clear()
Exemple #8
0
  def post(self):
    user = users.get_current_user()
    coach = Coach.all().filter("user ="******"tournament_key"))
    memberships = [m for m in TournamentMembership.all().ancestor(tournament) if
        m.team.coach.key() == coach.key()]

    membership = memberships[0]
    membership.delete()

    views.Tournaments.clear()
Exemple #9
0
    def post(self):
        user = users.get_current_user()
        coach = Coach.all().filter("user ="******"tournament_key"))
        memberships = [
            m for m in TournamentMembership.all().ancestor(tournament)
            if m.team.coach.key() == coach.key()
        ]

        membership = memberships[0]
        membership.delete()

        views.Tournaments.clear()
Exemple #10
0
  def post(self):
    tournament = Tournament.get(self.request.get("tournament_key"))
    team       = Team.get(self.request.get("team_key"))

    member_count = TournamentMembership.all().ancestor(tournament).count()

    if member_count < tournament.max_enrollment:
      TournamentMembership(parent=tournament, team=team, active=True).put()
      #Unretire team if retired.
      if team.retired:
        misc.unretire_team(team)
        
      if (member_count + 1 == tournament.max_enrollment and
          tournament.seed_by != "Custom"):
        tournament.schedule()


    views.Tournaments.clear()
Exemple #11
0
 def final_enrollment_getter(tournament):
   return TournamentMembership.all().ancestor(tournament).count()
Exemple #12
0
 def enrollment_getter(tournament):
   return "%s/%s" % (
     TournamentMembership.all().ancestor(tournament).count(),
     tournament.max_enrollment)
    def get(self):

        # check for a cached version
        #--------------------------------------------------------------------#

        tournament = Tournament.get_by_key_name(
            self.request.get("tournament_key_name"))

        if tournament.started:
            if self.emit(self.response.out, tournament.key()):
                return

        # not cached or evicted from cache; regenerate
        #--------------------------------------------------------------------#

        teams = [
            m.team for m in TournamentMembership.all().ancestor(tournament)
        ]

        races_allowed = []
        for race_key in tournament.races_allowed:
            races_allowed.append(Race.get(race_key))

        if not tournament.started:
            user = users.get_current_user()
            coach = None
            if user:
                coach = Coach.all().filter("user ="******":")]

            # pixel settings
            width_unit = 530 / round
            match_width = 200

            # compute data for each match_up
            match_up_data = []
            for match_up, child in match_ups:
                round, seed = [
                    int(x) for x in match_up.key().name().split(":")
                ]
                position_left = round * width_unit

                team_data = []
                for i, mm in enumerate(
                        match_up.tournamentmatchupmembership_set.order(
                            "__key__")):

                    data = {}
                    data["name"] = "_" * 25
                    data["seed"] = ""
                    data["score"] = ""

                    if mm.membership:
                        team = mm.membership.team
                        if team.matches:
                            data[
                                "name"] = "<a rel='tournament_teams' href='%s'>%s</a>" % (
                                    team.get_box_href(), team.key().name())
                        else:
                            data["name"] = "<b title='%s'>%s</b>" % (
                                team.coach.key().name(), team.key().name())
                        data["seed"] = mm.membership.seed + 1

                        if match_up.match:
                            team_record = match_up.match.get_team_records_query(
                            ).filter("team =", mm.membership.team.key()).get()
                            score = str(team_record.tds_for)
                            if (match_up.winner.key() == mm.membership.key()
                                    and
                                (team_record.tds_for == team_record.tds_against
                                 or match_up.match.disconnect)):
                                score += "*"

                            data["score"] = "<b>%s</b>" % score

                        elif match_up.winner:
                            # if there was a winner but no match then it was a forfeit
                            if match_up.winner.key() == mm.membership.key():
                                data["score"] = "&nbsp;"
                            else:
                                data["score"] = "<b><i>F</i></b>"

                    team_data.append(data)

                if child == 0:
                    arrow_class = "down_arrow"
                elif child == 1:
                    arrow_class = "up_arrow"
                else:
                    arrow_class = None

                match_data = match_up.match

                end_this_match = width_unit * round + match_width
                mid_next_match = width_unit * (round + 1) + match_width / 2
                arrow_width = mid_next_match - end_this_match

                match_up_data.append((round, team_data, position_left,
                                      arrow_width, arrow_class, match_data))

        # render and update
        #--------------------------------------------------------------------#

        tournament_box = misc.render('tournament_box.html', locals())
        if tournament.started:
            self.update(tournament_box, tournament.key())

        self.response.out.write(tournament_box)
Exemple #14
0
    def post(self):
        membership = TournamentMembership.get(
            self.request.get("membership_key"))
        membership.delete()

        views.Tournaments.clear()
Exemple #15
0
  def post(self):
    membership = TournamentMembership.get(self.request.get("membership_key"))
    membership.delete()

    views.Tournaments.clear()