def post(self, request, year): 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] buy_in = request.POST['buy_in'] name = request.POST['name'] new_league = League(name=name, buy_in = buy_in, commissioner = active_user, nfl_year=year) new_league.slug = slugify(new_league.name) new_league.save() new_league_dict = new_league.to_json() if new_league: return JsonResponse({'Success':True, 'new_league_dict':new_league_dict}) return JsonResponse({'Success':False})
def post(self, request): if not request.user.is_anonymous(): active_user_id = request.user.id league_form = LeagueForm(request.POST,request.FILES) if league_form.is_valid(): name = league_form.data.get('name') buy_in = league_form.data.get('buy_in') active_user = User.objects.filter(id=active_user_id)[0] if league_form.files.get('marquee'): marquee = league_form.files.get('marquee') new_league = League(name=name, buy_in = buy_in, commissioner = active_user, marquee=marquee) else: new_league = League(name=name, buy_in = buy_in, commissioner = active_user) new_league.slug = slugify(new_league.name) new_league.save() if new_league: return redirect('interface:league_view', league_slug = new_league.slug) return redirect('interface:create_league') return redirect('interface:login')