diff --git a/manuels/admin.py b/manuels/admin.py index 2f9e69b..161c2fe 100644 --- a/manuels/admin.py +++ b/manuels/admin.py @@ -43,8 +43,8 @@ class BookResource(resources.ModelResource): class BookAdmin(ExportMixin, admin.ModelAdmin): resource_class = BookResource list_display = ['level', 'field', 'title', 'authors', 'editor', 'publication_year', 'isbn', - 'price', 'previously_acquired', 'teacher',] - list_filter = ['editor', 'previously_acquired', 'teacher', 'level'] + 'price', 'previously_acquired', 'teacher', 'done'] + list_filter = ['done', 'editor', 'previously_acquired', 'teacher', 'level'] list_display_links = ['title'] fieldsets = [ ('Infos livre', { @@ -56,6 +56,9 @@ class BookAdmin(ExportMixin, admin.ModelAdmin): ('Enseignant', { 'fields': ('teacher', 'level', 'field') }), + ('Gestion', { + 'fields': ('done',) + }), ] readonly_fields = ['created_at', 'updated_at'] @@ -75,6 +78,6 @@ class SuppliesResource(resources.ModelResource): @admin.register(SuppliesRequirement) class SuppliesRequirementAdmin(ExportMixin, admin.ModelAdmin): resource_class = SuppliesResource - list_display = ['id', 'teacher', 'level', 'fields', 'supplies'] + list_display = ['id', 'teacher', 'level', 'fields', 'supplies', 'done'] readonly_fields = ['created_at', 'updated_at'] - list_filter = ['teacher', 'level'] + list_filter = ['done', 'teacher', 'level'] diff --git a/manuels/forms.py b/manuels/forms.py index 23e907c..83a9891 100644 --- a/manuels/forms.py +++ b/manuels/forms.py @@ -6,7 +6,7 @@ from manuels.models import Book, SuppliesRequirement class AddBookForm(forms.ModelForm): class Meta: model = Book - fields = '__all__' + exclude = ['done'] add_another = forms.BooleanField(label='Ajouter un autre livre', required=False, initial=True) @@ -14,6 +14,6 @@ class AddBookForm(forms.ModelForm): class AddSuppliesForm(forms.ModelForm): class Meta: model = SuppliesRequirement - fields = '__all__' + exclude = ['done'] add_another = forms.BooleanField(label="Ajouter d'autres fournitures", required=False, initial=True) diff --git a/manuels/migrations/0017_auto_20180530_1804.py b/manuels/migrations/0017_auto_20180530_1804.py new file mode 100644 index 0000000..a4d9e1a --- /dev/null +++ b/manuels/migrations/0017_auto_20180530_1804.py @@ -0,0 +1,23 @@ +# Generated by Django 2.0.5 on 2018-05-30 16:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('manuels', '0016_auto_20180530_1801'), + ] + + operations = [ + migrations.AddField( + model_name='book', + name='done', + field=models.BooleanField(default=False, verbose_name='Traité'), + ), + migrations.AddField( + model_name='suppliesrequirement', + name='done', + field=models.BooleanField(default=False, verbose_name='Traité'), + ), + ] diff --git a/manuels/models.py b/manuels/models.py index 0f17e8d..e145661 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -132,6 +132,11 @@ class Book(BaseModel): blank=False, default=False, ) + done = models.BooleanField( + 'Traité', + blank=True, + default=False + ) @property def previously_acquired_emoji(self): @@ -153,6 +158,11 @@ class SuppliesRequirement(BaseModel): level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True) fields = models.TextField('disciplines') supplies = models.TextField('fournitures') + done = models.BooleanField( + 'Traité', + blank=True, + default=False + ) def __str__(self): return f'{self.supplies} pour {self.level} ({self.teacher})'