I recall the updated time time from database. I want to disable the button 15 minutes after the updated time and keep disable even after reload or refresh the page.
<tr>
<td class="table-user-profile-attribute">
{% trans 'Updated time' %}
</td>
<td>{{ app.updated_time | default:_('Not provided.') }}
</td>
</tr>
<button id="myButton"
style="border-radius: 50px; width: 130px;" type="button"
class="btn btn-primary btn-cons m-b-10 pull-right">
<i class="fa fa-download"></i> <span
class="bold">{% trans "Download" %}</span>
</button>
I have tried this in javascript. But this not compared the time with the updated time in the database.
<script>
$(document).ready(function(){
var limit = 15*60*1000; // the time limit (in milliseconds) for the disable function
var timer = setTimeout(disableMyButton, limit);
function disableMyButton(){
$('#myButton').prop('hidden', true);
localStorage.setItem("isMyButtonDisabled", "true");
}
if(localStorage.getItem("isMyButtonDisabled") == "true"){
$('#myButton').prop('hidden', true);
window.clearTimeout(timer);
}
});
</script>
This is my model of application.
class Application(models.Model):
created_at = models.DateTimeField(auto_now_add='True')
updated_at = models.DateTimeField(
auto_now='True', blank='True', null='True')