本文整理汇总了Python中shuup.configuration.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_register_bad_data
def test_register_bad_data():
get_default_shop()
configuration.set(None, "api_permission_FrontUserViewSet", PermissionLevel.PUBLIC_WRITE)
client = _get_client()
# no username or email
register_data = {
"password": "somepassword"
}
response = client.post("/api/shuup/front/user/",
content_type="application/json",
data=json.dumps(register_data))
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "username and/or email is required" in response.content.decode("utf-8")
# invalid email
register_data = {
"email": "invalidemail",
"password": "somepassword"
}
response = client.post("/api/shuup/front/user/",
content_type="application/json",
data=json.dumps(register_data))
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "Enter a valid email address" in response.content.decode("utf-8")
# no password
register_data = {
"email": "[email protected]",
}
response = client.post("/api/shuup/front/user/",
content_type="application/json",
data=json.dumps(register_data))
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "password" in json.loads(response.content.decode("utf-8"))
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_front_users_api.py
示例2: test_product_create
def test_product_create(browser, admin_user, live_server, settings):
activate("en")
shop = get_default_shop()
get_default_product_type()
get_default_sales_unit()
get_default_tax_class()
configuration.set(None, "shuup_product_tour_complete", True)
object_created.connect(_add_custom_product_created_message, sender=Product, dispatch_uid="object_created_signal_test")
initialize_admin_browser_test(browser, live_server, settings)
url = reverse("shuup_admin:shop_product.new")
browser.visit("%s%s" % (live_server, url))
sku = "testsku"
name = "Some product name"
price_value = 10
short_description = "short but gold"
browser.fill("base-sku", sku)
browser.fill("base-name__en", name)
browser.fill("base-short_description__en", short_description)
browser.fill("shop%s-default_price_value" % shop.pk, price_value)
configuration.set(None, "shuup_category_tour_complete", True)
_add_primary_category(browser, shop)
_add_additional_category(browser, shop)
click_element(browser, "button[form='product_form']")
wait_until_appeared(browser, "div[class='message success']")
product = Product.objects.filter(sku=sku).first()
assert product.log_entries.filter(identifier=OBJECT_CREATED_LOG_IDENTIFIER).count() == 1
object_created.disconnect(sender=Product, dispatch_uid="object_created_signal_test")
shop_product = product.get_shop_instance(shop)
assert shop_product.categories.count() == 2
开发者ID:gurch101,项目名称:shuup,代码行数:33,代码来源:test_product_create.py
示例3: test_product_detail
def test_product_detail(browser, admin_user, live_server, settings):
shop = get_default_shop()
product = create_product("test_sku", shop, default_price=10)
configuration.set(None, "shuup_product_tour_complete", True)
initialize_admin_browser_test(browser, live_server, settings)
url = reverse("shuup_admin:product.edit", kwargs={"pk": product.pk})
browser.visit("%s%s" % (live_server, url))
assert browser.find_by_id("id_base-sku").value == product.sku
# Test product save
new_sku = "some-new-sku"
browser.find_by_id("id_base-sku").fill(new_sku)
browser.execute_script("window.scrollTo(0,0)")
click_element(browser, "button[form='product_form']")
product.refresh_from_db()
assert product.sku == new_sku
# Test that toolbar action item is there
dropdowns = browser.find_by_css(".btn.dropdown-toggle")
for dropdown in dropdowns:
if "Actions" in dropdown.text:
dropdown.click()
click_element(browser, "a[href='#%s']" % product.sku)
# Make sure that the tabs is clickable in small devices
browser.driver.set_window_size(480, 960)
click_element(browser, "#product-images-section", header_height=320)
click_element(browser, "#additional-details-section", header_height=320)
开发者ID:suutari,项目名称:shoop,代码行数:31,代码来源:test_product_detail.py
示例4: test_global_configurations
def test_global_configurations():
with override_settings(CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'test_global_configurations',
}
}):
cache.init_cache()
shop = get_default_shop()
configuration.set(None, "key1", {"data": "test1"})
configuration.set(shop, "key2", {"data": "test2"})
# key1 from shop should come from global configuration
assert configuration.get(shop, "key1").get("data") == "test1"
# key2 shouldn't be in global configurations
assert configuration.get(None, "key2") is None
# Update global configuration
configuration.set(None, "key1", {"data": "test_bump"})
assert configuration.get(shop, "key1").get("data") == "test_bump"
# Override shop data for global key1
configuration.set(shop, "key1", "test_data")
assert configuration.get(shop, "key1") == "test_data"
# Update shop configuration for global key1
configuration.set(shop, "key1", "test_data1")
assert configuration.get(shop, "key1") == "test_data1"
开发者ID:ruqaiya,项目名称:shuup,代码行数:28,代码来源:test_configurations.py
示例5: set_configuration
def set_configuration():
config = {
"api_permission_ShopViewSet": 3,
"api_permission_FrontShopProductViewSet": 3,
"api_permission_PersonContactViewSet": 4,
"api_permission_FrontUserViewSet": 2,
"api_permission_FrontOrderViewSet": 4,
"api_permission_AttributeViewSet": 5,
"api_permission_TaxClassViewSet": 5,
"api_permission_FrontProductViewSet": 3,
"api_permission_ProductVariationVariableValueViewSet": 5,
"api_permission_SalesUnitViewSet": 5,
"api_permission_UserViewSet": 5,
"api_permission_ShopReviewViewSet": 4,
"api_permission_BasketViewSet": 2,
"api_permission_CategoryViewSet": 1,
"api_permission_ShipmentViewSet": 5,
"api_permission_CgpPriceViewSet": 5,
"api_permission_ShopProductViewSet": 3,
"api_permission_ContactViewSet": 4,
"api_permission_OrderViewSet": 5,
"api_permission_ProductViewSet": 5,
"api_permission_ProductTypeViewSet": 5,
"api_permission_ProductVariationVariableViewSet": 5,
"api_permission_SupplierViewSet": 5,
"api_permission_ManufacturerViewSet": 5,
"api_permission_ProductMediaViewSet": 5,
"api_permission_ProductAttributeViewSet": 5,
"api_permission_MutableAddressViewSet": 5,
"api_permission_ProductPackageViewSet": 5,
}
for field, value in six.iteritems(config):
configuration.set(None, field, value)
开发者ID:ruqaiya,项目名称:shuup,代码行数:33,代码来源:basket_helpers.py
示例6: toggle_all_seeing_for_user
def toggle_all_seeing_for_user(user):
if not getattr(user, "is_superuser", False):
return
all_seeing_key = ALL_SEEING_FORMAT % {"user_id": user.pk}
is_all_seeing = configuration.get(None, all_seeing_key, False)
configuration.set(None, all_seeing_key, not is_all_seeing)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:users.py
示例7: test_category_deletion
def test_category_deletion(admin_user):
admin = get_person_contact(admin_user)
category = get_default_category()
category.children.create(identifier="foo")
shop_product = get_default_shop_product()
shop_product.categories.add(category)
shop_product.primary_category = category
shop_product.save()
configuration.set(None, get_all_seeing_key(admin), True)
assert category.status == CategoryStatus.VISIBLE
assert category.children.count() == 1
with pytest.raises(NotImplementedError):
category.delete()
category.soft_delete()
shop_product.refresh_from_db()
shop_product.product.refresh_from_db()
assert shop_product.categories.count() == 0
assert shop_product.primary_category is None
assert category.status == CategoryStatus.DELETED
assert category.children.count() == 0
# the child category still exists
assert Category.objects.all_visible(customer=admin).count() == 1
assert Category.objects.all_except_deleted().count() == 1
configuration.set(None, get_all_seeing_key(admin), False)
开发者ID:gurch101,项目名称:shuup,代码行数:29,代码来源:test_categories.py
示例8: test_simple_set_and_get_without_shop
def test_simple_set_and_get_without_shop():
configuration.set(None, "answer", 42)
assert configuration.get(None, "answer") == 42
assert configuration.get(None, "non-existing") is None
configuration.set(None, "non-existing", "hello")
assert configuration.get(None, "non-existing") == "hello"
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_configurations.py
示例9: _handle_xtheme_save
def _handle_xtheme_save(self):
svc_pk = config.get(self.shop, CONTENT_FOOTER_KEY)
svc = SavedViewConfig.objects.filter(pk=svc_pk).first()
theme = get_current_theme(self.shop)
if not svc and theme:
context = {"shop": self.shop}
rendered_content = template_loader.render_to_string(content_data.FOOTER_TEMPLATE, context).strip()
layout = Layout(theme, "footer-bottom")
# adds the footer template
layout.begin_row()
layout.begin_column({"md": 12})
layout.add_plugin(SnippetsPlugin.identifier, {"in_place": rendered_content})
svc = SavedViewConfig(
theme_identifier=theme.identifier,
shop=self.shop,
view_name=XTHEME_GLOBAL_VIEW_NAME,
status=SavedViewConfigStatus.CURRENT_DRAFT
)
svc.set_layout_data(layout.placeholder_name, layout)
svc.save()
svc.publish()
config.set(self.shop, CONTENT_FOOTER_KEY, svc.pk)
开发者ID:ruqaiya,项目名称:shuup,代码行数:25,代码来源:forms.py
示例10: test_register_api
def test_register_api():
get_default_shop()
configuration.set(None, "api_permission_FrontUserViewSet", PermissionLevel.PUBLIC_WRITE)
client = _get_client()
register_data = {
"username": "goodusername",
"password": "somepassword"
}
response = client.post("/api/shuup/front/user/",
content_type="application/json",
data=json.dumps(register_data))
assert response.status_code == status.HTTP_201_CREATED
response_json = json.loads(response.content.decode("utf-8"))
assert "token" in response_json
assert get_user_model().objects.count() == 1
# Try to register with same username
register_data = {
"username": "goodusername",
"password": "somepassword"
}
response = client.post("/api/shuup/front/user/",
content_type="application/json",
data=json.dumps(register_data))
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "User already exists" in response.content.decode("utf-8")
开发者ID:suutari-ai,项目名称:shuup,代码行数:26,代码来源:test_front_users_api.py
示例11: test_simple_set_and_get_with_shop
def test_simple_set_and_get_with_shop():
shop = get_default_shop()
configuration.set(shop, "answer", 42)
assert configuration.get(shop, "answer") == 42
assert configuration.get(shop, "non-existing") is None
configuration.set(shop, "non-existing", "hello")
assert configuration.get(shop, "non-existing") == "hello"
开发者ID:suutari,项目名称:shoop,代码行数:8,代码来源:test_configurations.py
示例12: toggle_all_seeing
def toggle_all_seeing(request):
return_url = request.META["HTTP_REFERER"]
if not request.user.is_superuser:
return HttpResponseRedirect(return_url)
all_seeing_key = "is_all_seeing:%d" % request.user.pk
is_all_seeing = not configuration.get(None, all_seeing_key, False)
configuration.set(None, all_seeing_key, is_all_seeing)
return HttpResponseRedirect(return_url)
开发者ID:gurch101,项目名称:shuup,代码行数:8,代码来源:misc.py
示例13: test_omniscience
def test_omniscience(admin_user, regular_user):
assert not get_person_contact(admin_user).is_all_seeing
configuration.set(None, get_all_seeing_key(admin_user), True)
assert get_person_contact(admin_user).is_all_seeing
assert not get_person_contact(regular_user).is_all_seeing
assert not get_person_contact(None).is_all_seeing
assert not get_person_contact(AnonymousUser()).is_all_seeing
assert not AnonymousContact().is_all_seeing
configuration.set(None, get_all_seeing_key(admin_user), False)
开发者ID:suutari,项目名称:shoop,代码行数:9,代码来源:test_contacts.py
示例14: save
def save(self):
""" Store the fields in configuration """
if not self.is_valid():
return
# that simple, aham
for field, value in six.iteritems(self.cleaned_data):
configuration.set(None, field, value)
开发者ID:gurch101,项目名称:shuup,代码行数:9,代码来源:forms.py
示例15: test_registration_company_multiple_shops
def test_registration_company_multiple_shops(django_user_model, client):
if "shuup.front.apps.registration" not in settings.INSTALLED_APPS:
pytest.skip("shuup.front.apps.registration required in installed apps")
configuration.set(None, "allow_company_registration", True)
configuration.set(None, "company_registration_requires_approval", False)
shop1 = Shop.objects.create(identifier="shop1", status=ShopStatus.ENABLED, domain="shop1.shuup.com")
shop2 = Shop.objects.create(identifier="shop2", status=ShopStatus.ENABLED, domain="shop2.shuup.com")
username = "u-%d" % uuid.uuid4().time
email = "%[email protected]" % username
with override_settings(
SHUUP_REGISTRATION_REQUIRES_ACTIVATION=False,
SHUUP_MANAGE_CONTACTS_PER_SHOP=True,
SHUUP_ENABLE_MULTIPLE_SHOPS=True
):
url = reverse("shuup:registration_register_company")
client.post(url, data={
'company-name': "Test company",
'company-name_ext': "test",
'company-tax_number': "12345",
'company-email': "[email protected]",
'company-phone': "123123",
'company-www': "",
'billing-street': "testa tesat",
'billing-street2': "",
'billing-postal_code': "12345",
'billing-city': "test test",
'billing-region': "",
'billing-region_code': "",
'billing-country': "FI",
'contact_person-first_name': "Test",
'contact_person-last_name': "Tester",
'contact_person-email': email,
'contact_person-phone': "123",
'user_account-username': username,
'user_account-password1': "password",
'user_account-password2': "password",
}, HTTP_HOST="shop1.shuup.com")
user = django_user_model.objects.get(username=username)
contact = PersonContact.objects.get(user=user)
company = CompanyContact.objects.get(members__in=[contact])
assert contact.in_shop(shop1)
assert company.in_shop(shop1)
assert contact.in_shop(shop1, only_registration=True)
assert company.in_shop(shop1, only_registration=True)
assert contact.registered_in(shop1)
assert company.registered_in(shop1)
assert not contact.in_shop(shop2)
assert not company.in_shop(shop2)
assert not contact.in_shop(shop2, only_registration=True)
assert not company.in_shop(shop2, only_registration=True)
assert not contact.registered_in(shop2)
assert not company.registered_in(shop2)
开发者ID:ruqaiya,项目名称:shuup,代码行数:57,代码来源:test_registration_multishop.py
示例16: test_notify_on_company_created
def test_notify_on_company_created(regular_user, allow_company_registration):
if "shuup.front.apps.customer_information" not in settings.INSTALLED_APPS:
pytest.skip("shuup.front.apps.customer_information required in installed apps")
if "shuup.notify" not in settings.INSTALLED_APPS:
pytest.skip("shuup.notify required in installed apps")
configuration.set(None, "allow_company_registration", allow_company_registration)
step = Step(
cond_op=StepConditionOperator.NONE,
actions=[
AddNotification({
"message": {"constant": "It Works. {{ customer_email }}"},
"message_identifier": {"constant": "company_created"},
})
],
next=StepNext.STOP
)
script = Script(
event_identifier=CompanyAccountCreated.identifier, name="Test Script", enabled=True, shop=get_default_shop())
script.set_steps([step])
script.save()
assert not Notification.objects.filter(identifier="company_created").exists()
assert get_person_contact(regular_user)
assert not get_company_contact(regular_user)
client = SmartClient()
client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
company_edit_url = reverse("shuup:company_edit")
if allow_company_registration:
client.soup(company_edit_url)
data = _default_company_data()
data.update(_default_address_data("billing"))
data.update(_default_address_data("shipping"))
response, soup = client.response_and_soup(company_edit_url, data, "post")
assert response.status_code == 302
assert get_company_contact(regular_user)
assert Notification.objects.filter(identifier="company_created").count() == 1
notification = Notification.objects.filter(identifier="company_created").first()
assert notification
assert data["contact-email"] in notification.message
# New save should not add new notifications
response, soup = client.response_and_soup(company_edit_url, data, "post")
assert response.status_code == 302
assert Notification.objects.filter(identifier="company_created").count() == 1
script.delete()
else:
response = client.get(company_edit_url)
assert reverse("shuup:customer_edit") in response.url
assert Notification.objects.filter(identifier="company_created").count() == 0
开发者ID:ruqaiya,项目名称:shuup,代码行数:56,代码来源:test_notify_on_company_created.py
示例17: form_valid
def form_valid(self, form):
if djangoenv.has_installed("shuup.simple_cms") or djangoenv.has_installed("shuup.xtheme"):
content_form = form["content"]
content_form.save()
if djangoenv.has_installed("shuup.notify"):
behavior_form = form["behaviors"]
behavior_form.save()
configuration.set(None, "wizard_content_completed", True)
开发者ID:gurch101,项目名称:shuup,代码行数:10,代码来源:views.py
示例18: test_configuration_set_and_get
def test_configuration_set_and_get():
cache.clear()
shop = get_default_shop()
test_conf_data = {"data": "test"}
configuration.set(shop, "key", test_conf_data)
# Get the configuration via configuration API
assert configuration.get(shop, "key") == test_conf_data
# Check that configuration is saved to database
assert ConfigurationItem.objects.get(shop=shop, key="key").value == test_conf_data
开发者ID:suutari,项目名称:shoop,代码行数:10,代码来源:test_configurations.py
示例19: set_shop_available_languages
def set_shop_available_languages(shop, languages):
available_codes = [code for code, name in settings.LANGUAGES]
# validate languages
for language in languages:
if language not in available_codes:
msg = _("{language_code} is an invalid language code").format(language_code=language)
raise ValueError(msg)
configuration.set(shop, FRONT_AVAILABLE_LANGUAGES_CONFIG_KEY, ",".join(languages))
开发者ID:ruqaiya,项目名称:shuup,代码行数:10,代码来源:translation.py
示例20: test_view_saved_columns
def test_view_saved_columns(rf):
visible_fields = sorted(["id", "name"])
configuration.set(None, "view_configuration_product_saved", True)
for field in visible_fields:
configuration.set(None, "view_configuration_product_%s" % field, True)
listview = ProductListView()
column_names = [c.id for c in sorted(listview.columns, key=lambda x: x.id)]
assert len(listview.columns) == len(visible_fields)
assert column_names == visible_fields
开发者ID:shawnadelic,项目名称:shuup,代码行数:10,代码来源:test_view_settings.py
注:本文中的shuup.configuration.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论