示例#1
0
 def post(self, request):
     week_to_complete = request.POST.get('week')
     week_slug = 'week-{}'.format(week_to_complete)
     week = int(week_slug.strip('week-'))
     r = requests.get(os.environ.get('fballAPI') + week_slug + '/matchups/')
     winners_list = r.json().get('winning_teams')
     all_teams = Team.objects.all()
     for team in all_teams:
         get_weekly_record(int(week_to_complete), team)
         pick_list_dict = tally_weekly_results(int(week_to_complete), team, winners_list)
     return redirect('interface:week_view', week_slug=week_slug)
示例#2
0
    def get(self, request, year, week, team_slug):

        if request.session.get('_auth_user_id'):


            active_user_id = int(request.session.get('_auth_user_id'))
            active_user = User.objects.filter(id=active_user_id)[0]
            week_int = int(week.strip('week-'))

            r = requests.get(os.environ.get('fballAPI')  + '/' + week + '/winners/')
            string_dict = r.content.decode("utf-8")
            winners_dict = json.loads(string_dict)

            current_team = Team.objects.filter(slug=team_slug)[0]
            team_dict = current_team.to_json()

            current_team_weekly_record_dict = get_weekly_record(week_int,current_team)

            pick_list_dict = tally_weekly_results(week_int, current_team, winners_dict)

            return JsonResponse({'current_team_weekly_record_dict':current_team_weekly_record_dict, 'team_dict':team_dict, 'winners_dict': winners_dict,'pick_list_dict':pick_list_dict})