from django.conf import settings from django.urls import reverse_lazy from core.models.invoices import Invoice, InvoiceItem from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView class InvoiceListView(BackendListView): template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/index.html" model = Invoice def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["title"] = "Invoice Settings" return context class InvoiceEditView(BackendUpdateView): template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/update.html" model = Invoice success_url = reverse_lazy("invoices") fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["title"] = "Edit Invoice" return context class InvoiceDeleteView(BackendDeleteView): template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/delete.html" model = Invoice success_url = reverse_lazy("invoices") def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["title"] = "Delete Invoice" return context class InvoiceCreateView(BackendCreateView): template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/create.html" model = Invoice success_url = reverse_lazy("invoices") fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["title"] = "Create Invoice" return context