Source code for shuup.admin.modules.contacts.sections
# -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2017, Shoop Commerce Ltd. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import unicode_literals
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from shuup.admin.base import Section
from shuup.core.models import PersonContact
[docs]class BasicInfoContactSection(Section):
identifier = "contact_basic_info"
name = _("Basic Information")
icon = "fa-info-circle"
template = "shuup/admin/contacts/_contact_basic_info.jinja"
order = 1
@staticmethod
@staticmethod
[docs] def get_context_data(contact):
context = {}
context['groups'] = sorted(
contact.groups.all(),
key=(lambda x: force_text(x))
)
context["companies"] = []
if isinstance(contact, PersonContact):
context["companies"] = sorted(
contact.company_memberships.all(),
key=(lambda x: force_text(x))
)
return context
[docs]class AddressesContactSection(Section):
identifier = "contact_addresses"
name = _("Addresses")
icon = "fa-map-marker"
template = "shuup/admin/contacts/_contact_addresses.jinja"
order = 2
@staticmethod
[docs] def visible_for_object(contact):
return (contact.default_shipping_address_id or
contact.default_billing_address_id)
@staticmethod
[docs]class OrdersContactSection(Section):
identifier = "contact_orders"
name = _("Orders")
icon = "fa-inbox"
template = "shuup/admin/contacts/_contact_orders.jinja"
order = 3
@staticmethod
[docs] def visible_for_object(contact):
return (contact.default_shipping_address_id or
contact.default_billing_address_id)
@staticmethod
[docs]class MembersContactSection(Section):
identifier = "contact_members"
name = _("Members")
icon = "fa-user"
template = "shuup/admin/contacts/_contact_members.jinja"
order = 4
@staticmethod
@staticmethod