Compare commits
3 Commits
8396b256c0
...
ca629fd1fb
Author | SHA1 | Date |
---|---|---|
Gregory Trullemans | ca629fd1fb | |
Gregory Trullemans | 05e130355a | |
Gregory Trullemans | 9a60aac062 |
|
@ -52,13 +52,13 @@
|
|||
<script type="text/javascript" >
|
||||
$(document).ready(function() {
|
||||
var number_of_jump = {{ number_of_jump }};
|
||||
var score_type = {{ score_type }};
|
||||
var is_tof_score = {{ score_type }};
|
||||
$('#jump_score').focus();
|
||||
|
||||
function send_score_to_database(score)
|
||||
{
|
||||
var jump_value = score / 100;
|
||||
if(score_type && score.length >= 4) // tof
|
||||
if(!is_tof_score && score.length >= 4) // tof
|
||||
var jump_value = jump_value / 10;
|
||||
|
||||
$.ajax({
|
||||
|
@ -94,7 +94,7 @@
|
|||
|
||||
$('#jump_score').keyup(function(){
|
||||
var score = $('#jump_score').val();
|
||||
if((score_type && score.length >= 4) || (!score_type && score.length >= 3))
|
||||
if((!is_tof_score && score.length >= 3) || (is_tof_score && score.length >= 4))
|
||||
send_score_to_database(score);
|
||||
});
|
||||
|
||||
|
|
|
@ -128,21 +128,31 @@ def remove_jump_chrono_value(request):
|
|||
@require_http_methods(["POST"])
|
||||
def add_jump_chrono_value(request):
|
||||
"""
|
||||
Recoit trois informations permettant d'ajouter le chrono d'un saut à un chrono.
|
||||
Receives three pieces of information to add the time of a jump to a <Chrono> record.
|
||||
"""
|
||||
chrono_id = request.POST.get("chrono_id", None)
|
||||
order = request.POST.get("order", None)
|
||||
value = request.POST.get("value", None)
|
||||
chrono_id = request.POST.get("chrono_id")
|
||||
order = request.POST.get("order")
|
||||
value = request.POST.get("value")
|
||||
|
||||
# Validate required parameters
|
||||
if not chrono_id or not order or value is None:
|
||||
return HttpResponse(400, "Missing required parameters.")
|
||||
|
||||
# Retrieve the Chrono object or return 404 if not found
|
||||
chrono = get_object_or_404(Chrono, pk=chrono_id)
|
||||
|
||||
# Attempt to create a new ChronoDetails record
|
||||
row, created = ChronoDetails.objects.get_or_create(
|
||||
# chrono=chrono, order=order, defaults={'value': value}
|
||||
chrono=chrono, order=order, value=value
|
||||
)
|
||||
|
||||
# Check if the record was created or just retrieved
|
||||
if created:
|
||||
return HttpResponse(200, (row, created)) # devrait être un 201
|
||||
|
||||
return HttpResponse(400, (row, created))
|
||||
return HttpResponse(201, f"New chrono detail added: {row}") # 201 Created
|
||||
else:
|
||||
# If the record was not created, it means it already exists with the same order and chrono
|
||||
return HttpResponse(409, f"Chrono detail already exists: {row}") # 409 Conflict
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
</div>
|
||||
<div class="card-footer pt-0 row">
|
||||
{% if ghr_list %}
|
||||
<div class="col-md-6 text-muted pt-0">
|
||||
<div class="col-md-6 pt-0">
|
||||
{% if has_routine_1 %}
|
||||
<a href="#">
|
||||
<button type="submit" value="list" class="btn btn-icon btn-success mr-2 action-button"
|
||||
|
@ -81,7 +81,8 @@
|
|||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="col-md-6 text-right pt-0 pr-2">
|
||||
{% if has_routine_1 %}
|
||||
<a href="#">
|
||||
<button type="submit" value="list" class="btn btn-icon btn-danger mr-2 action-button"
|
||||
|
|
Loading…
Reference in New Issue