Autofull UV small changes

This commit is contained in:
tleb 2019-10-20 17:09:36 +02:00
parent bddb88d97f
commit 4759551c16
2 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-18 18:04+0200\n" "POT-Creation-Date: 2019-10-20 16:50+0200\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -4990,17 +4990,21 @@ msgstr "Supprimer signalement"
#: pedagogy/templates/pedagogy/uv_create.jinja:4 #: pedagogy/templates/pedagogy/uv_create.jinja:4
#: pedagogy/templates/pedagogy/uv_create.jinja:8 #: pedagogy/templates/pedagogy/uv_create.jinja:8
#, fuzzy
#| msgid "Edit"
msgid "Edit UV" msgid "Edit UV"
msgstr "Éditer" msgstr "Éditer"
#: pedagogy/templates/pedagogy/uv_create.jinja:27
msgid "Import from UTBM"
msgstr "Importer depuis l'UTBM"
#: pedagogy/templates/pedagogy/uv_create.jinja:57 #: pedagogy/templates/pedagogy/uv_create.jinja:57
#, fuzzy
#| msgid "Unknown event"
msgid "Unknown UV code" msgid "Unknown UV code"
msgstr "Code d'UV inconnu" msgstr "Code d'UV inconnu"
#: pedagogy/templates/pedagogy/uv_create.jinja:72
msgid "Successful autocomplete"
msgstr "Autocomplétion réussite"
#: pedagogy/templates/pedagogy/uv_detail.jinja:6 #: pedagogy/templates/pedagogy/uv_detail.jinja:6
msgid "UV Details" msgid "UV Details"
msgstr "Détails d'UV" msgstr "Détails d'UV"

View File

@ -24,7 +24,7 @@
{% if field.name == 'code' %} {% if field.name == 'code' %}
<a href="javascript:void(0)" id="autofill">Fill</a> <button type="button" id="autofill">{% trans %}Import from UTBM{% endtrans %}</button>
{% endif %} {% endif %}
</p> </p>
{% endif %} {% endif %}
@ -48,13 +48,13 @@
autofillBtn.addEventListener('click', () => { autofillBtn.addEventListener('click', () => {
const today = new Date() const today = new Date()
let year = today.getFullYear() let year = today.getFullYear()
if (today.getMonth() < 7) { // student year, starts in september if (today.getMonth() < 7) { // student year starts in september
year-- year--
} }
const url = "{{ url('api:uv_endpoint') }}?year=" + year + "&code=" + codeInput.value const url = "{{ url('api:uv_endpoint') }}?year=" + year + "&code=" + codeInput.value
$.getJSON(url, function(data, _, xhr) { $.getJSON(url, function(data, _, xhr) {
if (xhr.status != 200) { if (xhr.status != 200) {
alert('{% trans %}Unknown UV code{% endtrans %}') alert("{% trans %}Unknown UV code{% endtrans %}")
return return
} }
for (let key in data) { for (let key in data) {
@ -68,9 +68,10 @@
} }
} }
alert('{% trans %}Successful autocomplete{% endtrans %}')
}) })
}) })
}) })
</script> </script>
{% endblock %} {% endblock %}