expephalon/core/views/backend/brands.py

46 lines
1.7 KiB
Python

from django.conf import settings
from django.urls import reverse_lazy
from core.models.brands import Brand
from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
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
success_url = reverse_lazy("brands")
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 Brand"
return context
class BrandDeleteView(BackendDeleteView):
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/delete.html"
model = Brand
success_url = reverse_lazy("brands")
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Delete Brand"
return context
class BrandCreateView(BackendCreateView):
template_name = f"{settings.EXPEPHALON_BACKEND}/brands/create.html"
model = Brand
success_url = reverse_lazy("brands")
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 Brand"
return context