Witam mam pytanie. chce zrobic aby po kliknieciu na przycisk zostal on zablokowany dla danego uzytkownika poki sie nie wypisze troche nie mam pomyslu jak to zrobic . Kod :
try:
sign.user = user
sign.subject = subject
finally:
if subject.actual_space < subject.space:
subject.actual_space = subject.actual_space + 1
subject.save()
sign.save()
else:
pass
----------------------------------------------
{% for subject in subjects %}
<tbody>
<td>{{ subject.name }}</td>
<td>{{ subject.begin_at }}</td>
<td>{{ subject.end_at }}</td>
<td> {{ subject.actual_space }}/{{ subject.space }}</td>
<td><button class="btn-success subjectButton" day="monday" subjectId="{{ subject.id }}"> Zapisz </button><br></td>
</tbody>
{% endfor %}
</table>
<script>
$(document).ready(function () {
$('.subjectButton').click(function(){
var day = $(this).attr('day');
var subjectId = $(this).attr('subjectId');
var button = $(this);
button.prop('disabled', true);
button.text("Zapisano!");
console.log('dzien: '+day+', id: '+subjectId)
$.ajax({
url: 'http://localhost:8000/sign/'+day+'/signme/'+subjectId
}).done(function(data){
console.log('subject send');
console.log('recived data: '+ JSON.stringify(data));
});
})
})