def fishspeed_bonus(request):
if request.GET.get('button') == 'button':
a = 1
else:
a = 0
return render(request, 'fishspeed/bonus.html',{
'a': a,
})
{% if a == 0 %}
<button type="submit" class="btn btn-blue btn-righ" name="button" value="button">GET BONUS</button>
{% endif %}
{% if a == 1 %}
<b class="my">Next bonus after 24 hours</b>
{% endif %}
</center>
import datetime
def fishspeed_bonus(request):
now = datetime.datetime.now()
bonus_time = request.session.get("bonus_time")
if bonus_time:
delta = now - datetime.datetime.fromisoformat(bonus_time)
if delta.days > 0:
bonus = True
else:
bonus = False
else:
request.session['bonus_time'] = datetime.datetime.now().isoformat()
bonus = True
return render(request, 'fishspeed/bonus.html', {"bonus": bonus})
{% if bonus %}
<button type="submit" class="btn btn-blue btn-righ" name="button" value="button">GET BONUS</button>
{% else %}
<b class="my">Next bonus after 24 hours</b>
{% endif %}
</center>