Add done field. Close #2

This commit is contained in:
Gabriel Augendre 2018-05-30 18:06:27 +02:00
parent eb88c5d4af
commit 1ec152f6c7
4 changed files with 42 additions and 6 deletions

View file

@ -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']

View file

@ -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)

View file

@ -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é'),
),
]

View file

@ -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})'