lfs-theme 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. lfs_theme/__init__.py +1 -0
  2. lfs_theme/locale/cs/LC_MESSAGES/django.mo +0 -0
  3. lfs_theme/locale/cs/LC_MESSAGES/django.po +1299 -0
  4. lfs_theme/locale/de/LC_MESSAGES/django.mo +0 -0
  5. lfs_theme/locale/de/LC_MESSAGES/django.po +1466 -0
  6. lfs_theme/locale/en/LC_MESSAGES/django.mo +0 -0
  7. lfs_theme/locale/en/LC_MESSAGES/django.po +1083 -0
  8. lfs_theme/locale/es/LC_MESSAGES/django.mo +0 -0
  9. lfs_theme/locale/es/LC_MESSAGES/django.po +1100 -0
  10. lfs_theme/locale/es_MX/LC_MESSAGES/django.mo +0 -0
  11. lfs_theme/locale/es_MX/LC_MESSAGES/django.po +1236 -0
  12. lfs_theme/locale/fr/LC_MESSAGES/django.mo +0 -0
  13. lfs_theme/locale/fr/LC_MESSAGES/django.po +1223 -0
  14. lfs_theme/locale/it/LC_MESSAGES/django.mo +0 -0
  15. lfs_theme/locale/it/LC_MESSAGES/django.po +1267 -0
  16. lfs_theme/locale/nl/LC_MESSAGES/django.mo +0 -0
  17. lfs_theme/locale/nl/LC_MESSAGES/django.po +1113 -0
  18. lfs_theme/locale/pl/LC_MESSAGES/django.mo +0 -0
  19. lfs_theme/locale/pl/LC_MESSAGES/django.po +1285 -0
  20. lfs_theme/locale/ro/LC_MESSAGES/django.mo +0 -0
  21. lfs_theme/locale/ro/LC_MESSAGES/django.po +1108 -0
  22. lfs_theme/locale/ru/LC_MESSAGES/django.mo +0 -0
  23. lfs_theme/locale/ru/LC_MESSAGES/django.po +1107 -0
  24. lfs_theme/locale/zh_CN/LC_MESSAGES/django.mo +0 -0
  25. lfs_theme/locale/zh_CN/LC_MESSAGES/django.po +1138 -0
  26. lfs_theme/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  27. lfs_theme/locale/zh_TW/LC_MESSAGES/django.po +1139 -0
  28. lfs_theme/navigation.py +81 -0
  29. lfs_theme/package-lock.json +503 -0
  30. lfs_theme/package.json +23 -0
  31. lfs_theme/static/lfs_theme/css/lfs_theme.css +1 -0
  32. lfs_theme/static/lfs_theme/img/favicon.svg +1 -0
  33. lfs_theme/static/lfs_theme/js/addons/bulk_prices.js +26 -0
  34. lfs_theme/static/lfs_theme/js/addons/carousel.js +8 -0
  35. lfs_theme/static/lfs_theme/js/cart.js +49 -0
  36. lfs_theme/static/lfs_theme/js/checkout.js +72 -0
  37. lfs_theme/static/lfs_theme/js/main.js +229 -0
  38. lfs_theme/static/lfs_theme/js/product.js +136 -0
  39. lfs_theme/static/lfs_theme/js/rating.js +24 -0
  40. lfs_theme/static/lfs_theme/scss/_added-to-cart.scss +73 -0
  41. lfs_theme/static/lfs_theme/scss/_base.scss +71 -0
  42. lfs_theme/static/lfs_theme/scss/_breadcrumbs.scss +23 -0
  43. lfs_theme/static/lfs_theme/scss/_breakpoints.scss +18 -0
  44. lfs_theme/static/lfs_theme/scss/_cart.scss +83 -0
  45. lfs_theme/static/lfs_theme/scss/_checkout.scss +130 -0
  46. lfs_theme/static/lfs_theme/scss/_colors.scss +15 -0
  47. lfs_theme/static/lfs_theme/scss/_footer.scss +84 -0
  48. lfs_theme/static/lfs_theme/scss/_header.scss +82 -0
  49. lfs_theme/static/lfs_theme/scss/_menu.scss +290 -0
  50. lfs_theme/static/lfs_theme/scss/_one-page-checkout.scss +75 -0
  51. lfs_theme/static/lfs_theme/scss/_portlets.scss +51 -0
  52. lfs_theme/static/lfs_theme/scss/_product-cards.scss +97 -0
  53. lfs_theme/static/lfs_theme/scss/_product-page.scss +398 -0
  54. lfs_theme/static/lfs_theme/scss/_rating.scss +73 -0
  55. lfs_theme/static/lfs_theme/scss/_search.scss +52 -0
  56. lfs_theme/static/lfs_theme/scss/_swiper.scss +56 -0
  57. lfs_theme/static/lfs_theme/scss/bootstrap-custom.scss +20 -0
  58. lfs_theme/static/lfs_theme/scss/lfs_theme.scss +17 -0
  59. lfs_theme/static/lfs_theme/vendor/bootstrap/bootstrap.bundle.min.js +7 -0
  60. lfs_theme/static/lfs_theme/vendor/bootstrap/bootstrap.bundle.min.js.map +1 -0
  61. lfs_theme/static/lfs_theme/vendor/bootstrap/bootstrap.min.css +5 -0
  62. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/bootstrap-icons.css +2106 -0
  63. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/bootstrap-icons.json +2080 -0
  64. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/bootstrap-icons.min.css +5 -0
  65. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/bootstrap-icons.scss +2118 -0
  66. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/fonts/bootstrap-icons.woff +0 -0
  67. lfs_theme/static/lfs_theme/vendor/bootstrap-icons/fonts/bootstrap-icons.woff2 +0 -0
  68. lfs_theme/static/lfs_theme/vendor/htmx/htmx.min.js +1 -0
  69. lfs_theme/static/lfs_theme/vendor/swiper/swiper-bundle.min.css +13 -0
  70. lfs_theme/static/lfs_theme/vendor/swiper/swiper-bundle.min.js +14 -0
  71. lfs_theme/static/lfs_theme/vendor/swiper/swiper-bundle.min.js.map +1 -0
  72. lfs_theme/templates/404.html +14 -0
  73. lfs_theme/templates/500.html +8 -0
  74. lfs_theme/templates/lfs/addresses/address_form.html +8 -0
  75. lfs_theme/templates/lfs/addresses/address_view.html +35 -0
  76. lfs_theme/templates/lfs/base.html +182 -0
  77. lfs_theme/templates/lfs/cart/added_to_cart.html +101 -0
  78. lfs_theme/templates/lfs/cart/added_to_cart_items.html +102 -0
  79. lfs_theme/templates/lfs/cart/cart.html +22 -0
  80. lfs_theme/templates/lfs/cart/cart_inline.html +310 -0
  81. lfs_theme/templates/lfs/catalog/breadcrumbs.html +42 -0
  82. lfs_theme/templates/lfs/catalog/categories/category/default.html +30 -0
  83. lfs_theme/templates/lfs/catalog/categories/product/default.html +80 -0
  84. lfs_theme/templates/lfs/catalog/categories/product/products_navigation.html +50 -0
  85. lfs_theme/templates/lfs/catalog/category_base.html +45 -0
  86. lfs_theme/templates/lfs/catalog/packing_result.html +5 -0
  87. lfs_theme/templates/lfs/catalog/product_base.html +47 -0
  88. lfs_theme/templates/lfs/catalog/product_navigation.html +16 -0
  89. lfs_theme/templates/lfs/catalog/products/_product_properties.html +24 -0
  90. lfs_theme/templates/lfs/catalog/products/product_inline.html +566 -0
  91. lfs_theme/templates/lfs/catalog/sorting.html +17 -0
  92. lfs_theme/templates/lfs/catalog/top_level_categories.html +10 -0
  93. lfs_theme/templates/lfs/checkout/address_summary.html +11 -0
  94. lfs_theme/templates/lfs/checkout/checkout_cart_inline.html +204 -0
  95. lfs_theme/templates/lfs/checkout/empty_page_checkout.html +24 -0
  96. lfs_theme/templates/lfs/checkout/login.html +107 -0
  97. lfs_theme/templates/lfs/checkout/new_addresses.html +56 -0
  98. lfs_theme/templates/lfs/checkout/new_check_and_pay.html +117 -0
  99. lfs_theme/templates/lfs/checkout/new_payment_and_shipping.html +42 -0
  100. lfs_theme/templates/lfs/checkout/one_page_checkout.html +219 -0
  101. lfs_theme/templates/lfs/checkout/payment_inline.html +20 -0
  102. lfs_theme/templates/lfs/checkout/shipping_inline.html +23 -0
  103. lfs_theme/templates/lfs/checkout/stepper.html +20 -0
  104. lfs_theme/templates/lfs/checkout/thank_you_page.html +34 -0
  105. lfs_theme/templates/lfs/checkout/voucher_inline.html +32 -0
  106. lfs_theme/templates/lfs/contact/contact_form.html +43 -0
  107. lfs_theme/templates/lfs/contact/contact_form_sent.html +22 -0
  108. lfs_theme/templates/lfs/customer/account.html +15 -0
  109. lfs_theme/templates/lfs/customer/addresses.html +62 -0
  110. lfs_theme/templates/lfs/customer/base.html +30 -0
  111. lfs_theme/templates/lfs/customer/data.html +90 -0
  112. lfs_theme/templates/lfs/customer/email.html +29 -0
  113. lfs_theme/templates/lfs/customer/login.html +91 -0
  114. lfs_theme/templates/lfs/customer/order.html +21 -0
  115. lfs_theme/templates/lfs/customer/orders.html +83 -0
  116. lfs_theme/templates/lfs/customer/password.html +28 -0
  117. lfs_theme/templates/lfs/mail/contact_mail.html +28 -0
  118. lfs_theme/templates/lfs/mail/mail.css +35 -0
  119. lfs_theme/templates/lfs/mail/mail_html_footer.html +3 -0
  120. lfs_theme/templates/lfs/mail/mail_text_footer.html +2 -0
  121. lfs_theme/templates/lfs/mail/new_user_mail.html +17 -0
  122. lfs_theme/templates/lfs/mail/new_user_mail.txt +7 -0
  123. lfs_theme/templates/lfs/mail/new_user_mail_subject.txt +1 -0
  124. lfs_theme/templates/lfs/mail/order_details.html +299 -0
  125. lfs_theme/templates/lfs/mail/order_details.txt +63 -0
  126. lfs_theme/templates/lfs/mail/order_paid_mail.html +18 -0
  127. lfs_theme/templates/lfs/mail/order_paid_mail.txt +7 -0
  128. lfs_theme/templates/lfs/mail/order_paid_subject.txt +1 -0
  129. lfs_theme/templates/lfs/mail/order_received_mail.html +18 -0
  130. lfs_theme/templates/lfs/mail/order_received_mail.txt +8 -0
  131. lfs_theme/templates/lfs/mail/order_received_subject.txt +1 -0
  132. lfs_theme/templates/lfs/mail/order_sent_mail.html +18 -0
  133. lfs_theme/templates/lfs/mail/order_sent_mail.txt +8 -0
  134. lfs_theme/templates/lfs/mail/order_sent_subject.txt +1 -0
  135. lfs_theme/templates/lfs/mail/review_added_mail.html +44 -0
  136. lfs_theme/templates/lfs/mail/review_added_mail.txt +15 -0
  137. lfs_theme/templates/lfs/manufacturers/manufacturer.html +29 -0
  138. lfs_theme/templates/lfs/manufacturers/manufacturers.html +48 -0
  139. lfs_theme/templates/lfs/manufacturers/products.html +16 -0
  140. lfs_theme/templates/lfs/order/lfs_order_tmpl.html +229 -0
  141. lfs_theme/templates/lfs/page/page.html +41 -0
  142. lfs_theme/templates/lfs/page/pages.html +28 -0
  143. lfs_theme/templates/lfs/portlets/average_rating.html +18 -0
  144. lfs_theme/templates/lfs/portlets/cart.html +27 -0
  145. lfs_theme/templates/lfs/portlets/categories.html +22 -0
  146. lfs_theme/templates/lfs/portlets/category_children.html +14 -0
  147. lfs_theme/templates/lfs/portlets/delivery_time.html +21 -0
  148. lfs_theme/templates/lfs/portlets/featured.html +62 -0
  149. lfs_theme/templates/lfs/portlets/filter.html +197 -0
  150. lfs_theme/templates/lfs/portlets/forsale.html +63 -0
  151. lfs_theme/templates/lfs/portlets/latest.html +62 -0
  152. lfs_theme/templates/lfs/portlets/pages.html +22 -0
  153. lfs_theme/templates/lfs/portlets/portlet.html +1 -0
  154. lfs_theme/templates/lfs/portlets/recent_products.html +18 -0
  155. lfs_theme/templates/lfs/portlets/related_products.html +27 -0
  156. lfs_theme/templates/lfs/portlets/text_portlet.html +8 -0
  157. lfs_theme/templates/lfs/portlets/topseller.html +27 -0
  158. lfs_theme/templates/lfs/reviews/rating_mail.html +16 -0
  159. lfs_theme/templates/lfs/reviews/rating_mail.txt +8 -0
  160. lfs_theme/templates/lfs/search/livesearch_results.html +47 -0
  161. lfs_theme/templates/lfs/search/search_results.html +101 -0
  162. lfs_theme/templates/lfs/shipping/shipping_portlet.html +19 -0
  163. lfs_theme/templates/lfs/shipping/shipping_tag.html +13 -0
  164. lfs_theme/templates/lfs/shop/google_analytics_ecommerce.html +37 -0
  165. lfs_theme/templates/lfs/shop/google_analytics_tracking.html +11 -0
  166. lfs_theme/templates/lfs/shop/lfs_form.html +6 -0
  167. lfs_theme/templates/lfs/shop/menu.html +8 -0
  168. lfs_theme/templates/lfs/shop/robots.txt +17 -0
  169. lfs_theme/templates/lfs/shop/shop.html +113 -0
  170. lfs_theme/templates/lfs/shop/tabs.html +18 -0
  171. lfs_theme/templates/lfs_carousel/carousel.html +25 -0
  172. lfs_theme/templates/lfs_theme/addons/bulk_prices.html +34 -0
  173. lfs_theme/templates/lfs_theme/addons/bulk_prices_scripts.html +3 -0
  174. lfs_theme/templates/lfs_theme/addons/carousel.html +2 -0
  175. lfs_theme/templates/lfs_theme/addons/cookie_consent_body.html +3 -0
  176. lfs_theme/templates/lfs_theme/addons/cookie_consent_head.html +2 -0
  177. lfs_theme/templates/lfs_theme/addons/cookie_consent_link.html +2 -0
  178. lfs_theme/templates/lfs_theme/addons/cookie_consent_scripts.html +2 -0
  179. lfs_theme/templates/lfs_theme/addons/gtm/added_to_cart_script.html +1 -0
  180. lfs_theme/templates/lfs_theme/addons/gtm/begin_checkout_script.html +1 -0
  181. lfs_theme/templates/lfs_theme/addons/gtm/consent_script.html +2 -0
  182. lfs_theme/templates/lfs_theme/addons/gtm/gtm_noscript.html +1 -0
  183. lfs_theme/templates/lfs_theme/addons/gtm/gtm_script.html +1 -0
  184. lfs_theme/templates/lfs_theme/addons/gtm/purchase_script.html +1 -0
  185. lfs_theme/templates/lfs_theme/addons/gtm/view_item_list_script.html +1 -0
  186. lfs_theme/templates/lfs_theme/addons/gtm/view_item_script.html +1 -0
  187. lfs_theme/templates/lfs_theme/addons/samples.html +14 -0
  188. lfs_theme/templates/lfs_theme/addons/stripe_card_fields.html +25 -0
  189. lfs_theme/templates/lfs_theme/addons/stripe_scripts.html +3 -0
  190. lfs_theme/templates/lfs_theme/categories_footer.html +16 -0
  191. lfs_theme/templates/lfs_theme/mobile_menu.html +11 -0
  192. lfs_theme/templates/lfs_theme/mobile_menu_item.html +28 -0
  193. lfs_theme/templates/lfs_theme/og_image.html +11 -0
  194. lfs_theme/templates/lfs_theme/og_share_card.html +11 -0
  195. lfs_theme/templates/lfs_theme/star_rating.html +2 -0
  196. lfs_theme/templates/lfs_theme/top_nav.html +41 -0
  197. lfs_theme/templates/pagination/pagination.html +26 -0
  198. lfs_theme/templates/registration/password_reset_complete.html +31 -0
  199. lfs_theme/templates/registration/password_reset_confirm.html +62 -0
  200. lfs_theme/templates/registration/password_reset_done.html +28 -0
  201. lfs_theme/templates/registration/password_reset_email.html +15 -0
  202. lfs_theme/templates/registration/password_reset_form.html +38 -0
  203. lfs_theme/templates/reviews/already_rated.html +11 -0
  204. lfs_theme/templates/reviews/average_for_instance.html +7 -0
  205. lfs_theme/templates/reviews/review_form.html +72 -0
  206. lfs_theme/templates/reviews/review_preview.html +67 -0
  207. lfs_theme/templates/reviews/reviews_for_instance.html +36 -0
  208. lfs_theme/templates/reviews/thank_you.html +17 -0
  209. lfs_theme/templatetags/__init__.py +0 -0
  210. lfs_theme/templatetags/lfs_theme_tags.py +227 -0
  211. lfs_theme/tests/__init__.py +0 -0
  212. lfs_theme/tests/settings.py +86 -0
  213. lfs_theme/tests/test_addons.py +30 -0
  214. lfs_theme/tests/test_category_page.py +66 -0
  215. lfs_theme/tests/test_contact.py +24 -0
  216. lfs_theme/tests/test_layout.py +63 -0
  217. lfs_theme/tests/test_manufacturers.py +68 -0
  218. lfs_theme/tests/test_mobile_menu.py +32 -0
  219. lfs_theme/tests/test_navigation.py +145 -0
  220. lfs_theme/tests/test_organization.py +42 -0
  221. lfs_theme/tests/test_page.py +25 -0
  222. lfs_theme/tests/test_pages.py +22 -0
  223. lfs_theme/tests/test_product_group.py +131 -0
  224. lfs_theme/tests/test_product_images.py +103 -0
  225. lfs_theme/tests/test_star_rating.py +100 -0
  226. lfs_theme/tests/test_titles.py +60 -0
  227. lfs_theme/tests/urls.py +14 -0
  228. lfs_theme/tests/urls_without_theme.py +5 -0
  229. lfs_theme/urls.py +9 -0
  230. lfs_theme/views.py +20 -0
  231. lfs_theme-1.0.0.dist-info/METADATA +73 -0
  232. lfs_theme-1.0.0.dist-info/RECORD +235 -0
  233. lfs_theme-1.0.0.dist-info/WHEEL +5 -0
  234. lfs_theme-1.0.0.dist-info/licenses/LICENSE.txt +27 -0
  235. lfs_theme-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,227 @@
