Source code for shuup.testing.supplier_provider

# -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2021, Shuup Commerce Inc. 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 shuup.core.models import Supplier


[docs]class UsernameSupplierProvider(object): @classmethod
[docs] def get_supplier(cls, request, **kwargs): return Supplier.objects.filter(identifier=request.user.username).first()
[docs]class RequestSupplierProvider(object): @classmethod
[docs] def get_supplier(cls, request, **kwargs): return getattr(request, "supplier", None)
[docs]class FirstSupplierProvider(object): @classmethod
[docs] def get_supplier(cls, request, **kwargs): return Supplier.objects.first()