本文整理汇总了Python中shoop.core.models.get_person_contact函数的典型用法代码示例。如果您正苦于以下问题:Python get_person_contact函数的具体用法?Python get_person_contact怎么用?Python get_person_contact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_person_contact函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_product_query
def test_product_query(admin_user, regular_user):
anon_contact = AnonymousContact()
shop_product = get_default_shop_product()
shop = shop_product.shop
product = shop_product.product
regular_contact = get_person_contact(regular_user)
admin_contact = get_person_contact(admin_user)
with modify(shop_product, save=True,
listed=True,
visible=True,
visibility_limit=ProductVisibility.VISIBLE_TO_ALL
):
assert Product.objects.list_visible(shop=shop, customer=anon_contact).filter(pk=product.pk).exists()
with modify(shop_product, save=True,
listed=False,
visible=True,
visibility_limit=ProductVisibility.VISIBLE_TO_ALL
):
assert not Product.objects.list_visible(shop=shop, customer=anon_contact).filter(pk=product.pk).exists()
assert not Product.objects.list_visible(shop=shop, customer=regular_contact).filter(pk=product.pk).exists()
assert Product.objects.list_visible(shop=shop, customer=admin_contact).filter(pk=product.pk).exists()
with modify(shop_product, save=True,
listed=True,
visible=True,
visibility_limit=ProductVisibility.VISIBLE_TO_LOGGED_IN
):
assert not Product.objects.list_visible(shop=shop, customer=anon_contact).filter(pk=product.pk).exists()
assert Product.objects.list_visible(shop=shop, customer=regular_contact).filter(pk=product.pk).exists()
product.soft_delete()
assert not Product.objects.all_except_deleted().filter(pk=product.pk).exists()
示例2: _set_person
def _set_person(self, request):
request.person = get_person_contact(request.user)
if not request.person.is_active:
messages.add_message(request, messages.INFO, _("Logged out since this account is inactive."))
logout(request)
# Usually logout is connected to the `refresh_on_logout`
# method via a signal and that already sets request.person
# to anonymous, but set it explicitly too, just to be sure
request.person = get_person_contact(None)
示例3: test_address_ownership
def test_address_ownership(admin_user):
address = get_address()
address.save()
saved = SavedAddress(address=address)
saved.owner = get_person_contact(admin_user)
assert saved.get_title(), u"get_title does what it should even if there is no explicit title"
saved.title = u"My favorite address"
assert saved.get_title() == saved.title, u"get_title does what it should when there is an explicit title"
assert six.text_type(saved) == saved.get_title(), u"str() is an alias for .get_title()"
saved.full_clean()
saved.save()
assert SavedAddress.objects.for_owner(get_person_contact(admin_user)).filter(address=address).exists(), \
"contacts can save addresses"
assert SavedAddress.objects.for_owner(None).count() == 0, "Ownerless saved addresses aren't a real thing"
示例4: test_product_unsupplied
def test_product_unsupplied(admin_user):
shop_product = get_default_shop_product()
fake_supplier = Supplier.objects.create(identifier="fake")
admin_contact = get_person_contact(admin_user)
with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_ALL, orderable=True):
assert any(ve.code == "invalid_supplier" for ve in shop_product.get_orderability_errors(supplier=fake_supplier, customer=admin_contact, quantity=1))
示例5: seed_source
def seed_source(user, shop):
source = BasketishOrderSource(shop)
source.status = get_initial_order_status()
source.customer = get_person_contact(user)
source.payment_method = get_default_payment_method()
source.shipping_method = get_default_shipping_method()
return source
示例6: get_form
def get_form(self, form_class):
contact = get_person_contact(self.request.user)
form_group = FormGroup(**self.get_form_kwargs())
form_group.add_form_def("billing", AddressForm, kwargs={"instance": contact.default_billing_address})
form_group.add_form_def("shipping", AddressForm, kwargs={"instance": contact.default_shipping_address})
form_group.add_form_def("contact", PersonContactForm, kwargs={"instance": contact})
return form_group
示例7: get_order_and_source
def get_order_and_source(admin_user):
# create original source to tamper with
source = BasketishOrderSource(get_default_shop())
source.status = get_initial_order_status()
source.billing_address = MutableAddress.objects.create(name="Original Billing")
source.shipping_address = MutableAddress.objects.create(name="Original Shipping")
source.customer = get_person_contact(admin_user)
source.payment_method = get_default_payment_method()
source.shipping_method = get_default_shipping_method()
source.add_line(
type=OrderLineType.PRODUCT,
product=get_default_product(),
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
)
source.add_line(
type=OrderLineType.OTHER,
quantity=1,
base_unit_price=source.create_price(10),
require_verification=True,
)
assert len(source.get_lines()) == 2
source.creator = admin_user
creator = OrderCreator()
order = creator.create_order(source)
return order, source
示例8: test_get_company_contact
def test_get_company_contact(regular_user):
person_contact = get_person_contact(regular_user)
assert person_contact != AnonymousContact()
assert not get_company_contact(regular_user)
company_contact = create_random_company()
company_contact.members.add(person_contact)
assert get_company_contact(regular_user) == company_contact
示例9: test_product_minimum_order_quantity
def test_product_minimum_order_quantity(admin_user):
shop_product = get_default_shop_product()
supplier = get_default_supplier()
admin_contact = get_person_contact(admin_user)
with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_ALL, orderable=True, minimum_purchase_quantity=10):
assert any(ve.code == "purchase_quantity_not_met" for ve in shop_product.get_orderability_errors(supplier=supplier, customer=admin_contact, quantity=1))
assert not any(ve.code == "purchase_quantity_not_met" for ve in shop_product.get_orderability_errors(supplier=supplier, customer=admin_contact, quantity=15))
示例10: test_basic_order
def test_basic_order(rf, admin_user):
request = rf.get('/')
product = get_default_product()
SimpleProductPrice.objects.create(product=product, group=None, price=Decimal("100.00"), includes_tax=False)
customer = get_person_contact(admin_user)
for x in range(10):
create_order(request, creator=admin_user, customer=customer, product=product)
assert Order.objects.filter(customer=customer).count() == 10
示例11: test_product_order_multiple
def test_product_order_multiple(admin_user):
shop_product = get_default_shop_product()
supplier = get_default_supplier()
admin_contact = get_person_contact(admin_user)
with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_ALL, orderable=True, purchase_multiple=7):
assert any(ve.code == "invalid_purchase_multiple" for ve in shop_product.get_orderability_errors(supplier=supplier, customer=admin_contact, quantity=4))
assert any(ve.code == "invalid_purchase_multiple" for ve in shop_product.get_orderability_errors(supplier=supplier, customer=admin_contact, quantity=25))
assert not any(ve.code == "invalid_purchase_multiple" for ve in shop_product.get_orderability_errors(supplier=supplier, customer=admin_contact, quantity=49))
示例12: test_companies
def test_companies(django_user_model):
peons = [django_user_model.objects.create_user('Peon-%d' % x, 'Peon%[email protected]' % x, 'password') for x in range(10)]
for cx in range(10):
company = CompanyContact.objects.create(name="Company %d" % cx, tax_number="FI2101%d" % cx)
assert str(company)
for x in range(5):
off = (cx * 3 + x) % len(peons)
contact = get_person_contact(user=peons[off])
company.members.add(contact)
示例13: confirm_login_allowed
def confirm_login_allowed(self, user):
"""
Do not let user with inactive person contact to login.
"""
if not get_person_contact(user).is_active:
raise forms.ValidationError(
self.error_messages['inactive'],
code='inactive',
)
super(EmailAuthenticationForm, self).confirm_login_allowed(user)
示例14: test_intra_request_user_changing
def test_intra_request_user_changing(rf, regular_user):
get_default_shop() # Create a shop
mw = ShoopFrontMiddleware()
request = apply_request_middleware(rf.get("/"), user=regular_user)
mw.process_request(request)
assert request.person == get_person_contact(regular_user)
logout(request)
assert request.user == AnonymousUser()
assert request.person == AnonymousContact()
assert request.customer == AnonymousContact()
示例15: test_customers
def test_customers(django_user_model):
users = [django_user_model.objects.create_user('Joe-%d' % x, 'joe%[email protected]' % x, 'password') for x in range(10)]
group = get_default_customer_group()
assert str(group) == DEFAULT_NAME
for user in users:
contact = get_person_contact(user)
group.members.add(contact)
for user in users:
assert PersonContact.objects.get(user=user).user_id == user.pk, "Customer profile found"
assert tuple(user.contact.groups.values_list("identifier", flat=True)) == (DEFAULT_IDENTIFIER,), "Joe is now in the group"