1
+ """Template tags of the LFS default theme: navigation, footer, slots, optional add-ons, and mail footers."""
2
+
3
+ from typing import Any
4
+
5
+ from django.apps import apps
6
+ from django.conf import settings
7
+ from django.core.cache import cache
8
+ from django.forms import boundfield
9
+ from django.template import Context, Library, Node, TemplateSyntaxError
10
+ from django.template.base import Parser, Token
11
+ from django.template.loader import get_template, render_to_string
12
+ from django.urls import NoReverseMatch, reverse
13
+ from django.utils.safestring import SafeString, mark_safe
14
+ from django.utils.translation import get_language
15
+
16
+ from crispy_forms.exceptions import CrispyError
17
+ from crispy_forms.utils import TEMPLATE_PACK
18
+ from portlets.models import Slot
19
+
20
+ import lfs.catalog.utils
21
+ import lfs.core.utils
22
+ import lfs.marketing.utils
23
+ from lfs.catalog.models import Product, StaticBlock
24
+ from lfs_theme.navigation import get_category_tree, get_path
25
+
26
+ register = Library()
27
+
28
+
29
+ @register.simple_tag(takes_context=True)
30
+ def addon_include(context: Context, app_label: str, template_name: str) -> SafeString:
31
+ """Render ``template_name`` with the current context only when the add-on ``app_label`` is installed.
32
+
33
+ The theme supports optional add-ons (bulk prices, samples, carousel, Google Tag Manager, ...). Their template tags
34
+ can only be loaded when they are installed, so the parts that use them live in their own templates under
35
+ ``lfs_theme/addons/``, which this tag renders only for installed add-ons.
36
+ """
37
+ if not apps.is_installed(app_label):
38
+ return mark_safe("")
39
+ return mark_safe(render_to_string(template_name, context.flatten(), request=context.get("request")))
40
+
41
+
42
+ @register.simple_tag
43
+ def addon_installed(app_label: str) -> bool:
44
+ """Return whether the add-on ``app_label`` is installed, for markup that only an add-on's JavaScript uses."""
45
+ return apps.is_installed(app_label)
46
+
47
+
48
+ @register.simple_tag
49
+ def currency_code() -> str:
50
+ """Return the shop's currency as ISO 4217 code (setting ``LFS_CURRENCY``), for structured data."""
51
+ return getattr(settings, "LFS_CURRENCY", "EUR")
52
+
53
+
54
+ @register.simple_tag(takes_context=True)
55
+ def site_name(context: Context) -> str:
56
+ """Return the shop's name, appended to page titles and given as og:site_name."""
57
+ return lfs.core.utils.get_default_shop(context.get("request")).name
58
+
59
+
60
+ @register.inclusion_tag("lfs_theme/categories_footer.html")
61
+ def categories_footer() -> dict[str, Any]:
62
+ """Display the top-level categories and their children in the footer."""
63
+ return {"categories": get_category_tree()["categories"]}
64
+
65
+
66
+ class FooterNode(Node):
67
+ """Put the first three static blocks into the context as ``footer``, for the footer columns."""
68
+
69
+ def render(self, context: Context) -> str:
70
+ """Set ``footer`` in the context; renders nothing."""
71
+ context["footer"] = StaticBlock.objects.all()[:3]
72
+ return ""
73
+
74
+
75
+ @register.tag("footer")
76
+ def do_footer(parser: Parser, token: Token) -> FooterNode:
77
+ """Put the first three static blocks into the context as ``footer``."""
78
+ bits = token.split_contents()
79
+ if len(bits) != 1:
80
+ raise TemplateSyntaxError(f"{bits[0]} tag needs no arguments")
81
+ return FooterNode()
82
+
83
+
84
+ class TopsellerNode(Node):
85
+ """Put the top sellers into the context as ``topseller``, in rows of five.
86
+
87
+ On a product or category page the top sellers of that category, otherwise those of the whole shop.
88
+ """
89
+
90
+ def render(self, context: Context) -> str:
91
+ """Set ``topseller`` in the context; renders nothing."""
92
+ obj = context.get("category") or context.get("product")
93
+ if obj is None:
94
+ topseller = lfs.marketing.utils.get_topseller()
95
+ elif isinstance(obj, Product):
96
+ category = lfs.catalog.utils.get_current_product_category(context.get("request"), obj)
97
+ topseller = lfs.marketing.utils.get_topseller_for_category(category, 5)
98
+ else:
99
+ topseller = lfs.marketing.utils.get_topseller_for_category(obj, 5)
100
+ context["topseller"] = lfs.core.utils.getLOL(topseller, 5)
101
+ return ""
102
+
103
+
104
+ @register.tag("topseller")
105
+ def do_topseller(parser: Parser, token: Token) -> TopsellerNode:
106
+ """Put the top sellers into the context as ``topseller``."""
107
+ bits = token.split_contents()
108
+ if len(bits) != 1:
109
+ raise TemplateSyntaxError(f"{bits[0]} tag needs no arguments")
110
+ return TopsellerNode()
111
+
112
+
113
+ @register.inclusion_tag("lfs_theme/top_nav.html", takes_context=True)
114
+ def top_nav(context: Context) -> dict[str, Any]:
115
+ """Build the desktop menu and the drawer of the mobile menu from the cached category tree.
116
+
117
+ The categories on the path to the current one (the page's category, or the product's) are marked as current.
118
+ The drawer names the URL its levels are loaded from, and the current category, which main.js opens; a shop that
119
+ does not include the theme's URLs gets the levels inside the page.
120
+ """
121
+ request = context.get("request")
122
+ tree = get_category_tree()
123
+ current = context.get("category")
124
+ if current is None and context.get("product") is not None:
125
+ current = context["product"].get_current_category(request)
126
+ path = get_path(tree["categories"], current.id if current else None)
127
+
128
+ try:
129
+ mobile_menu_url = f"{reverse('lfs_theme_mobile_menu')}?v={tree['version']}-{get_language()}"
130
+ except NoReverseMatch:
131
+ mobile_menu_url = ""
132
+
133
+ return {
134
+ "categories": tree["categories"],
135
+ "current_ids": {category["id"] for category in path},
136
+ "current_url": path[-1]["url"] if path else "",
137
+ "mobile_menu_url": mobile_menu_url,
138
+ }
139
+
140
+
141
+ @register.filter(name="as_crispy_field_no_label")
142
+ def as_crispy_field_no_label(
143
+ field: boundfield.BoundField, template_pack: str = TEMPLATE_PACK, label_class: str = "", field_class: str = ""
144
+ ) -> SafeString:
145
+ """Render a form field like crispy-forms' ``as_crispy_field``, but without its label."""
146
+ if not isinstance(field, boundfield.BoundField) and settings.DEBUG:
147
+ raise CrispyError("|as_crispy_field_no_label got passed an invalid or inexistent field")
148
+
149
+ attributes = {
150
+ "field": field,
151
+ "form_show_errors": True,
152
+ "form_show_labels": False,
153
+ "label_class": label_class,
154
+ "field_class": field_class,
155
+ }
156
+ helper = getattr(field.form, "helper", None)
157
+ template_path = None
158
+ if helper is not None:
159
+ attributes.update(helper.get_attributes(template_pack))
160
+ template_path = helper.field_template
161
+ template = get_template(template_path or f"{template_pack}/field.html")
162
+ return template.render(attributes)
163
+
164
+
165
+ class SlotsInformationNode(Node):
166
+ """Put ``SlotLeft``, ``SlotRight`` (whether the slot has portlets) into the context.
167
+
168
+ For the current category, product, or page; otherwise for the shop. Results are cached.
169
+ """
170
+
171
+ def render(self, context: Context) -> str:
172
+ """Set one ``Slot<name>`` flag per slot in the context; renders nothing."""
173
+ obj = context.get("category") or context.get("product") or context.get("page")
174
+ if obj is None or obj.__class__.__name__.lower() not in ("category", "product", "page"):
175
+ obj = lfs.core.utils.get_default_shop(context.get("request"))
176
+
177
+ slots = cache.get("slots")
178
+ if slots is None:
179
+ slots = list(Slot.objects.all())
180
+ cache.set("slots", slots)
181
+
182
+ for slot in slots:
183
+ cache_key = f"has-portlets-{obj.__class__.__name__}-{obj.id}-{slot.name}"
184
+ has_portlets = cache.get(cache_key)
185
+ if has_portlets is None:
186
+ has_portlets = slot.has_portlets(obj)
187
+ cache.set(cache_key, has_portlets)
188
+ context[f"Slot{slot.name}"] = has_portlets
189
+ return ""
190
+
191
+
192
+ @register.tag("slots_information")
193
+ def do_slots_information(parser: Parser, token: Token) -> SlotsInformationNode:
194
+ """Put the ``Slot<name>`` flags of the current object into the context."""
195
+ bits = token.split_contents()
196
+ if len(bits) != 1:
197
+ raise TemplateSyntaxError(f"{bits[0]} tag needs no arguments")
198
+ return SlotsInformationNode()
199
+
200
+
201
+ @register.inclusion_tag("lfs/mail/mail_html_footer.html", takes_context=True)
202
+ def email_html_footer(context: Context) -> dict[str, Any]:
203
+ """Render the HTML footer of the shop's e-mails."""
204
+ return {"shop": lfs.core.utils.get_default_shop(context.get("request"))}
205
+
206
+
207
+ @register.inclusion_tag("lfs/mail/mail_text_footer.html", takes_context=True)
208
+ def email_text_footer(context: Context) -> dict[str, Any]:
209
+ """Render the plain-text footer of the shop's e-mails."""
210
+ return {"shop": lfs.core.utils.get_default_shop(context.get("request"))}
211
+
212
+
213
+ @register.filter
214
+ def cart_delivery_time(cart: Any, request: Any) -> Any:
215
+ """Return the longest delivery time of the cart's products, for the checkout summary; None without a cart."""
216
+ return cart.get_delivery_time(request) if cart else None
217
+
218
+
219
+ @register.inclusion_tag("lfs_theme/star_rating.html")
220
+ def star_rating(score: float | None) -> dict[str, Any]:
221
+ """Draw ``score`` (0 to 5) as five Bootstrap Icons stars, rounded to half stars.
222
+
223
+ Each star is "fill", "half", or "empty"; ``score`` is passed on for the label that screen readers read out.
224
+ """
225
+ halves = round((score or 0) * 2)
226
+ kinds = ["fill" if halves >= 2 * i else "half" if halves == 2 * i - 1 else "empty" for i in range(1, 6)]
227
+ return {"stars": kinds, "score": score or 0}
File without changes
@@ -0,0 +1,86 @@
1
+ """Settings for the theme's tests: the core, its required add-ons, and this theme; no optional add-ons."""
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+ SECRET_KEY = "test-only"
5
+ DEBUG = False
6
+ ALLOWED_HOSTS = ["testserver", "localhost", "127.0.0.1"]
7
+ SITE_ID = 1
8
+ DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
9
+ DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
10
+ CACHES = {"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}}
11
+ INSTALLED_APPS = [
12
+ "lfs_theme", "crispy_forms", "crispy_bootstrap5", "compressor",
13
+ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions",
14
+ "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.sites", "django.contrib.flatpages",
15
+ "django.contrib.redirects", "django.contrib.sitemaps", "django_countries",
16
+ "reviews", "portlets",
17
+ "lfs.addresses", "lfs.caching", "lfs.cart", "lfs.catalog", "lfs.checkout", "lfs.core", "lfs.criteria",
18
+ "lfs.customer", "lfs.customer_tax", "lfs.discounts", "lfs.export", "lfs.gross_price", "lfs.mail", "lfs.manage",
19
+ "lfs.marketing", "lfs.manufacturer", "lfs.net_price", "lfs.order", "lfs.page", "lfs.payment", "lfs.portlet",
20
+ "lfs.search", "lfs.shipping", "lfs.supplier", "lfs.tax", "lfs.tests", "lfs.utils", "lfs.voucher",
21
+ "lfs_contact", "lfs_order_numbers", "localflavor", "postal", "lfs_paypal", "captcha",
22
+ ]
23
+ MIDDLEWARE = [
24
+ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
25
+ "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
26
+ "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
27
+ ]
28
+ ROOT_URLCONF = "lfs_theme.tests.urls"
29
+ STATIC_URL = "static/"
30
+ STATICFILES_FINDERS = ("django.contrib.staticfiles.finders.AppDirectoriesFinder", "compressor.finders.CompressorFinder")
31
+ COMPRESS_ENABLED = False
32
+ TEMPLATES = [{
33
+ "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [], "APP_DIRS": True,
34
+ "OPTIONS": {"context_processors": [
35
+ "django.template.context_processors.debug", "django.template.context_processors.request",
36
+ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages",
37
+ "lfs.core.context_processors.main"]},
38
+ }]
39
+ AUTHENTICATION_BACKENDS = ["lfs.customer.auth.EmailBackend", "django.contrib.auth.backends.ModelBackend"]
40
+ USE_TZ = True
41
+ TIME_ZONE = "UTC"
42
+ LANGUAGE_CODE = "en"
43
+ SESSION_SERIALIZER = "lfs.core.pickle_serializer.PickleSerializer"
44
+ CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
45
+ CRISPY_TEMPLATE_PACK = "bootstrap5"
46
+ LFS_CURRENCY = "EUR"
47
+ LFS_AFTER_ADD_TO_CART = "lfs_added_to_cart"
48
+ LFS_RECENT_PRODUCTS_LIMIT = 5
49
+ LFS_ORDER_NUMBER_GENERATOR = "lfs_order_numbers.models.OrderNumberGenerator"
50
+ LFS_DOCS = ""
51
+ LFS_INVOICE_COMPANY_NAME_REQUIRED = False
52
+ LFS_INVOICE_EMAIL_REQUIRED = True
53
+ LFS_INVOICE_PHONE_REQUIRED = True
54
+ LFS_SHIPPING_COMPANY_NAME_REQUIRED = False
55
+ LFS_SHIPPING_EMAIL_REQUIRED = False
56
+ LFS_SHIPPING_PHONE_REQUIRED = False
57
+ LFS_PAYMENT_METHOD_PROCESSORS = [["lfs_paypal.processor.PayPalProcessor", _("PayPal")]]
58
+ LFS_PRICE_CALCULATORS = [
59
+ ["lfs.gross_price.calculator.GrossPriceCalculator", _("Price includes tax")],
60
+ ["lfs.net_price.calculator.NetPriceCalculator", _("Price excludes tax")],
61
+ ]
62
+ LFS_SHIPPING_METHOD_PRICE_CALCULATORS = [
63
+ ["lfs.shipping.calculator.GrossShippingMethodPriceCalculator", _("Price includes tax")],
64
+ ["lfs.shipping.calculator.NetShippingMethodPriceCalculator", _("Price excludes tax")],
65
+ ]
66
+ LFS_UNITS = ["kg", "l", "m", "Stück"]
67
+ LFS_PRICE_UNITS = LFS_BASE_PRICE_UNITS = LFS_PACKING_UNITS = LFS_UNITS
68
+ LFS_CRITERIA = [
69
+ ["lfs.criteria.models.CartPriceCriterion", _("Cart Price")],
70
+ ["lfs.criteria.models.CountryCriterion", _("Country")],
71
+ ["lfs.criteria.models.WeightCriterion", _("Weight")],
72
+ ["lfs.criteria.models.ShippingMethodCriterion", _("Shipping Method")],
73
+ ["lfs.criteria.models.PaymentMethodCriterion", _("Payment Method")],
74
+ ]
75
+ PAYPAL_TEST = True
76
+ STATIC_ROOT = "/tmp/lfs-theme-tests/static"
77
+ MEDIA_ROOT = "/tmp/lfs-theme-tests/media"
78
+ MEDIA_URL = "media/"
79
+ PAYPAL_MODE = "sandbox"
80
+ PAYPAL_CLIENT_ID = "test"
81
+ PAYPAL_CLIENT_SECRET = "test" # not a real secret
82
+ LOGIN_URL = "/login/"
83
+ REVIEWS_SHOW_PREVIEW = False
84
+ REVIEWS_IS_NAME_REQUIRED = False
85
+ REVIEWS_IS_EMAIL_REQUIRED = False
86
+ REVIEWS_IS_MODERATED = False
@@ -0,0 +1,30 @@
1
+ """Optional add-ons: their markup appears only when they are installed, and pages render without them."""
2
+
3
+ import pytest
4
+ from django.conf import settings
5
+ from django.core.management import call_command
6
+ from django.test import override_settings
7
+ from django.urls import reverse
8
+
9
+
10
+ @pytest.fixture
11
+ def shop(db):
12
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
13
+
14
+
15
+ def test_home_page_renders_without_any_optional_add_on(client, shop):
16
+ html = client.get(reverse("lfs_shop_view")).content.decode()
17
+ assert "lfs_cookie_consent" not in html
18
+ assert "lfs_gtm" not in html
19
+ assert "swiper" not in html
20
+
21
+
22
+ @pytest.mark.skipif(
23
+ not __import__("importlib").util.find_spec("lfs_cookie_consent"), reason="needs the lfs_cookie_consent add-on"
24
+ )
25
+ def test_cookie_consent_is_included_when_installed(client, shop):
26
+ with override_settings(INSTALLED_APPS=[*settings.INSTALLED_APPS, "lfs_cookie_consent"]):
27
+ html = client.get(reverse("lfs_shop_view")).content.decode()
28
+ assert "lfs_cookie_consent/lfs_cookie_consent.css" in html
29
+ assert "lfs_cookie_consent/lfs_cookie_consent.js" in html
30
+ assert 'class="cookie-settings-link"' in html
@@ -0,0 +1,66 @@
1
+ """Category page: Open Graph tags and sizes of the product images."""
2
+
3
+ import re
4
+
5
+ import pytest
6
+ from django.core.management import call_command
7
+ from django.urls import reverse
8
+
9
+ from lfs_theme.tests.test_product_images import png
10
+ from lfs.catalog.models import Category, Image, Product
11
+ from lfs.core.models import Shop
12
+
13
+ BASE = "http://testserver"
14
+
15
+
16
+ @pytest.fixture
17
+ def categories(db, settings, tmp_path):
18
+ """A category with an image and a product, and a subcategory-free one without an image."""
19
+ settings.MEDIA_ROOT = tmp_path
20
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
21
+ terraces = Category.objects.create(name="Terraces", slug="terraces", meta_title="Wooden terraces")
22
+ terraces.image.save("terraces.png", png(1200, 800))
23
+ product = Product.objects.create(name="Decking board", slug="decking-board", active=True, price=10)
24
+ Image(content=product, title="Decking.jpg", position=0).image.save("decking.png", png(800, 600))
25
+ terraces.products.add(product)
26
+ Category.objects.create(name="Fences", slug="fences")
27
+ return terraces
28
+
29
+
30
+ def head_meta(html):
31
+ """Return the og:* meta tags of a page as a dict."""
32
+ return dict(re.findall(r'<meta property="(og:[a-z_:]+)" content="([^"]*)"', html))
33
+
34
+
35
+ def render(client, slug):
36
+ response = client.get(reverse("lfs_category", kwargs={"slug": slug}))
37
+ assert response.status_code == 200
38
+ return response.content.decode()
39
+
40
+
41
+ def test_category_has_title_type_and_its_image_for_open_graph(client, categories):
42
+ og = head_meta(render(client, "terraces"))
43
+ assert og["og:title"] == "Wooden terraces"
44
+ assert og["og:type"] == "website"
45
+ assert re.fullmatch(rf"{BASE}/media/images/terraces\w*\.png", og["og:image"])
46
+ assert (og["og:image:width"], og["og:image:height"]) == ("1200", "800")
47
+
48
+
49
+ def test_category_without_image_uses_the_shop_image(client, categories):
50
+ shop = Shop.objects.get()
51
+ shop.image.save("shop.png", png(1200, 630))
52
+ og = head_meta(render(client, "fences"))
53
+ assert og["og:title"] == "Fences"
54
+ assert re.fullmatch(rf"{BASE}/media/\S*shop\w*\.png", og["og:image"])
55
+ assert (og["og:image:width"], og["og:image:height"]) == ("1200", "630")
56
+
57
+
58
+ def test_category_without_image_has_no_og_image_when_the_shop_has_none(client, categories):
59
+ assert "og:image" not in head_meta(render(client, "fences"))
60
+
61
+
62
+ def test_product_tiles_have_the_real_thumbnail_size(client, categories):
63
+ html = render(client, "terraces")
64
+ tile = re.search(r'<div class="product-image[^"]*">\s*(<img[^>]*>)', html).group(1)
65
+ assert 'width="200"' in tile and 'height="150"' in tile
66
+ assert 'alt="Decking board"' in tile
@@ -0,0 +1,24 @@
1
+ """Contact form: title, description and Open Graph."""
2
+
3
+ import pytest
4
+ from django.core.management import call_command
5
+ from django.urls import reverse
6
+ from django.utils import translation
7
+
8
+ from lfs_theme.tests.test_titles import title_and_og
9
+
10
+
11
+ @pytest.fixture
12
+ def shop(db):
13
+ """The default shop."""
14
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
15
+
16
+
17
+ def test_contact_has_a_description_and_open_graph(client, shop):
18
+ with translation.override("de"):
19
+ title, og = title_and_og(client, reverse("lfs_contact_form"))
20
+ html = client.get(reverse("lfs_contact_form")).content.decode()
21
+ assert title == "Kontaktformular | LFS"
22
+ assert og["og:title"] == "Kontaktformular"
23
+ assert og["og:type"] == "website"
24
+ assert '<meta name="description" content="Fragen? Schreiben Sie uns' in html
@@ -0,0 +1,63 @@
1
+ """Header and footer: shop name, cart badge, and footer links from the shop's Footer actions."""
2
+
3
+ import pytest
4
+ from django.core.management import call_command
5
+ from django.urls import reverse
6
+
7
+ from lfs.core.models import Action, ActionGroup
8
+
9
+
10
+ @pytest.fixture
11
+ def shop(db):
12
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
13
+
14
+
15
+ def test_header_shows_the_shop_name_without_a_logo(client, shop):
16
+ html = client.get(reverse("lfs_shop_view")).content.decode()
17
+ assert '<span class="shop-name">LFS</span>' in html
18
+
19
+
20
+ def test_cart_badge_is_hidden_while_the_cart_is_empty(client, shop):
21
+ html = client.get(reverse("lfs_shop_view")).content.decode()
22
+ assert '<span class="badge rounded-pill bg-danger cart-items-count" hidden>' in html
23
+
24
+
25
+ def test_footer_links_come_from_the_footer_actions(client, shop):
26
+ group, _ = ActionGroup.objects.get_or_create(name="Footer")
27
+ Action.objects.create(group=group, title="Imprint", link="/page/imprint/", active=True, position=1)
28
+ html = client.get(reverse("lfs_shop_view")).content.decode()
29
+ assert '<a href="/page/imprint/">Imprint</a>' in html
30
+ assert "/page/agb" not in html and "/page/datenschutz" not in html
31
+
32
+
33
+ def _account_menu(html: str) -> str:
34
+ """Return the markup of the account menu behind the person icon."""
35
+ start = html.index('<div class="dropdown account-menu">')
36
+ return html[start : html.index("</ul>", start)]
37
+
38
+
39
+ def test_account_menu_holds_my_account_manage_and_logout_for_a_superuser(admin_client, shop):
40
+ html = admin_client.get(reverse("lfs_shop_view")).content.decode()
41
+
42
+ menu = _account_menu(html)
43
+ for name in ("lfs_my_account", "lfs_manage_dashboard", "lfs_logout"):
44
+ assert f'href="{reverse(name)}"' in menu
45
+ assert 'class="management"' not in html
46
+
47
+
48
+ def test_account_menu_has_no_manage_link_for_a_customer(client, django_user_model, shop):
49
+ client.force_login(django_user_model.objects.create_user("joe", "joe@example.com", "secret"))
50
+
51
+ menu = _account_menu(client.get(reverse("lfs_shop_view")).content.decode())
52
+
53
+ assert f'href="{reverse("lfs_logout")}"' in menu
54
+ assert reverse("lfs_manage_dashboard") not in menu
55
+
56
+
57
+ def test_mobile_menu_button_sits_next_to_the_cart(client, shop):
58
+ html = client.get(reverse("lfs_shop_view")).content.decode()
59
+
60
+ actions = html[html.index('<div class="header-actions">') :]
61
+ actions = actions[: actions.index("</div>")]
62
+ assert actions.index('class="cart-link"') < actions.index('class="mobile-nav-toggle-btn"')
63
+ assert html.count('class="mobile-nav-toggle-btn"') == 1
@@ -0,0 +1,68 @@
1
+ """Manufacturer list: German labels, title, description and Open Graph."""
2
+
3
+ import re
4
+
5
+ import pytest
6
+ from django.core.management import call_command
7
+ from django.urls import reverse
8
+ from django.utils import translation
9
+
10
+ from lfs_theme.tests.test_category_page import BASE, head_meta
11
+ from lfs_theme.tests.test_product_images import png
12
+ from lfs_theme.tests.test_titles import title_and_og
13
+
14
+ from lfs.catalog.models import Product
15
+ from lfs.manufacturer.models import Manufacturer
16
+
17
+
18
+ @pytest.fixture
19
+ def manufacturer(db):
20
+ """A manufacturer with two active products."""
21
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
22
+ auma = Manufacturer.objects.create(name="auma", slug="auma")
23
+ for slug in ("a", "b"):
24
+ Product.objects.create(name=slug, slug=slug, active=True, price=1, manufacturer=auma)
25
+ return auma
26
+
27
+
28
+ def test_product_count_is_labelled_products_in_german(client, manufacturer):
29
+ with translation.override("de"):
30
+ response = client.get(reverse("lfs_manufacturers"), HTTP_ACCEPT_LANGUAGE="de")
31
+ html = " ".join(response.content.decode().split())
32
+ assert "2 Produkte" in html
33
+ assert "Monate" not in html
34
+
35
+
36
+ def test_list_has_its_own_title_description_and_open_graph(client, manufacturer):
37
+ with translation.override("de"):
38
+ title, og = title_and_og(client, reverse("lfs_manufacturers"))
39
+ html = client.get(reverse("lfs_manufacturers")).content.decode()
40
+ assert title == "Hersteller | LFS"
41
+ assert og["og:title"] == "Hersteller"
42
+ assert og["og:type"] == "website"
43
+ assert '<meta name="description" content="Alle Hersteller und Marken bei LFS' in html
44
+
45
+
46
+ def test_manufacturer_page_has_title_and_type(client, manufacturer):
47
+ response = client.get(reverse("lfs_manufacturer", kwargs={"slug": "auma"}))
48
+ assert response.status_code == 200
49
+ og = head_meta(response.content.decode())
50
+ assert og["og:title"] == "auma"
51
+ assert og["og:type"] == "website"
52
+
53
+
54
+ def test_manufacturer_image_is_used_for_open_graph(client, manufacturer, settings, tmp_path):
55
+ settings.MEDIA_ROOT = tmp_path
56
+ manufacturer.image.save("auma.png", png(600, 400))
57
+ og = head_meta(client.get(reverse("lfs_manufacturer", kwargs={"slug": "auma"})).content.decode())
58
+ assert re.fullmatch(rf"{BASE}/media/\S*auma\w*\.png", og["og:image"])
59
+ assert (og["og:image:width"], og["og:image:height"]) == ("600", "400")
60
+
61
+
62
+ def test_list_leaves_out_manufacturers_without_active_products(client, manufacturer):
63
+ remmers = Manufacturer.objects.create(name="Remmers", slug="remmers")
64
+ Product.objects.create(name="Lasur", slug="lasur", active=False, price=1, manufacturer=remmers)
65
+ Manufacturer.objects.create(name="menz", slug="menz")
66
+ html = client.get(reverse("lfs_manufacturers")).content.decode()
67
+ assert "/manufacturer-auma/" in html
68
+ assert "/manufacturer-remmers/" not in html and "/manufacturer-menz/" not in html
@@ -0,0 +1,32 @@
1
+ """Mobile category menu: the menu button controls the drawer; its levels are tested in test_navigation."""
2
+
3
+ import re
4
+
5
+ import pytest
6
+ from django.core.management import call_command
7
+ from django.urls import reverse
8
+
9
+ from lfs.catalog.models import Category
10
+
11
+
12
+ @pytest.fixture
13
+ def garden(db):
14
+ """Garden with the subcategory Tools."""
15
+ call_command("loaddata", "lfs_shop.xml", verbosity=0)
16
+ garden = Category.objects.create(name="Garden", slug="garden")
17
+ Category.objects.create(name="Tools", slug="tools", parent=garden)
18
+ return garden
19
+
20
+
21
+ def drawer(html: str) -> str:
22
+ """Return the markup of the mobile menu drawer."""
23
+ start = html.index('<nav class="mobile-nav-sidebar"')
24
+ return html[start : html.index("</nav>", start)]
25
+
26
+
27
+ def test_menu_button_controls_the_drawer_and_reports_it_is_closed(client, garden):
28
+ html = client.get(reverse("lfs_shop_view")).content.decode()
29
+
30
+ button = re.search(r'<button type="button" class="mobile-nav-toggle-btn"[^>]*>', html).group(0)
31
+ assert 'aria-controls="mobile-nav"' in button and 'aria-expanded="false"' in button
32
+ assert 'id="mobile-nav"' in drawer(html)