def get(self, request, *a, **k): id = int(k.get("pk")) claim_obj = WaiverClaim.objects.filter(id=id).first() if claim_obj is None or not claim_obj.active_claim(): return redirect(reverse("waivers_index")) guid = self.request.user.usertoken_set.first().user_guid user_teams = jje_main_functions.get_users_teams_ids(guid) if not claim_obj.yahoo_team.id in user_teams: return redirect(reverse("waivers_index")) return super(CancelClaimView, self).get(request, *a, **k)
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
def post(self, request, *args, **kwargs): claim_id = kwargs.get("pk") claim = get_object_or_404(WaiverClaim, id=claim_id) guid = self.request.user.usertoken_set.first().user_guid user_teams = jje_main_functions.get_users_teams_ids(guid) if not claim.yahoo_team.id in user_teams: return redirect(reverse('waivers_index')) claim.cancelled = True claim.save() messages.add_message(self.request, messages.INFO, "Claim cancelled") email_functions.cancel_email(claim, request) return redirect(reverse('waivers_index'))
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