Source code for shuup.xtheme.layout._contact_group
from django.utils.translation import gettext_lazy as _
from shuup.core.models import CompanyContact, PersonContact
from shuup.xtheme.layout import Layout
from shuup.xtheme.layout.utils import get_customer_from_context
[docs]
class AnonymousContactLayout(Layout):
identifier = "xtheme-anonymous-contact-layout"
[docs]
def get_help_text(self, context):
return _("Content in this box is shown to guests (anonymous users) only.")
[docs]
def is_valid_context(self, context):
customer = get_customer_from_context(context)
return bool(customer.is_anonymous)
[docs]
class CompanyContactLayout(Layout):
identifier = "xtheme-company-contact-layout"
[docs]
def get_help_text(self, context):
return _("Content in this box is shown to company contacts only.")
[docs]
def is_valid_context(self, context):
customer = get_customer_from_context(context)
return isinstance(customer, CompanyContact) if customer else False
[docs]
class ContactLayout(Layout):
identifier = "xtheme-contact-layout"
[docs]
def get_help_text(self, context):
return _("Content in this box is shown to all logged-in contacts (both person and company; not anonymous).")
[docs]
def is_valid_context(self, context):
customer = get_customer_from_context(context)
return bool(not customer.is_anonymous)
[docs]
class PersonContactLayout(Layout):
identifier = "xtheme-person-contact-layout"
[docs]
def get_help_text(self, context):
return _("Content in this box is shown to person contacts only.")
[docs]
def is_valid_context(self, context):
customer = get_customer_from_context(context)
return isinstance(customer, PersonContact) if customer else False