Files
pablo 2a9407e676
CI / ci (ubuntu-24.04, 3.13) (push) Has been cancelled
feat: backoffice setup
2026-07-23 13:31:53 +02:00

60 lines
2.0 KiB
Python

from django.urls import reverse_lazy
from django.views.generic import UpdateView
from backoffice.mixins import BackofficeCRUDMixin, BackofficeStyledFormMixin
from shop.models import ShopSettings
from web.models import WebSettings
SECTION = 'settings'
class BrandSettingsView(BackofficeCRUDMixin, BackofficeStyledFormMixin, UpdateView):
model = WebSettings
permission_required = 'web.change_websettings'
section = SECTION
fields = (
'web_title',
'web_description',
'logo',
'business_name',
'business_vat_id',
'business_brand',
'business_address',
'business_state',
'business_zip',
'business_phone',
'business_email',
'business_email_2',
'bg_color',
'theme_color',
)
template_name = 'backoffice/generic/form.html'
success_url = reverse_lazy('backoffice:brand_settings')
def get_object(self, queryset=None):
obj, created = WebSettings.objects.get_or_create(pk=1)
return obj
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({'title': 'Marca y ajustes de la web', 'cancel_url': reverse_lazy('backoffice:dashboard')})
return context
class ShopSettingsView(BackofficeCRUDMixin, BackofficeStyledFormMixin, UpdateView):
model = ShopSettings
permission_required = 'shop.change_shopsettings'
section = SECTION
fields = ('merchant_code', 'currency_code', 'terminal', 'shared_secret', 'tpv_domain')
template_name = 'backoffice/generic/form.html'
success_url = reverse_lazy('backoffice:shop_settings')
def get_object(self, queryset=None):
obj, created = ShopSettings.objects.get_or_create(pk=1)
return obj
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({'title': 'Ajustes de la tienda (TPV)', 'cancel_url': reverse_lazy('backoffice:dashboard')})
return context