30 lines
976 B
Python
30 lines
976 B
Python
from django.views.generic import ListView
|
|
|
|
from backoffice.mixins import BackofficeCRUDMixin, BackofficeHtmxMixin
|
|
from shop.models import Provider
|
|
|
|
SECTION = 'providers'
|
|
|
|
|
|
class ProviderListView(BackofficeCRUDMixin, BackofficeHtmxMixin, ListView):
|
|
model = Provider
|
|
permission_required = 'shop.view_provider'
|
|
section = SECTION
|
|
paginate_by = 20
|
|
template_name = 'backoffice/generic/list.html'
|
|
fragment_template_name = 'backoffice/generic/_list_fragment.html'
|
|
ordering = 'name'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context.update(
|
|
{
|
|
'title': 'Proveedores',
|
|
'columns': [('Nombre', 'name'), ('NIF/CIF', 'vat_id'), ('E-mail', 'email'), ('Teléfono', 'phone')],
|
|
}
|
|
)
|
|
return context
|
|
|
|
# CRUD pendiente: replicar ProductCategoryCreateView/UpdateView/DeleteView de
|
|
# backoffice/views/products.py sobre el modelo Provider.
|