Add "see_later" field in form
This commit is contained in:
parent
51be90baad
commit
651907682c
2 changed files with 60 additions and 43 deletions
|
@ -6,10 +6,14 @@ from manuels.models import Book, SuppliesRequirement
|
|||
class EditBookForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Book
|
||||
fields = ['teacher', 'level', 'field', 'no_book', 'title', 'authors', 'editor', 'publication_year',
|
||||
fields = ['teacher', 'level', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'publication_year',
|
||||
'isbn', 'price', 'previously_acquired', 'comments']
|
||||
|
||||
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):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -20,7 +24,7 @@ class EditBookForm(forms.ModelForm):
|
|||
|
||||
class AddBookForm(EditBookForm):
|
||||
class Meta(EditBookForm.Meta):
|
||||
fields = ['teacher', 'level', 'field', 'no_book', 'title', 'authors', 'editor', 'publication_year',
|
||||
fields = ['teacher', 'level', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'publication_year',
|
||||
'isbn', 'price', 'previously_acquired', 'comments', 'add_another']
|
||||
|
||||
add_another = forms.BooleanField(label='Ajouter un autre livre', required=False, initial=True)
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
var _selector = document.querySelector('#id_no_book');
|
||||
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, index, array) {
|
||||
var _selector = document.querySelector(selector.id);
|
||||
if (_selector === null) return;
|
||||
var data = {
|
||||
title: document.querySelector('#id_title').value,
|
||||
|
@ -19,7 +30,7 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
|||
price: document.querySelector('#id_price').value,
|
||||
editor: document.querySelector('#id_editor').value,
|
||||
};
|
||||
document.querySelector('#id_title').value = "PAS DE LIVRE POUR CETTE CLASSE";
|
||||
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";
|
||||
|
@ -43,4 +54,6 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
|||
document.querySelector('#id_price').value = data.price;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue