Django: can I block new entries until one is completed?
You have to create some kind of lock that indicates that the price is currently assigned to a user and that prevents other users from going to the same form.
You could create a random token, store it in the DB (or redis), and add it a hidden field to the form. I suggest you also add an expiration date.
As long as a valid token exists, no other user can access the form. When user 1 submits the form, you check that it contains a valid token.
Sorry for the vague question, here's what's going on:
I will be giving away "win codes" to people. My django app is written so that the first one to enter a valid code XX hours after the last win will again be a winner.
If the user is a winner he will be redirected to a page with a form to claim his prize.
1) User enters code
2) I check the datetime of the last win
3) If it's a winner again, go to the form page
The problem is: if someone wins and then another person enters a code before the first one has filled in the form to claim the prize, the second one will get to that form as well because the last winner is still more than XX hours ago.
How can I avoid this? Can I somehow check if someone already made it to that form?