Пример #1
0
def test_admin_set_shop_language(admin_user):
    original_language = get_language()
    shop = factories.get_default_shop()
    client = SmartClient()
    admin_user.set_password("admin")
    admin_user.save()
    client.login(username=admin_user.username, password="******")

    with override_settings(LANGUAGES=[("it", "Italian"), ("fr", "French"),
                                      ("fi", "Finnish"),
                                      ("pt-br", "Portuguese (Brazil)")],
                           LANGUAGE_CODE="it",
                           PARLER_DEFAULT_LANGUAGE_CODE="it"):
        assert get_shop_available_languages(shop) == []
        edit_url = reverse("shuup_admin:shop.edit", kwargs=dict(pk=shop.id))
        payload = {
            "translation_config-available_languages": ["pt-br", "fi"],
            "base-public_name__it":
            shop.public_name,
            "base-name__it":
            shop.name,
            "base-status":
            "1",
            "base-currency":
            shop.currency,
            "product_list_facets-filter_products_by_category_ordering":
            "1",
            "product_list_facets-filter_products_by_price_ordering":
            "1",
            "product_list_facets-limit_product_list_page_size_ordering":
            "1",
            "product_list_facets-sort_products_by_price_ordering":
            "1",
            "product_list_facets-sort_products_by_name_ordering":
            "1",
            "product_list_facets-sort_products_by_ascending_created_date_ordering":
            "1",
            "product_list_facets-sort_products_by_date_created_ordering":
            "1",
            "product_list_facets-filter_products_by_manufacturer_ordering":
            "1",
            "product_list_facets-filter_products_by_variation_value_ordering":
            "1",
            "order_configuration-order_reference_number_length":
            "20",
            "order_configuration-order_reference_number_prefix":
            "10"
        }
        response = client.post(edit_url, data=payload)
        assert response.status_code == 302
        assert get_shop_available_languages(shop) == ["pt-br", "fi"]

    activate(original_language)
Пример #2
0
def test_admin_set_shop_language(admin_user):
    original_language = get_language()
    shop = factories.get_default_shop()
    client = SmartClient()
    admin_user.set_password("admin")
    admin_user.save()
    client.login(username=admin_user.username, password="******")

    with override_settings(
        LANGUAGES=[
            ("it", "Italian"),
            ("fr", "French"),
            ("fi", "Finnish"),
            ("pt-br", "Portuguese (Brazil)")
        ],
        LANGUAGE_CODE="it",
        PARLER_DEFAULT_LANGUAGE_CODE = "it"
    ):
        assert get_shop_available_languages(shop) == []
        edit_url = reverse("shuup_admin:shop.edit", kwargs=dict(pk=shop.id))
        payload = {
            "translation_config-available_languages": ["pt-br", "fi"],
            "base-public_name__it": shop.public_name,
            "base-name__it": shop.name,
            "base-status": "1",
            "base-currency": shop.currency,
            "product_list_facets-filter_products_by_category_ordering": "1",
            "product_list_facets-filter_products_by_price_ordering": "1",
            "product_list_facets-limit_product_list_page_size_ordering": "1",
            "product_list_facets-sort_products_by_price_ordering": "1",
            "product_list_facets-sort_products_by_name_ordering": "1",
            "product_list_facets-sort_products_by_ascending_created_date_ordering": "1",
            "product_list_facets-sort_products_by_date_created_ordering": "1",
            "product_list_facets-filter_products_by_manufacturer_ordering": "1",
            "product_list_facets-filter_products_by_variation_value_ordering": "1",
            "order_configuration-order_reference_number_length": "20",
            "order_configuration-order_reference_number_prefix": "10"
        }
        response = client.post(edit_url, data=payload)
        assert response.status_code == 302
        assert get_shop_available_languages(shop) == ["pt-br", "fi"]

    activate(original_language)
Пример #3
0
 def get_form_defs(self):
     if not self.object.pk:
         return
     yield TemplatedFormDef(
         name=self.name,
         form_class=self.form,
         template_name="shuup/front/admin/translation.jinja",
         required=False,
         kwargs={"initial": dict(available_languages=get_shop_available_languages(self.object))}
     )
Пример #4
0
 def get_form_defs(self):
     if not self.object.pk:
         return
     yield TemplatedFormDef(
         name=self.name,
         form_class=self.form,
         template_name="shuup/front/admin/translation.jinja",
         required=False,
         kwargs={
             "initial":
             dict(available_languages=get_shop_available_languages(
                 self.object))
         })