Remove no_book and see_later options
This commit is contained in:
parent
323a5d86ea
commit
b5e7c3037f
3 changed files with 0 additions and 114 deletions
|
@ -11,8 +11,6 @@ class EditBookForm(forms.ModelForm):
|
||||||
"teacher",
|
"teacher",
|
||||||
"level",
|
"level",
|
||||||
"field",
|
"field",
|
||||||
"no_book",
|
|
||||||
"see_later",
|
|
||||||
"title",
|
"title",
|
||||||
"authors",
|
"authors",
|
||||||
"editor",
|
"editor",
|
||||||
|
@ -25,16 +23,6 @@ class EditBookForm(forms.ModelForm):
|
||||||
"consumable",
|
"consumable",
|
||||||
]
|
]
|
||||||
|
|
||||||
no_book = forms.BooleanField(
|
|
||||||
label="Pas de livre pour cette classe/matière", required=False, initial=False
|
|
||||||
)
|
|
||||||
see_later = forms.BooleanField(
|
|
||||||
label="Voir à la rentrée",
|
|
||||||
help_text="Notamment en cas de désaccord sur l'adoption ou non d'un manuel",
|
|
||||||
required=False,
|
|
||||||
initial=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields["title"].widget = forms.TextInput()
|
self.fields["title"].widget = forms.TextInput()
|
||||||
|
@ -82,8 +70,6 @@ class AddBookForm(EditBookForm):
|
||||||
"teacher",
|
"teacher",
|
||||||
"levels",
|
"levels",
|
||||||
"field",
|
"field",
|
||||||
"no_book",
|
|
||||||
"see_later",
|
|
||||||
"title",
|
"title",
|
||||||
"authors",
|
"authors",
|
||||||
"editor",
|
"editor",
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
var selectors = [
|
|
||||||
{
|
|
||||||
id: "#id_no_book",
|
|
||||||
value: "PAS DE LIVRE POUR CETTE CLASSE",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "#id_see_later",
|
|
||||||
value: "VOIR À LA RENTRÉE",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
selectors.forEach(function (selector) {
|
|
||||||
var _selector = document.querySelector(selector.id);
|
|
||||||
if (_selector === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var data = {
|
|
||||||
title: document.querySelector("#id_title").value,
|
|
||||||
authors: document.querySelector("#id_authors").value,
|
|
||||||
publicationYear: document.querySelector("#id_publication_year").value,
|
|
||||||
isbn: document.querySelector("#id_isbn").value,
|
|
||||||
price: document.querySelector("#id_price").value,
|
|
||||||
editor: document.querySelector("#id_editor").value,
|
|
||||||
previouslyAcquired: document.querySelector("#id_previously_acquired").value,
|
|
||||||
};
|
|
||||||
_selector.addEventListener("change", function () {
|
|
||||||
if (_selector.checked) {
|
|
||||||
data = {
|
|
||||||
title: document.querySelector("#id_title").value,
|
|
||||||
authors: document.querySelector("#id_authors").value,
|
|
||||||
publicationYear: document.querySelector("#id_publication_year").value,
|
|
||||||
isbn: document.querySelector("#id_isbn").value,
|
|
||||||
price: document.querySelector("#id_price").value,
|
|
||||||
editor: document.querySelector("#id_editor").value,
|
|
||||||
previouslyAcquired: document.querySelector("#id_previously_acquired").value,
|
|
||||||
};
|
|
||||||
document.querySelector("#id_title").value = selector.value;
|
|
||||||
document.querySelector("#id_authors").value = "N/A";
|
|
||||||
document.querySelector("#id_publication_year").value = 1900;
|
|
||||||
document.querySelector("#id_isbn").value = "0000000000";
|
|
||||||
document.querySelector("#id_price").value = 0;
|
|
||||||
document.querySelector("#id_previously_acquired").value = "False";
|
|
||||||
var editorValue = null;
|
|
||||||
for (var option of document.querySelector("#id_editor").children) {
|
|
||||||
if (editorValue === null && option.value !== "") {
|
|
||||||
editorValue = option.value;
|
|
||||||
}
|
|
||||||
if (option.firstChild.data.toLowerCase().indexOf("autre") !== -1) {
|
|
||||||
editorValue = option.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.querySelector("#id_editor").value = editorValue;
|
|
||||||
} else {
|
|
||||||
document.querySelector("#id_title").value = data.title;
|
|
||||||
document.querySelector("#id_authors").value = data.authors;
|
|
||||||
document.querySelector("#id_editor").value = data.editor;
|
|
||||||
document.querySelector("#id_publication_year").value = data.publicationYear;
|
|
||||||
document.querySelector("#id_isbn").value = data.isbn;
|
|
||||||
document.querySelector("#id_price").value = data.price;
|
|
||||||
document.querySelector("#id_previously_acquired").value = data.previouslyAcquired;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function toggleOtherEditorDisplay() {
|
|
||||||
var editor = document.querySelector("#id_editor");
|
|
||||||
var otherEditor = document.querySelector("#id_other_editor").parentElement;
|
|
||||||
|
|
||||||
if (editor.options[editor.selectedIndex].text.toLowerCase().indexOf("autre") !== -1) {
|
|
||||||
otherEditor.style.display = "block";
|
|
||||||
} else {
|
|
||||||
otherEditor.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toggleOtherEditorDisplay();
|
|
||||||
|
|
||||||
document.querySelector("#id_editor").addEventListener("change", toggleOtherEditorDisplay);
|
|
||||||
});
|
|
|
@ -17,27 +17,6 @@
|
||||||
{% bootstrap_field form.field %}
|
{% bootstrap_field form.field %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="{{ form.no_book.auto_id }}">
|
|
||||||
<label class="custom-control-label" for="{{ form.no_book.auto_id }}">{{ form.no_book.label }}</label>
|
|
||||||
<small class="form-text text-muted">
|
|
||||||
{{ form.no_book.help_text|safe }}
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="{{ form.see_later.auto_id }}">
|
|
||||||
<label class="custom-control-label"
|
|
||||||
for="{{ form.see_later.auto_id }}">{{ form.see_later.label }}</label>
|
|
||||||
<small class="form-text text-muted">
|
|
||||||
{{ form.see_later.help_text|safe }}
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -110,6 +89,5 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block end_js %}
|
{% block end_js %}
|
||||||
<script defer src="{% static 'manuels/no_book.js' %}"></script>
|
|
||||||
<script defer src="{% static 'manuels/fetch-isbn.js' %}"></script>
|
<script defer src="{% static 'manuels/fetch-isbn.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue