Ejemplo n.º 1
0
    def get(self, request, *args, **kwargs):
        try:
            if not jje_standings_functions.check_if_standings():
                raise AssertionError

            wc_id = self.kwargs.get("pk")
            player = WaiverClaim.objects.get(id=wc_id)
            # asserting the claim is still active
            if not player.active_claim():
                messages.add_message(request, messages.WARNING,
                                     "Waiver claim is no longer active")
                assert player.active_claim()

            # want to assert that the team holding the claim is in the overclaim list
            guid = self.request.user.usertoken_set.first().user_guid
            user_teams = jje_main_functions.get_users_teams_waivers(guid)
            team_ids = [t['id'] for t in user_teams]
            # these ids are the teams that the user CAN overclaim
            overclaim_teams = jje_standings_functions.get_overclaim_teams(
                team_ids)
            if not player.yahoo_team.id in overclaim_teams:
                messages.add_message(request, messages.WARNING,
                                     "Claim team is lower ranked then you")
                raise AssertionError

            return super(OverclaimCreate, self).get(request, *args, **kwargs)
        except Exception as e:
            return redirect(reverse("waivers_index"))
Ejemplo n.º 2
0
 def get_rank(self, request, player):
     # get the id of the claim team
     team_id = player.yahoo_team.id
     # get the overclaim ids for current claim holder that team
     overclaim_teams = jje_standings_functions.get_overclaim_teams([team_id])
     overclaim_teams.append(team_id)
     # exclude any teams that are in the overclaim list
     guid = self.request.user.usertoken_set.first().user_guid
     user_teams = jje_main_functions.get_users_teams_ids(guid)
     # filter list of team ids that can overclaim
     user_overclaim_teams = [x for x in user_teams if x not in overclaim_teams]
     team_qs = jje_main_functions.get_teams_qs(user_overclaim_teams)
     return team_qs
Ejemplo n.º 3
0
    def get_context_data(self, **kwargs):
        oauth_display = jje_waiver_functions.show_oauth_link(self.request)

        context = super(IndexView, self).get_context_data(**kwargs)

        user_teams = []
        overclaim_teams = []
        if (not self.request.user.is_anonymous) and (oauth_display is False):
            # query for users teams via api using GUID
            guid = self.request.user.usertoken_set.first().user_guid
            user_teams = jje_main_functions.get_users_teams_ids(guid)
            # these ids are the teams that the user CAN overclaim
            overclaim_teams = jje_standings_functions.get_overclaim_teams(user_teams)

        context['user_team_ids'] = user_teams
        context['overclaim_ids'] = overclaim_teams
        context['show_oauth'] = oauth_display
        return context