Simplify list book and supplies view
This commit is contained in:
parent
7276b8eedc
commit
0a93b93a7e
2 changed files with 4 additions and 14 deletions
|
@ -58,7 +58,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
{% for book in teacher.book_set.all %}
|
||||
<tr>
|
||||
{% if not teacher.has_confirmed_list %}
|
||||
<th scope="row">
|
||||
|
@ -115,7 +115,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for supply in supplies %}
|
||||
{% for supply in teacher.suppliesrequirement_set.all %}
|
||||
<tr>
|
||||
{% if not teacher.has_confirmed_list %}
|
||||
<th scope="row">
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib import messages
|
|||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse
|
||||
from django.views.generic import CreateView, ListView, UpdateView, DeleteView, FormView
|
||||
from django.views.generic import CreateView, ListView, UpdateView, DeleteView, FormView, DetailView, TemplateView
|
||||
|
||||
from manuels.forms import AddBookForm, AddSuppliesForm, EditBookForm, EditSuppliesForm
|
||||
from manuels.models import Teacher, Book, SuppliesRequirement
|
||||
|
@ -46,18 +46,8 @@ class BaseTeacherView:
|
|||
return context
|
||||
|
||||
|
||||
class ListBooksView(BaseTeacherView, ListView):
|
||||
model = Book
|
||||
class ListBooksView(BaseTeacherView, TemplateView):
|
||||
template_name = 'manuels/list_books_supplies.html'
|
||||
context_object_name = 'books'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['supplies'] = SuppliesRequirement.objects.filter(teacher=self.teacher)
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
return Book.objects.filter(teacher=self.teacher)
|
||||
|
||||
|
||||
class ItemView(BaseTeacherView):
|
||||
|
|
Loading…
Reference in a new issue