def post( self, request ): form = Portfolio.create_form( request.POST ) if form.is_valid(): data = form.cleaned_data data['user'] = User.objects.get( id=request.user.id ) results = Portfolio.create( data ) return redirect( '/portfolio/{}/manage'.format( results.slug ) ) request.context_dict[ 'form' ] = form return render( request, 'portfolio/create.html', request.context_dict )
def post(self, request): form = GameCreateForm( request.POST ) if form.is_valid(): form_data = form.cleaned_data form_data['user'] = User.objects.get( id=request.user.id ) form_data['balance'] = form_data['start_balance'] portfolio_data = { 'title': "game_{}".format( form_data['name'] ), 'description': "Portfolio for game play.", 'user': form_data['user'] } portfolio = Portfolio.create( portfolio_data ) form_data['portfolio_id'] = portfolio.id game = Whole_Game.objects.create( **form_data ) return redirect( '/game/{}/start'.format( game.id ) ) else: request.context_dict['form'] = form return render( request, 'game/index.html', request.context_dict )