Add consumable notion for books
This commit is contained in:
parent
ff2df691e7
commit
fd8af82a71
7 changed files with 78 additions and 7 deletions
|
@ -34,9 +34,11 @@ class BookResource(resources.ModelResource):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Book
|
model = Book
|
||||||
fields = ('title', 'authors', 'editor__name', 'publication_year', 'isbn', 'comments', 'other_editor',
|
fields = ('title', 'authors', 'editor__name', 'publication_year', 'isbn', 'comments', 'other_editor',
|
||||||
'price', 'previously_acquired', 'teacher__first_name', 'teacher__last_name', 'level__name', 'field')
|
'price', 'previously_acquired', 'teacher__first_name', 'teacher__last_name', 'level__name', 'field',
|
||||||
|
'consumable')
|
||||||
export_order = ('level__name', 'field', 'title', 'authors', 'editor__name', 'publication_year', 'isbn', 'price',
|
export_order = ('level__name', 'field', 'title', 'authors', 'editor__name', 'publication_year', 'isbn', 'price',
|
||||||
'other_editor', 'previously_acquired', 'teacher__first_name', 'teacher__last_name', 'comments')
|
'other_editor', 'previously_acquired', 'teacher__first_name', 'teacher__last_name', 'comments',
|
||||||
|
'consumable')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Book)
|
@admin.register(Book)
|
||||||
|
|
|
@ -8,7 +8,7 @@ class EditBookForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Book
|
model = Book
|
||||||
fields = ['teacher', 'level', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'other_editor',
|
fields = ['teacher', 'level', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'other_editor',
|
||||||
'publication_year', 'isbn', 'price', 'previously_acquired', 'comments']
|
'publication_year', 'isbn', 'price', 'previously_acquired', 'comments', 'consumable']
|
||||||
|
|
||||||
no_book = forms.BooleanField(label='Pas de livre pour cette classe/matière', required=False, initial=False)
|
no_book = forms.BooleanField(label='Pas de livre pour cette classe/matière', required=False, initial=False)
|
||||||
see_later = forms.BooleanField(
|
see_later = forms.BooleanField(
|
||||||
|
@ -24,6 +24,7 @@ class EditBookForm(forms.ModelForm):
|
||||||
self.fields['teacher'].widget.attrs.update({'class': 'custom-select'})
|
self.fields['teacher'].widget.attrs.update({'class': 'custom-select'})
|
||||||
self.fields['editor'].widget.attrs.update({'class': 'custom-select'})
|
self.fields['editor'].widget.attrs.update({'class': 'custom-select'})
|
||||||
self.fields['previously_acquired'].widget.attrs.update({'class': 'custom-select'})
|
self.fields['previously_acquired'].widget.attrs.update({'class': 'custom-select'})
|
||||||
|
self.fields['consumable'].widget.attrs.update({'class': 'custom-select'})
|
||||||
if 'level' in self.fields:
|
if 'level' in self.fields:
|
||||||
self.fields['level'].widget.attrs.update({'class': 'custom-select'})
|
self.fields['level'].widget.attrs.update({'class': 'custom-select'})
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ class EditBookForm(forms.ModelForm):
|
||||||
class AddBookForm(EditBookForm):
|
class AddBookForm(EditBookForm):
|
||||||
class Meta(EditBookForm.Meta):
|
class Meta(EditBookForm.Meta):
|
||||||
fields = ['teacher', 'levels', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'other_editor',
|
fields = ['teacher', 'levels', 'field', 'no_book', 'see_later', 'title', 'authors', 'editor', 'other_editor',
|
||||||
'publication_year', 'isbn', 'price', 'previously_acquired', 'comments', 'add_another']
|
'publication_year', 'isbn', 'price', 'previously_acquired', 'comments', 'add_another', 'consumable']
|
||||||
|
|
||||||
add_another = forms.BooleanField(label='Ajouter un autre livre', required=False, initial=True)
|
add_another = forms.BooleanField(label='Ajouter un autre livre', required=False, initial=True)
|
||||||
levels = forms.ModelMultipleChoiceField(
|
levels = forms.ModelMultipleChoiceField(
|
||||||
|
|
28
manuels/migrations/0028_auto_20190406_1901.py
Normal file
28
manuels/migrations/0028_auto_20190406_1901.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 2.2 on 2019-04-06 17:01
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('manuels', '0027_auto_20190401_2036'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='level',
|
||||||
|
options={'ordering': ['order', 'name'], 'verbose_name': 'classe', 'verbose_name_plural': 'classes'},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='book',
|
||||||
|
name='consumable',
|
||||||
|
field=models.BooleanField(default=False, help_text="Exemple : un cahier d'exercices est un consommable", verbose_name='consommable'),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='level',
|
||||||
|
name='order',
|
||||||
|
field=models.IntegerField(default=0, verbose_name='ordre'),
|
||||||
|
),
|
||||||
|
]
|
18
manuels/migrations/0029_auto_20190406_1904.py
Normal file
18
manuels/migrations/0029_auto_20190406_1904.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2 on 2019-04-06 17:04
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('manuels', '0028_auto_20190406_1901'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='book',
|
||||||
|
name='consumable',
|
||||||
|
field=models.BooleanField(choices=[(None, '------------'), (False, 'Non'), (True, 'Oui')], default=None, help_text="Exemple : un cahier d'exercices est un consommable", verbose_name='consommable'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -184,6 +184,13 @@ class Book(BaseModel):
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text="Ce message sera visible par la documentaliste."
|
help_text="Ce message sera visible par la documentaliste."
|
||||||
)
|
)
|
||||||
|
consumable = models.BooleanField(
|
||||||
|
'consommable',
|
||||||
|
help_text="Exemple : un cahier d'exercices est un consommable",
|
||||||
|
choices=YES_NO_CHOICE,
|
||||||
|
blank=False,
|
||||||
|
default=None,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def previously_acquired_text(self):
|
def previously_acquired_text(self):
|
||||||
|
@ -192,6 +199,13 @@ class Book(BaseModel):
|
||||||
else:
|
else:
|
||||||
return 'Non'
|
return 'Non'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def consumable_text(self):
|
||||||
|
if self.previously_acquired:
|
||||||
|
return 'Oui'
|
||||||
|
else:
|
||||||
|
return 'Non'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.title} ({self.authors}) - {self.isbn}'
|
return f'{self.title} ({self.authors}) - {self.isbn}'
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-12">
|
<div class="col-lg-6 col-12">
|
||||||
{% bootstrap_field form.previously_acquired %}
|
{% bootstrap_field form.previously_acquired %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-lg-6 col-12">
|
||||||
|
{% bootstrap_field form.consumable %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
<th scope="col">ISBN</th>
|
<th scope="col">ISBN</th>
|
||||||
<th scope="col">Prix</th>
|
<th scope="col">Prix</th>
|
||||||
<th scope="col">Déjà acheté par l'élève</th>
|
<th scope="col">Déjà acheté par l'élève</th>
|
||||||
|
<th scope="col">Consommable</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -85,6 +86,10 @@
|
||||||
<i class="fas fa-{% if book.previously_acquired %}check-circle{% else %}ban{% endif %}"></i>
|
<i class="fas fa-{% if book.previously_acquired %}check-circle{% else %}ban{% endif %}"></i>
|
||||||
{{ book.previously_acquired_text }}
|
{{ book.previously_acquired_text }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<i class="fas fa-{% if book.consumable %}check-circle{% else %}ban{% endif %}"></i>
|
||||||
|
{{ book.consumable_text }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -110,7 +115,7 @@
|
||||||
<th scope="col">Modifier</th>
|
<th scope="col">Modifier</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th scope="col">Classe</th>
|
<th scope="col">Classe</th>
|
||||||
<th scope="col">Disciplines</th>
|
<th scope="col">Discipline</th>
|
||||||
<th scope="col">Liste de fournitures</th>
|
<th scope="col">Liste de fournitures</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -130,7 +135,7 @@
|
||||||
</th>
|
</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>{{ supply.level }}</td>
|
<td>{{ supply.level }}</td>
|
||||||
<td>{{ supply.fields }}</td>
|
<td>{{ supply.field }}</td>
|
||||||
<td>{{ supply.supplies|linebreaksbr }}</td>
|
<td>{{ supply.supplies|linebreaksbr }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue