2020-05-31 12:08:26 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
from core.models.invoices import Invoice, InvoiceItem
|
2020-05-31 12:08:26 +00:00
|
|
|
from core.views.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceListView(BackendListView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/index.html"
|
|
|
|
model = Invoice
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Brand Settings"
|
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceEditView(BackendUpdateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/update.html"
|
|
|
|
model = Invoice
|
2020-06-01 16:29:22 +00:00
|
|
|
success_url = reverse_lazy("brands")
|
|
|
|
fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"]
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Edit Brand"
|
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceDeleteView(BackendDeleteView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/delete.html"
|
|
|
|
model = Invoice
|
2020-06-01 16:29:22 +00:00
|
|
|
success_url = reverse_lazy("brands")
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Delete Brand"
|
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceCreateView(BackendCreateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/create.html"
|
|
|
|
model = Invoice
|
2020-06-01 16:29:22 +00:00
|
|
|
success_url = reverse_lazy("brands")
|
|
|
|
fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"]
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Create Brand"
|
|
|
|
return context
|