Lot of modifications

This commit is contained in:
Gregory Trullemans 2024-04-29 12:55:05 +02:00
parent aeb07ccb01
commit cfef189b1c
11 changed files with 145 additions and 74 deletions

View File

@ -38,10 +38,6 @@
<!-- CSS Files -->
<link href="{% static "css/black-dashboard.css" %}" rel="stylesheet" />
<!-- Maps by mapbox -->
<script src='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.css' rel='stylesheet' />
<!-- Core JS Files -->
<script src="{% static "js/core/jquery_3.7.1.min.js" %}"></script>
<script src="{% static "js/core/popper.min.js" %}"></script>

View File

@ -20,7 +20,7 @@
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet" />
<!-- Font Awesome Pro -->
<link href="{% static "css/gymnast_report.css" %}" rel="stylesheet" />
<link href="{% static "css/a4_paper.css" %}" rel="stylesheet" />
<link href="{% static "css/font_awesome_all_5.15.3.css" %}" rel="stylesheet" />
<link href="{% static "css/black-dashboard_report.css" %}" rel="stylesheet" />
</head>

View File

@ -300,7 +300,7 @@ def generate_best_straightjump_listing(request):
HTML(string=html, base_url=request.build_absolute_uri()).write_pdf(
response,
stylesheets=[
CSS(settings.STATICFILES_DIRS[0] + "/css/gymnast_report.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/a4_paper.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/black-dashboard_report.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/font_awesome_all_5.15.3.css"),
],

View File

@ -92,6 +92,10 @@
</div>
</div>
<div class="form-group text-center" id="informations_needed">
<p class="text-danger"><b>Details required !</b></p>
</div>
<div class="form-group row ">
<label for="id_information" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Informations</label>
</div>
@ -101,7 +105,7 @@
</div>
</div>
<div class="form-group text-center">
<div class="form-group text-center" id="div_submit">
<input type="submit" value="{% if intensity_id %}Update{% else %}Add{% endif %}"
class="btn btn-warning" />
</div>
@ -115,53 +119,123 @@
{% block footerscript %}
<script type="text/javascript">
$(function () {
$("#informations_needed").hide();
blackDashboard.initDateTimePicker();
});
const csrf_token = "{{ csrf_token|escapejs }}";
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
function is_lower_than(number, limit) {
if(number < limit)
return true;
$('#id_club_related').autocomplete({
source: function(request, response) {
$.ajax({
url: club_lookup,
method: "POST",
data: {
pattern: $('#id_club_related').val(),
csrfmiddlewaretoken: csrf_token
},
dataType: "json",
success: function(data) {
if(data.length != 0) {
response($.map(data, function(item) {
return {
label: item.Name,
value: item.Name,
clubid: item.ID
}
}))
} else {
response([{ label: 'No result found.', value: '' }]);
};
},
return false;
}
error: function (exception) {
console.log(exception);
}
});
},
minLength: 3,
select: function (event, ui) {
$($(this).data('ref')).val(ui.item.clubid);
},
{% if request.session.template == 0 %}
classes: {
"ui-widget-content": "custom_autocomplete_ul",
"ui-autocomplete": "custom_autocomplete_ul",
"ui-menu-item-wrapper": "custom_autocomplete_li",
"ui-menu-item": "custom_autocomplete_li",
},
{% endif %}
function is_greater_than(number, limit) {
if(number >= limit)
return true;
return false;
}
function is_informations_needed() {
var time_quality = $('#id_theorical_time').val() / $('#id_time').val();
alert(time_quality);
var diff_quality = $('#id_difficulty_asked').val() / $('#id_difficulty').val();
var skill_quality = $('#id_quantity_of_skill_asked').val() / $('#id_quantity_of_skils').val();
var passe_quality = $('#id_number_of_passes_asked').val() / $('#id_number_of_passes').val();
var limit = 0.7;
var test = is_lower_than(time_quality, limit);
test = test || is_lower_than(diff_quality, limit);
test = test || is_lower_than(skill_quality, limit);
test = test || is_lower_than(passe_quality, limit);
var limit = 1.1;
test = test || is_greater_than(time_quality, limit);
test = test || is_greater_than(diff_quality, limit);
test = test || is_greater_than(skill_quality, limit);
test = test || is_greater_than(passe_quality, limit);
var average_quality = (time_quality + (skill_quality * 2) + (passe_quality * 3) + (diff_quality * 4)) / 10;
test = test || is_lower_than(average_quality, 0.85);
test = test || is_greater_than(average_quality, 1.05);
return test
}
function is_information_field_too_short() {
information_length = $('#id_informations').val().length
if(isNaN(information_length) || information_length < 15) {
alert("Informations too shorts !");
return true;
} else
return false;
};
$('#id_time, #id_theorical_time, #id_difficulty, #id_difficulty_asked, #id_quantity_of_skill, #id_quantity_of_skill_asked, #id_number_of_passes, #id_number_of_passes_asked').keyup(function(){
if(is_informations_needed() && is_information_field_too_short()) {
$("#informations_needed").show();
$("#div_submit").hide();
} else {
$("#informations_needed").hide();
$("#div_submit").show();
}
});
$('#id_informations').on('keyup', function(){
if(is_informations_needed() && is_information_field_too_short()) {
$("#informations_needed").show();
$("#div_submit").hide();
} else {
$("#informations_needed").hide();
$("#div_submit").show();
}
});
const csrf_token = "{{ csrf_token|escapejs }}";
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
$('#id_club_related').autocomplete({
source: function(request, response) {
$.ajax({
url: club_lookup,
method: "POST",
data: {
pattern: $('#id_club_related').val(),
csrfmiddlewaretoken: csrf_token
},
dataType: "json",
success: function(data) {
if(data.length != 0) {
response($.map(data, function(item) {
return {
label: item.Name,
value: item.Name,
clubid: item.ID
}
}))
} else {
response([{ label: 'No result found.', value: '' }]);
};
},
error: function (exception) {
console.log(exception);
}
});
},
minLength: 3,
select: function (event, ui) {
$($(this).data('ref')).val(ui.item.clubid);
},
{% if request.session.template == 0 %}
classes: {
"ui-widget-content": "custom_autocomplete_ul",
"ui-autocomplete": "custom_autocomplete_ul",
"ui-menu-item-wrapper": "custom_autocomplete_li",
"ui-menu-item": "custom_autocomplete_li",
},
{% endif %}
});
});
</script>
<script src="{% static "js/template_users/datepicker_maxdate_today.js" %}"></script>

View File

@ -20,7 +20,7 @@
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet" />
<!-- Font Awesome Pro -->
<link href="{% static "css/gymnast_report.css" %}" rel="stylesheet" />
<link href="{% static "css/a4_paper.css" %}" rel="stylesheet" />
<link href="{% static "css/font_awesome_all_5.15.3.css" %}" rel="stylesheet" />
<link href="{% static "css/black-dashboard_report.css" %}" rel="stylesheet" />
</head>

View File

@ -17,10 +17,9 @@
<title>{{ gymnast.first_name }} {{ gymnast.last_name }}</title>
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet" />
<!-- Font Awesome Pro -->
<link href="{% static "css/gymnast_report.css" %}" rel="stylesheet" />
<link href="{% static "css/a4_paper.css" %}" rel="stylesheet" />
<link href="{% static "css/font_awesome_all_5.15.3.css" %}" rel="stylesheet" />
<link href="{% static "css/black-dashboard_report.css" %}" rel="stylesheet" />
</head>

View File

@ -20,7 +20,7 @@
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet" />
<!-- Font Awesome Pro -->
<link href="{% static "css/gymnast_report.css" %}" rel="stylesheet" />
<link href="{% static "css/a4_paper.css" %}" rel="stylesheet" />
<link href="{% static "css/font_awesome_all_5.15.3.css" %}" rel="stylesheet" />
<link href="{% static "css/black-dashboard_report.css" %}" rel="stylesheet" />
</head>

View File

@ -20,7 +20,7 @@
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet" />
<!-- Font Awesome Pro -->
<link href="{% static "css/gymnast_report.css" %}" rel="stylesheet" />
<link href="{% static "css/a4_paper.css" %}" rel="stylesheet" />
<link href="{% static "css/font_awesome_all_5.15.3.css" %}" rel="stylesheet" />
<link href="{% static "css/black-dashboard_report.css" %}" rel="stylesheet" />
</head>

View File

@ -753,25 +753,25 @@ def generate_report_for_period(
"notes": notes,
}
return render(request, "gymnasts/reports/report_periodical.html", context)
# return render(request, "gymnasts/reports/report_periodical.html", context)
# response = HttpResponse(content_type="application/pdf")
# response[
# "Content-Disposition"
# ] = f"attachment; filename={gymnast.last_name}_{gymnast.first_name}_{period}-report_{date_begin}_{date_end}.pdf" # pylint: disable=line-too-long
response = HttpResponse(content_type="application/pdf")
response[
"Content-Disposition"
] = f"attachment; filename={gymnast.last_name}_{gymnast.first_name}_{period}-report_{date_begin}_{date_end}.pdf" # pylint: disable=line-too-long
# html = render_to_string("gymnasts/reports/report_periodical.html", context)
html = render_to_string("gymnasts/reports/report_periodical.html", context)
# # font_config = FontConfiguration()
# HTML(string=html, base_url=request.build_absolute_uri()).write_pdf(
# response,
# stylesheets=[
# CSS(settings.STATICFILES_DIRS[0] + "/css/gymnast_report.css"),
# CSS(settings.STATICFILES_DIRS[0] + "/css/black-dashboard_report.css"),
# CSS(settings.STATICFILES_DIRS[0] + "/css/font_awesome_all_5.15.3.css"),
# ],
# ) # , font_config=font_config)
# return response
# font_config = FontConfiguration()
HTML(string=html, base_url=request.build_absolute_uri()).write_pdf(
response,
stylesheets=[
CSS(settings.STATICFILES_DIRS[0] + "/css/a4_paper.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/black-dashboard_report.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/font_awesome_all_5.15.3.css"),
],
) # , font_config=font_config)
return response
@login_required
@ -902,7 +902,7 @@ def generate_report_week_comparison(
# HTML(string=html, base_url=request.build_absolute_uri()).write_pdf(
# response,
# stylesheets=[
# CSS(settings.STATICFILES_DIRS[0] + "/css/gymnast_report.css"),
# CSS(settings.STATICFILES_DIRS[0] + "/css/a4_paper.css"),
# CSS(settings.STATICFILES_DIRS[0] + "/css/black-dashboard_report.css"),
# CSS(settings.STATICFILES_DIRS[0] + "/css/font_awesome_all_5.15.3.css"),
# ],
@ -1102,7 +1102,7 @@ def generate_timeline_report(
HTML(string=html, base_url=request.build_absolute_uri()).write_pdf(
response,
stylesheets=[
CSS(settings.STATICFILES_DIRS[0] + "/css/gymnast_report.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/a4_paper.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/black-dashboard_report.css"),
CSS(settings.STATICFILES_DIRS[0] + "/css/font_awesome_all_5.15.3.css"),
],

View File

@ -89,6 +89,8 @@
{% endblock %}
{% block footerscript %}
<link href='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.js'></script>
<script type="text/javascript">
const csrf_token = "{{ csrf_token|escapejs }}";