2020-05-31 12:08:26 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
|
|
|
from core.models.brands import Brand
|
2020-06-03 15:05:18 +00:00
|
|
|
from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
class BrandListView(BackendListView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/index.html"
|
|
|
|
model = Brand
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Brand Settings"
|
|
|
|
return context
|
|
|
|
|
|
|
|
class BrandEditView(BackendUpdateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/update.html"
|
|
|
|
model = Brand
|
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
|
|
|
|
|
|
|
|
class BrandDeleteView(BackendDeleteView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/delete.html"
|
|
|
|
model = Brand
|
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
|
|
|
|
|
|
|
|
class BrandCreateView(BackendCreateView):
|
2020-06-01 16:29:22 +00:00
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/create.html"
|
2020-05-31 12:08:26 +00:00
|
|
|
model = Brand
|
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
|