Hi im having a problems getting my variable raffle to return only the raffles i asked for.
check my codes
utils.py
for raffle in random.sample(raffles, raffle_count):
print “Assigning {0} to {1}”.format(raffle, user)
msg = Message(‘Raffle assigned’, sender = ‘osman.soloking009@outlook.com’, recipients = [user.email])
msg.body = myRaffle = “Assigning {0} to {1}”.format(raffle, user)
mail.send(msg)
raffle.user = user
db.session.commit()
return raffles
app.py
@app.route(’/’, methods=[‘GET’, ‘POST’])
def home():
form = RaffleForm(request.form)
raffle = None # here
if request.method == ‘POST’ and form.validate():
email = form.email.data
# check if user exists
user = User.query.filter_by(email=email).all()
if not user:
user = User(email=email)
db.session.add(user)
else:
user = user[0]
# assign required raffles to user
raffle = assign_raffles_to_user(form.raffle_count.data, user)
return render_template('success.html', raffle=raffle)
return render_template('home.html', form=form)