Compare commits

...
Author SHA1 Message Date
Mira Weller 2848d85511 Tests python3.11 compat 2024-10-14 13:20:07 +02:00
Mira Weller 21707f8407 Fix test case 2024-10-14 12:06:27 +02:00
Mira Weller 711479bfed fix display dependency in category settings 2024-10-14 10:23:34 +02:00
Mira Weller c401e54831 improve formatting for subevents 2024-10-14 10:23:34 +02:00
MiraandRichard Schreiber 27cfd4dbdd Update src/pretix/control/templates/pretixcontrol/items/category.html
Co-authored-by: Richard Schreiber <schreiber@rami.io>
2024-10-11 13:59:22 +02:00
Mira Weller e5ab1b08a2 reformat code 2024-10-11 11:34:13 +02:00
MiraandRichard Schreiber 7d22fe1a54 Update src/pretix/static/pretixcontrol/js/ui/main.js
Co-authored-by: Richard Schreiber <schreiber@rami.io>
2024-10-11 11:11:40 +02:00
MiraandRichard Schreiber 6c52cc8157 Apply suggestions from code review
Co-authored-by: Richard Schreiber <schreiber@rami.io>
2024-10-11 11:11:08 +02:00
Mira Weller 0191d258ab accessibility 2024-10-09 12:17:53 +02:00
Mira Weller b312a21e5e remove erroneous paste 2024-10-09 12:15:30 +02:00
Mira Weller f9ca9a781e one loop less 2024-10-09 12:13:11 +02:00
Mira Weller a314d219b8 fix iteration 2024-10-09 12:01:47 +02:00
Mira Weller 9a6756ce5d show discount notice on all categories with an available discount, not only those with cross_selling_condition=discount 2024-10-09 11:52:46 +02:00
Mira Weller b3ca02d8e5 change style of discount notice 2024-10-09 11:38:04 +02:00
Mira Weller 88936b5e7a improve wording of category types 2024-10-09 11:37:41 +02:00
MiraandRichard Schreiber 6b9eefd231 Update src/pretix/static/pretixpresale/scss/_checkout.scss
Co-authored-by: Richard Schreiber <schreiber@rami.io>
2024-10-07 21:19:02 +02:00
Mira Weller 6587cca608 add discount label 2024-10-02 12:12:43 +02:00
Mira Weller 3856095088 improve category type label for CROSS_SELLING_MODES=both 2024-10-02 09:57:16 +02:00
Mira Weller a84a27cc0b transfer cross_selling_match_products on event clone 2024-10-02 09:53:32 +02:00
Mira Weller 7d6b2d6df8 better description for CROSS_SELLING_CONDITION=discounts 2024-10-02 09:31:59 +02:00
Mira Weller d4f997c345 describe new category options in docs 2024-10-02 09:29:05 +02:00
Mira Weller bef88bf0d0 fix SUBEVENT_MODE_DISTINCT discounts 2024-10-01 18:46:44 +02:00
Mira Weller 159717c19f formatting 2024-10-01 18:36:24 +02:00
Mira Weller 5e9b5a9c24 support for variations 2024-10-01 18:35:07 +02:00
Mira Weller 52849f8fdd bugfix 2024-10-01 18:34:57 +02:00
Mira Weller 4f1ee82c4f remove unused vars 2024-10-01 18:15:59 +02:00
Mira Weller d5e480b7fd fix cross selling recommendations for SUBEVENT_MODE_SAME discounts 2024-10-01 18:14:46 +02:00
Mira Weller fd6ae65f23 add another test case 2024-10-01 18:14:17 +02:00
Mira Weller 94733135f0 add failing test for SUBEVENT_MODE_SAME 2024-10-01 17:29:25 +02:00
Mira Weller e51927c4e0 update query numbers 2024-10-01 16:54:24 +02:00
Mira Weller 11c7c950cb add subevent support to test framework 2024-10-01 16:52:47 +02:00
Mira Weller 0695365526 improved layout 2024-10-01 15:05:14 +02:00
Mira 0947476b41 Update src/pretix/base/services/cross_selling.py 2024-09-30 21:19:24 +02:00
Mira Weller 7a4aead22d rename id_prefix to form_prefix 2024-09-30 21:16:17 +02:00
MiraandRaphael Michel 44de4bb26b Apply suggestions from code review
Co-authored-by: Raphael Michel <michel@rami.io>
2024-09-30 21:13:19 +02:00
Mira Weller d879637b73 update query counts 2024-09-30 16:53:34 +02:00
Mira Weller b5fc227fca rebase migration 2024-09-27 16:36:54 +02:00
Mira Weller 1fb1696863 Merge remote-tracking branch 'origin/master' into cross-selling 2024-09-27 16:27:47 +02:00
Raphael Michel a07d5aaf05 Add-on step: Minimal performance improvement 2024-09-27 13:26:30 +02:00
Raphael Michel 0cf1a32902 Bump version to 2024.10.0.dev0 2024-09-27 09:46:47 +02:00
Raphael Michel be6aae8577 Bump version to 2024.9.0 2024-09-27 09:46:18 +02:00
Mira fe80f5fb78 Utils for internal plugin (#4483)
* Add full_code property to OrderPosition

* Add inline "json_script" as supported data source for select2

* Use shorter OrderPosition.code
2024-09-26 19:29:33 +02:00
Raphael Michel a2c15ad89e Check-in: Prevent duplicate auto check-outs (Z#23167003) (#4488) 2024-09-26 17:54:27 +02:00
Raphael Michel cab0f37830 Translations: Update German
Currently translated at 100.0% (5745 of 5745 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de/

powered by weblate
2024-09-26 17:51:57 +02:00
Raphael Michel 0423980058 Translations: Update German (informal) (de_Informal)
Currently translated at 100.0% (5745 of 5745 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de_Informal/

powered by weblate
2024-09-26 17:51:57 +02:00
Raphael Michel 63983b1b68 Translations: Update spellcheck lists 2024-09-26 16:52:28 +02:00
Raphael Michel 61241c2a1e Update po files
[CI skip]

Signed-off-by: Raphael Michel <michel@rami.io>
2024-09-26 13:23:02 +02:00
Raphael Michel 4069c61054 runperiodic: Allow to list all tasks 2024-09-26 10:32:53 +02:00
Raphael Michel 9bf4fb2d0f Sendmail: Fix incorrect filtering of subevents when mailing to attendees (Z#23166274) (#4474) 2024-09-25 17:55:33 +02:00
Raphael Michel ff910f293f Item list: Show tax rate even for products with 0 price
Might be neccessary for price input, variations, etc
2024-09-25 12:42:45 +02:00
Raphael Michel 74f7bec617 Change wording in a headline to avoid double-using a term 2024-09-25 12:42:45 +02:00
Albizuri 467a35e353 Translations: Update Basque
Currently translated at 56.0% (3213 of 5737 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/eu/

powered by weblate
2024-09-24 10:13:22 +02:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 770c13a4f0 Update pypdf requirement from ==4.3.* to ==5.0.* (#4471)
Updates the requirements on [pypdf](https://github.com/py-pdf/pypdf) to permit the latest version.
- [Release notes](https://github.com/py-pdf/pypdf/releases)
- [Changelog](https://github.com/py-pdf/pypdf/blob/main/CHANGELOG.md)
- [Commits](https://github.com/py-pdf/pypdf/compare/4.3.0...5.0.0)

---
updated-dependencies:
- dependency-name: pypdf
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-19 11:34:23 +02:00
dependabot[bot] 5373d4d8ba Bump django-bootstrap3 from 24.2 to 24.3
Bumps [django-bootstrap3](https://github.com/zostera/django-bootstrap3) from 24.2 to 24.3.
- [Changelog](https://github.com/zostera/django-bootstrap3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/zostera/django-bootstrap3/compare/v24.2...v24.3)

---
updated-dependencies:
- dependency-name: django-bootstrap3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-19 11:28:15 +02:00
Raphael Michel 42e673b5f6 Fix missing JS file name 2024-09-19 09:39:49 +02:00
Albizuri 7af2f2a87b Translations: Update Basque
Currently translated at 56.0% (3213 of 5737 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/eu/

powered by weblate
2024-09-18 16:25:32 +02:00
Tinna Sandström e408521769 Translations: Update Swedish
Currently translated at 99.1% (5686 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sv/

powered by weblate
2024-09-18 16:25:32 +02:00
Raphael Michel 8ed0d36346 Fix another wrong waiting_list_active reference 2024-09-18 10:28:41 +02:00
Raphael Michel 14cbe99667 Stripe: Fix a leftover } 2024-09-17 17:54:57 +02:00
Raphael Michel b059995eff Widget: Fix waiting list disable time based on subevent 2024-09-17 17:39:22 +02:00
Raphael Michel 100e8d0a4b Fix #4454 -- Resolve deprecation warning from celery 2024-09-17 13:36:35 +02:00
Raphael Michel eb92e4d8e6 Render progress info on non-javascript fallback page for celery tasks (#4452)
* Render progress info on non-javascript fallback page for celery tasks

* Review notes
2024-09-17 13:29:27 +02:00
Raphael Michel 32d6ded003 Stricten password validation to match PCI DSS requirements (#4467)
* Stricten password validation to match PCI DSS requirements

* Review fix

* Fix a file header
2024-09-17 13:29:17 +02:00
Raphael Michel aa07533693 Order import: Allow to set check-in attention and text (Z#23165806) (#4469) 2024-09-17 11:50:19 +02:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> e7d01f91a6 Bump @babel/preset-env from 7.25.3 to 7.25.4 in /src/pretix/static/npm_dir (#4438)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.25.3 to 7.25.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.25.4/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-17 11:42:33 +02:00
Raphael Michel 9616369f07 Formally deprecate eu_reverse_charge (#4470) 2024-09-17 11:39:32 +02:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> af606090ba Update sentry-sdk requirement from ==2.13.* to ==2.14.* (#4455)
Updates the requirements on [sentry-sdk](https://github.com/getsentry/sentry-python) to permit the latest version.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/2.13.0...2.14.0)

---
updated-dependencies:
- dependency-name: sentry-sdk
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-16 16:46:28 +02:00
Svyatoslav 931f3eca1b Translations: Update Estonian
Currently translated at 0.1% (1 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/et/

powered by weblate
2024-09-16 16:44:46 +02:00
Svyatoslav 36f306120e Translations: Update Latvian
Currently translated at 37.2% (2134 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/lv/

powered by weblate
2024-09-16 16:44:46 +02:00
Svyatoslav a3ba0c97e9 Translations: Update Russian
Currently translated at 19.1% (1097 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/ru/

powered by weblate
2024-09-16 16:44:46 +02:00
Richard Schreiber 484d24b66c Translations: Add Estonian 2024-09-16 16:44:46 +02:00
Tinna Sandström 2d39d3cc8e Translations: Update Swedish
Currently translated at 99.1% (5686 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sv/

powered by weblate
2024-09-16 16:44:46 +02:00
Kristian Feldsam 78b1adf423 Translations: Update Slovak
Currently translated at 29.3% (68 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sk/

powered by weblate
2024-09-16 16:44:46 +02:00
Kristian Feldsam c3eedcc396 Translations: Update Slovak
Currently translated at 92.5% (5307 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sk/

powered by weblate
2024-09-16 16:44:46 +02:00
Tinna Sandström 682c328390 Translations: Update Swedish
Currently translated at 99.1% (5686 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sv/

powered by weblate
2024-09-16 16:44:46 +02:00
Wikinaut 5230827f5e Translations: Update German
Currently translated at 100.0% (5736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de/

powered by weblate
2024-09-16 16:44:46 +02:00
Arthur Nunes dad9915435 Translations: Update Portuguese (Brazil)
Currently translated at 13.2% (759 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/pt_BR/

powered by weblate
2024-09-16 16:44:46 +02:00
Wikinaut a9d2c1eb34 Translations: Update German
Currently translated at 100.0% (5736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de/

powered by weblate
2024-09-16 16:44:46 +02:00
Tinna Sandström 66fe45a478 Translations: Update Swedish
Currently translated at 86.2% (200 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sv/

powered by weblate
2024-09-12 09:32:41 +02:00
Raphael Michel 24e2b1b9ab Import: Parse iso dates 2024-09-12 09:32:25 +02:00
Martin Gross eebdce80cd OIDC: Respect token_endpoint_auth_methods_supported (Z#2164777) (#4459) 2024-09-11 16:40:42 +02:00
Kristian Feldsam 09af95ec20 Translations: Update Slovak
Currently translated at 92.1% (5283 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sk/

powered by weblate
2024-09-11 16:01:16 +02:00
Tinna Sandström 1ade674beb Translations: Update Swedish
Currently translated at 99.1% (5686 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sv/

powered by weblate
2024-09-11 16:01:16 +02:00
Kristian Feldsam 76ff59f9c2 Translations: Update Slovak
Currently translated at 6.4% (15 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sk/

powered by weblate
2024-09-11 16:01:16 +02:00
Kristian Feldsam 0986522c2f Translations: Update Slovak
Currently translated at 6.0% (14 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sk/

powered by weblate
2024-09-11 16:01:16 +02:00
Kristian Feldsam 91f4e731da Translations: Update Slovak
Currently translated at 92.0% (5280 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sk/

powered by weblate
2024-09-11 16:01:16 +02:00
Raphael Michel 98709286c6 Order cancellation: Fix crash on deleted order (PRETIXEU-AHP) 2024-09-10 14:00:11 +02:00
Raphael Michel 667c2555b2 AsyncMixin: Fix crash on invalid query string (PRETIXEU-AHG) 2024-09-10 14:00:08 +02:00
Raphael Michel 6f5acb1ca7 Translations: Update German (informal) (de_Informal)
Currently translated at 100.0% (232 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/de_Informal/

powered by weblate
2024-09-10 09:19:12 +02:00
Raphael Michel 65ec3e3fd6 Translations: Update German
Currently translated at 100.0% (232 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/de/

powered by weblate
2024-09-10 09:19:12 +02:00
Richard Schreiber 1a8d0a973d Translations: Update German (informal) (de_Informal)
Currently translated at 100.0% (5736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de_Informal/

powered by weblate
2024-09-10 09:19:12 +02:00
Richard Schreiber 3c94631405 Translations: Update German
Currently translated at 100.0% (5736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/de/

powered by weblate
2024-09-10 09:19:12 +02:00
Kristian Feldsam 1dda7732a5 Translations: Update Slovak
Currently translated at 4.7% (11 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sk/

powered by weblate
2024-09-10 09:19:12 +02:00
Kristian Feldsam 33accf5f99 Translations: Update Slovak
Currently translated at 92.0% (5279 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sk/

powered by weblate
2024-09-10 09:19:12 +02:00
Tinna Sandström be2efd9df2 Translations: Update Swedish
Currently translated at 99.1% (5686 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sv/

powered by weblate
2024-09-10 09:19:12 +02:00
Ahmad AlHarthi fe69137a4e Translations: Update Arabic
Currently translated at 65.1% (3736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/ar/

powered by weblate
2024-09-09 11:18:16 +02:00
Ayden Jahola 7ccfb3a27a Translations: Update Arabic
Currently translated at 65.1% (3736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/ar/

powered by weblate
2024-09-09 11:18:16 +02:00
Ayden Jahola b7205622dc Translations: Update Arabic
Currently translated at 65.1% (3736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/ar/

powered by weblate
2024-09-09 11:18:16 +02:00
Ahmad AlHarthi 44da5b81b1 Translations: Update Arabic
Currently translated at 65.1% (3736 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/ar/

powered by weblate
2024-09-09 11:18:16 +02:00
Martin Gross 5a058342a6 Translations: Update Portuguese (Portugal)
Currently translated at 56.8% (132 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/pt_PT/

powered by weblate
2024-09-09 11:18:16 +02:00
Martin Gross 2d15dc7ce5 Translations: Update Portuguese (Portugal)
Currently translated at 56.8% (132 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/pt_PT/

powered by weblate
2024-09-09 11:18:16 +02:00
Martin Gross dd4ccc864e Translations: Update Portuguese (Portugal)
Currently translated at 86.7% (4977 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/pt_PT/

powered by weblate
2024-09-09 11:18:16 +02:00
Kristian Feldsam b812f0affe Translations: Update Slovak
Currently translated at 3.8% (9 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/sk/

powered by weblate
2024-09-09 11:18:16 +02:00
Kristian Feldsam 2af4183ce6 Translations: Update Slovak
Currently translated at 92.0% (5279 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/sk/

powered by weblate
2024-09-09 11:18:16 +02:00
Albizuri 8ac0b93ca5 Translations: Update Basque
Currently translated at 55.9% (3209 of 5737 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/eu/

powered by weblate
2024-09-09 11:18:16 +02:00
Ronisson Cabral 51a1193f32 Translations: Update Portuguese (Portugal)
Currently translated at 56.0% (130 of 232 strings)

Translation: pretix/pretix (JavaScript parts)
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix-js/pt_PT/

powered by weblate
2024-09-09 11:18:16 +02:00
Ronisson Cabral 002da2c9b7 Translations: Update Portuguese (Portugal)
Currently translated at 86.2% (4948 of 5736 strings)

Translation: pretix/pretix
Translate-URL: https://translate.pretix.eu/projects/pretix/pretix/pt_PT/

powered by weblate
2024-09-09 11:18:16 +02:00
Martin Gross 9a2ebe4e95 Refunds: Fix sortkey to work with not provided BICs (Z#23165187) (#4451) 2024-09-09 10:48:53 +02:00
Mira Weller 939d50061b Merge remote-tracking branch 'origin/master' into cross-selling
# Conflicts:
#	src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html
2024-08-29 13:49:28 +02:00
Mira Weller c1a5e8d912 codestyle 2024-08-01 23:01:11 +02:00
Mira Weller 106026045e fix sqlite compat 2024-08-01 22:59:51 +02:00
Mira Weller badbb64f4f add validation to ItemCategorySerializer 2024-07-26 20:05:03 +02:00
Mira Weller 537a0993b0 add more detailed description of collect_potential_discounts parameter 2024-07-26 19:40:28 +02:00
Mira Weller 9337ad1f70 add prefetching, add test cases checking number of queries 2024-07-25 14:37:19 +02:00
Mira Weller 5087e654e2 cleanup 2024-07-22 11:26:14 +02:00
Mira Weller dac2209243 rebase migration 2024-07-19 14:21:24 +02:00
Mira Weller 9cb708cf6f fix typing 2024-07-19 14:21:24 +02:00
Mira Weller e18c699529 formatting, refactoring 2024-07-19 14:21:24 +02:00
Mira Weller 9c3150ccde add license header 2024-07-19 14:21:24 +02:00
Mira Weller 923798ea5f fix cross-selling recommendation logic bug 2024-07-19 14:21:24 +02:00
Mira Weller b8d2372cf6 store apply_discounts result for use in test cases 2024-07-19 14:21:24 +02:00
Mira Weller e01e9151c3 correct type annotation 2024-07-19 14:21:24 +02:00
Mira Weller 09398ad7c7 add more test cases 2024-07-19 14:21:24 +02:00
Mira Weller d1de8f5863 remove redundant check
(this is already checked using the 'if not self.condition_min_count or self.condition_min_value' condition directly above)
2024-07-19 14:21:24 +02:00
Mira Weller bee0eaa2fa add some unit tests for cross-selling logic 2024-07-19 14:21:24 +02:00
Mira Weller ac771b8ca8 refactor cross-selling logic into its own module 2024-07-19 14:21:24 +02:00
Mira Weller cb635b2c37 add TODO for known error 2024-07-19 14:21:24 +02:00
Mira Weller 3fe6919bef add typing 2024-07-19 14:21:24 +02:00
Mira Weller 8cfb69c265 clarifications 2024-07-19 14:21:24 +02:00
Mira Weller 77fc13605e new sales channel compat 2024-07-19 14:21:24 +02:00
Mira Weller a95976ed50 translate comments 2024-07-19 14:21:24 +02:00
Mira Weller 2e3a611498 isort 2024-07-19 14:21:24 +02:00
Mira Weller 6bf16f1510 Use namedtuple 2024-07-19 14:21:24 +02:00
Mira Weller d29b183801 fix test case 2024-07-19 14:21:24 +02:00
Mira Weller 188ef5f463 isort 2024-07-19 14:21:24 +02:00
Mira Weller a7e292ea58 fix case 2024-07-19 14:21:24 +02:00
Mira Weller d04b855cce category_type refactoring 2024-07-19 14:21:24 +02:00
Mira Weller 01b535a0af cache potential discount information
relevant if shop has multiple categories with cross_selling_condition=discounts
2024-07-19 14:21:23 +02:00
Mira Weller d9f31aae8c better var names 2024-07-19 14:21:23 +02:00
Mira Weller 715347cb35 filter non-buyable items from list 2024-07-19 14:21:23 +02:00
Mira Weller 32cc45f19a make cross-selling-applicable more specific and cache state
(only show if really applicable, e.g. don't show if product can't be bought due to order_max)
2024-07-19 14:21:23 +02:00
Mira Weller cadf8dd39d better order_max handling 2024-07-19 14:21:23 +02:00
Mira Weller b136ac37c8 Hide addon text if only cross-selling, no addons in addon step 2024-07-19 14:21:23 +02:00
Mira Weller 8627eefebc first round of cleanup 2024-07-19 14:21:23 +02:00
Mira Weller e71d3e21ca display discounted prices, limit number of products according to discount rule 2024-07-19 14:21:23 +02:00
Mira Weller a18adb8a88 wip 2024-07-19 14:21:23 +02:00
Mira Weller f56d67ec9c add todo notes 2024-07-19 14:21:23 +02:00
Mira Weller c156581ad1 fix discount collection (?) 2024-07-19 14:21:23 +02:00
Mira Weller 8791280d0b Implement discount prediction (very WIP!) 2024-07-19 14:21:23 +02:00
Mira Weller 97925e2d77 migration, show category type in ui 2024-07-19 14:21:23 +02:00
Mira Weller a0d865cf4f implement cross_selling_visibility "always" and "products" 2024-07-19 14:21:21 +02:00
Mira Weller 2cd5d87da4 Refactor fragment_product_list.html 2024-07-19 14:21:00 +02:00
Mira Weller e5c7c85e75 Allow adding products from multiple subevents to the cart at once 2024-07-19 14:21:00 +02:00
Mira Weller 3e0992a7a7 Make the comments in cart.py less incorrect 2024-07-19 14:21:00 +02:00
Mira Weller f19e5bef72 Cross-selling category configuration 2024-07-19 14:21:00 +02:00
117 changed files with 70383 additions and 34801 deletions
+36 -5
View File
@@ -23,6 +23,22 @@ position integer An integer, use
is_addon boolean If ``true``, items within this category are not on sale
on their own but the category provides a source for
defining add-ons for other products.
cross_selling_mode string If ``null``, cross-selling is disabled for this category.
If ``"only"``, it is only visible in the cross-selling
step.
If ``"both"``, it is visible on the normal index page
as well.
Only available if ``is_addon`` is ``false``.
cross_selling_condition string Only relevant if ``cross_selling_mode`` is not ``null``.
If ``"always"``, always show in cross-selling step.
If ``"products"``, only show if the cart contains one of
the products listed in ``cross_selling_match_products``.
If ``"discounts"``, only show products that qualify for
a discount according to discount rules.
cross_selling_match_products list of integer Only relevant if ``cross_selling_condition`` is
``"products"``. Internal ID of the items of which at
least one needs to be in the cart for this category to
be shown.
===================================== ========================== =======================================================
@@ -60,7 +76,10 @@ Endpoints
"internal_name": "",
"description": {"en": "Tickets are what you need to get in."},
"position": 1,
"is_addon": false
"is_addon": false,
"cross_selling_mode": null,
"cross_selling_condition": null,
"cross_selling_match_products": []
}
]
}
@@ -102,7 +121,10 @@ Endpoints
"internal_name": "",
"description": {"en": "Tickets are what you need to get in."},
"position": 1,
"is_addon": false
"is_addon": false,
"cross_selling_mode": null,
"cross_selling_condition": null,
"cross_selling_match_products": []
}
:param organizer: The ``slug`` field of the organizer to fetch
@@ -130,7 +152,10 @@ Endpoints
"internal_name": "",
"description": {"en": "Tickets are what you need to get in."},
"position": 1,
"is_addon": false
"is_addon": false,
"cross_selling_mode": null,
"cross_selling_condition": null,
"cross_selling_match_products": []
}
**Example response**:
@@ -147,7 +172,10 @@ Endpoints
"internal_name": "",
"description": {"en": "Tickets are what you need to get in."},
"position": 1,
"is_addon": false
"is_addon": false,
"cross_selling_mode": null,
"cross_selling_condition": null,
"cross_selling_match_products": []
}
:param organizer: The ``slug`` field of the organizer of the event to create a category for
@@ -193,7 +221,10 @@ Endpoints
"internal_name": "",
"description": {"en": "Tickets are what you need to get in."},
"position": 1,
"is_addon": true
"is_addon": true,
"cross_selling_mode": null,
"cross_selling_condition": null,
"cross_selling_match_products": []
}
:param organizer: The ``slug`` field of the organizer to modify
+3 -2
View File
@@ -20,8 +20,9 @@ internal_name string An optional nam
rate decimal (string) Tax rate in percent
price_includes_tax boolean If ``true`` (default), tax is assumed to be included in
the specified product price
eu_reverse_charge boolean If ``true``, EU reverse charge rules are applied. Will
be ignored if custom rules are set.
eu_reverse_charge boolean **DEPRECATED**. If ``true``, EU reverse charge rules
are applied. Will be ignored if custom rules are set.
Use custom rules instead.
home_country string Merchant country (required for reverse charge), can be
``null`` or empty string
keep_gross_if_rate_changes boolean If ``true``, changes of the tax rate based on custom
+3 -3
View File
@@ -36,7 +36,7 @@ dependencies = [
"css-inline==0.14.*",
"defusedcsv>=1.1.0",
"Django[argon2]==4.2.*,>=4.2.15",
"django-bootstrap3==24.2",
"django-bootstrap3==24.3",
"django-compressor==4.5.1",
"django-countries==7.6.*",
"django-filter==24.3",
@@ -81,7 +81,7 @@ dependencies = [
"pycountry",
"pycparser==2.22",
"pycryptodome==3.20.*",
"pypdf==4.3.*",
"pypdf==5.0.*",
"python-bidi==0.6.*", # Support for Arabic in reportlab
"python-dateutil==2.9.*",
"pytz",
@@ -91,7 +91,7 @@ dependencies = [
"redis==5.0.*",
"reportlab==4.2.*",
"requests==2.31.*",
"sentry-sdk==2.13.*",
"sentry-sdk==2.14.*",
"sepaxml==2.6.*",
"slimit",
"stripe==7.9.*",
+1 -1
View File
@@ -19,4 +19,4 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
__version__ = "2024.9.0.dev0"
__version__ = "2024.10.0.dev0"
+16 -1
View File
@@ -441,7 +441,22 @@ class ItemCategorySerializer(I18nAwareModelSerializer):
class Meta:
model = ItemCategory
fields = ('id', 'name', 'internal_name', 'description', 'position', 'is_addon')
fields = (
'id', 'name', 'internal_name', 'description', 'position',
'is_addon', 'cross_selling_mode',
'cross_selling_condition', 'cross_selling_match_products'
)
def validate(self, data):
data = super().validate(data)
full_data = self.to_internal_value(self.to_representation(self.instance)) if self.instance else {}
full_data.update(data)
if full_data.get('is_addon') and full_data.get('cross_selling_mode'):
raise ValidationError('is_addon and cross_selling_mode are mutually exclusive')
return data
class QuestionOptionSerializer(I18nAwareModelSerializer):
+63 -1
View File
@@ -32,13 +32,16 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under the License.
import string
from collections import OrderedDict
from importlib import import_module
from django import forms
from django.conf import settings
from django.contrib.auth import authenticate
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.hashers import check_password, make_password
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _, ngettext
def get_auth_backends():
@@ -160,3 +163,62 @@ class NativeAuthBackend(BaseAuthBackend):
u = authenticate(request=request, email=form_data['email'].lower(), password=form_data['password'])
if u and u.auth_backend == self.identifier:
return u
class NumericAndAlphabeticPasswordValidator:
def validate(self, password, user=None):
has_numeric = any(c in string.digits for c in password)
has_alpha = any(c in string.ascii_letters for c in password)
if not has_numeric or not has_alpha:
raise ValidationError(
_(
"Your password must contain both numeric and alphabetic characters.",
),
code="password_numeric_and_alphabetic",
)
def get_help_text(self):
return _(
"Your password must contain both numeric and alphabetic characters.",
)
class HistoryPasswordValidator:
def __init__(self, history_length=4):
self.history_length = history_length
def validate(self, password, user=None):
from pretix.base.models import User
if not user or not user.pk or not isinstance(user, User):
return
for hp in user.historic_passwords.order_by("-created")[:self.history_length]:
if check_password(password, hp.password):
raise ValidationError(
ngettext(
"Your password may not be the same as your previous password.",
"Your password may not be the same as one of your %(history_length)s previous passwords.",
self.history_length,
),
code="password_history",
params={"history_length": self.history_length},
)
def get_help_text(self):
return ngettext(
"Your password may not be the same as your previous password.",
"Your password may not be the same as one of your %(history_length)s previous passwords.",
self.history_length,
) % {"history_length": self.history_length}
def password_changed(self, password, user=None):
if not user:
pass
user.historic_passwords.create(password=make_password(password))
user.historic_passwords.filter(
pk__in=user.historic_passwords.order_by("-created")[self.history_length:].values_list("pk", flat=True),
).delete()
+33 -1
View File
@@ -46,6 +46,8 @@ This module contains utilities for implementing OpenID Connect for customer auth
as well as an OpenID Provider (OP).
"""
pretix_token_endpoint_auth_methods = ['client_secret_basic', 'client_secret_post']
def _urljoin(base, path):
if not base.endswith("/"):
@@ -127,6 +129,16 @@ def oidc_validate_and_complete_config(config):
fields=", ".join(provider_config.get("claims_supported", []))
))
if "token_endpoint_auth_methods_supported" in provider_config:
token_endpoint_auth_methods_supported = provider_config.get("token_endpoint_auth_methods_supported",
["client_secret_basic"])
if not any(x in pretix_token_endpoint_auth_methods for x in token_endpoint_auth_methods_supported):
raise ValidationError(
_(f'No supported Token Endpoint Auth Methods supported: {token_endpoint_auth_methods_supported}').format(
token_endpoint_auth_methods_supported=", ".join(token_endpoint_auth_methods_supported)
)
)
config['provider_config'] = provider_config
return config
@@ -147,6 +159,18 @@ def oidc_authorize_url(provider, state, redirect_uri):
def oidc_validate_authorization(provider, code, redirect_uri):
endpoint = provider.configuration['provider_config']['token_endpoint']
# Wall of shame and RFC ignorant IDPs
if endpoint == 'https://www.linkedin.com/oauth/v2/accessToken':
token_endpoint_auth_method = 'client_secret_post'
else:
token_endpoint_auth_methods = provider.configuration['provider_config'].get(
'token_endpoint_auth_methods_supported', ['client_secret_basic']
)
token_endpoint_auth_method = [
x for x in pretix_token_endpoint_auth_methods if x in token_endpoint_auth_methods
][0]
params = {
# https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
# https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
@@ -154,6 +178,11 @@ def oidc_validate_authorization(provider, code, redirect_uri):
'code': code,
'redirect_uri': redirect_uri,
}
if token_endpoint_auth_method == 'client_secret_post':
params['client_id'] = provider.configuration['client_id']
params['client_secret'] = provider.configuration['client_secret']
try:
resp = requests.post(
endpoint,
@@ -161,7 +190,10 @@ def oidc_validate_authorization(provider, code, redirect_uri):
headers={
'Accept': 'application/json',
},
auth=(provider.configuration['client_id'], provider.configuration['client_secret']),
auth=(
provider.configuration['client_id'],
provider.configuration['client_secret']
) if token_endpoint_auth_method == 'client_secret_basic' else None,
)
resp.raise_for_status()
data = resp.json()
@@ -50,6 +50,7 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--tasks', action='store', type=str, help='Only execute the tasks with this name '
'(dotted path, comma separation)')
parser.add_argument('--list-tasks', action='store_true', help='Only list all tasks')
parser.add_argument('--exclude', action='store', type=str, help='Exclude the tasks with this name '
'(dotted path, comma separation)')
@@ -61,6 +62,9 @@ class Command(BaseCommand):
for receiver in periodic_task._live_receivers(self):
name = f'{receiver.__module__}.{receiver.__name__}'
if options['list_tasks']:
print(name)
continue
if options.get('tasks'):
if name not in options.get('tasks').split(','):
continue
@@ -0,0 +1,36 @@
# Generated by Django 4.2.15 on 2024-09-16 15:10
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("pretixbase", "0269_order_api_meta"),
]
operations = [
migrations.CreateModel(
name="HistoricPassword",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False
),
),
("created", models.DateTimeField(auto_now_add=True)),
("password", models.CharField(max_length=128)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="historic_passwords",
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
@@ -0,0 +1,32 @@
# Generated by Django 4.2.11 on 2024-05-27 13:19
from django.db import migrations, models
import pretix.base.models.orders
class Migration(migrations.Migration):
dependencies = [
("pretixbase", "0270_historicpassword"),
]
operations = [
migrations.AddField(
model_name="itemcategory",
name="cross_selling_condition",
field=models.CharField(null=True, max_length=10),
),
migrations.AddField(
model_name="itemcategory",
name="cross_selling_mode",
field=models.CharField(null=True, max_length=5),
),
migrations.AddField(
model_name="itemcategory",
name="cross_selling_match_products",
field=models.ManyToManyField(
related_name="matched_by_cross_selling_categories", to="pretixbase.item"
),
),
]
+7 -1
View File
@@ -213,7 +213,13 @@ class DatetimeColumnMixin:
except (ValueError, TypeError):
pass
else:
raise ValidationError(_("Could not parse {value} as a date and time.").format(value=value))
try:
d = datetime.datetime.fromisoformat(value)
if not d.tzinfo:
d = d.replace(tzinfo=self.timezone)
return d
except (ValueError, TypeError):
raise ValidationError(_("Could not parse {value} as a date and time.").format(value=value))
class DecimalColumnMixin:
+20 -2
View File
@@ -40,8 +40,8 @@ from phonenumbers import SUPPORTED_REGIONS
from pretix.base.forms.questions import guess_country
from pretix.base.modelimport import (
DatetimeColumnMixin, DecimalColumnMixin, ImportColumn, SubeventColumnMixin,
i18n_flat,
BooleanColumnMixin, DatetimeColumnMixin, DecimalColumnMixin, ImportColumn,
SubeventColumnMixin, i18n_flat,
)
from pretix.base.models import (
Customer, ItemVariation, OrderPosition, Question, QuestionAnswer,
@@ -604,6 +604,22 @@ class Comment(ImportColumn):
order.comment = value or ''
class CheckinAttentionColumn(BooleanColumnMixin, ImportColumn):
identifier = 'checkin_attention'
verbose_name = gettext_lazy('Requires special attention')
def assign(self, value, order, position, invoice_address, **kwargs):
order.checkin_attention = value
class CheckinTextColumn(ImportColumn):
identifier = 'checkin_text'
verbose_name = gettext_lazy('Check-in text')
def assign(self, value, order, position, invoice_address, **kwargs):
order.checkin_text = value
class QuestionColumn(ImportColumn):
def __init__(self, event, q):
self.q = q
@@ -742,6 +758,8 @@ def get_order_import_columns(event):
ValidUntil(event),
Locale(event),
Saleschannel(event),
CheckinAttentionColumn(event),
CheckinTextColumn(event),
Expires(event),
Comment(event),
]
+6
View File
@@ -654,3 +654,9 @@ class WebAuthnDevice(Device):
@property
def webauthnpubkey(self):
return websafe_decode(self.pub_key)
class HistoricPassword(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="historic_passwords")
created = models.DateTimeField(auto_now_add=True)
password = models.CharField(verbose_name=_("Password"), max_length=128)
+70 -31
View File
@@ -20,11 +20,11 @@
# <https://www.gnu.org/licenses/>.
#
from collections import defaultdict
from collections import defaultdict, namedtuple
from decimal import Decimal
from itertools import groupby
from math import ceil
from typing import Dict, Optional, Tuple
from math import ceil, inf
from typing import Dict
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
@@ -36,6 +36,8 @@ from django_scopes import ScopedManager
from pretix.base.decimal import round_decimal
from pretix.base.models.base import LoggedModel
PositionInfo = namedtuple('PositionInfo', ['item_id', 'subevent_id', 'line_price_gross', 'is_addon_to', 'voucher_discount'])
class Discount(LoggedModel):
SUBEVENT_MODE_MIXED = 'mixed'
@@ -245,22 +247,26 @@ class Discount(LoggedModel):
return False
return True
def _apply_min_value(self, positions, condition_idx_group, benefit_idx_group, result):
if self.condition_min_value and sum(positions[idx][2] for idx in condition_idx_group) < self.condition_min_value:
def _apply_min_value(self, positions, condition_idx_group, benefit_idx_group, result, collect_potential_discounts, subevent_id):
if self.condition_min_value and sum(positions[idx].line_price_gross for idx in condition_idx_group) < self.condition_min_value:
return
if self.condition_min_count or self.benefit_only_apply_to_cheapest_n_matches:
raise ValueError('Validation invariant violated.')
for idx in benefit_idx_group:
previous_price = positions[idx][2]
previous_price = positions[idx].line_price_gross
new_price = round_decimal(
previous_price * (Decimal('100.00') - self.benefit_discount_matching_percent) / Decimal('100.00'),
self.event.currency,
)
result[idx] = new_price
def _apply_min_count(self, positions, condition_idx_group, benefit_idx_group, result):
if collect_potential_discounts is not None:
for idx in condition_idx_group:
collect_potential_discounts[idx] = [(self, inf, -1, subevent_id)]
def _apply_min_count(self, positions, condition_idx_group, benefit_idx_group, result, collect_potential_discounts, subevent_id):
if len(condition_idx_group) < self.condition_min_count:
return
@@ -268,23 +274,53 @@ class Discount(LoggedModel):
raise ValueError('Validation invariant violated.')
if self.benefit_only_apply_to_cheapest_n_matches:
if not self.condition_min_count:
raise ValueError('Validation invariant violated.')
condition_idx_group = sorted(condition_idx_group, key=lambda idx: (positions[idx][2], -idx)) # sort by line_price
benefit_idx_group = sorted(benefit_idx_group, key=lambda idx: (positions[idx][2], -idx)) # sort by line_price
# sort by line_price
condition_idx_group = sorted(condition_idx_group, key=lambda idx: (positions[idx].line_price_gross, -idx))
benefit_idx_group = sorted(benefit_idx_group, key=lambda idx: (positions[idx].line_price_gross, -idx))
# Prevent over-consuming of items, i.e. if our discount is "buy 2, get 1 free", we only
# want to match multiples of 3
n_groups = min(len(condition_idx_group) // self.condition_min_count, ceil(len(benefit_idx_group) / self.benefit_only_apply_to_cheapest_n_matches))
# how many discount applications are allowed according to condition products in cart
possible_applications_cond = len(condition_idx_group) // self.condition_min_count
# how many discount applications are possible according to benefitting products in cart
possible_applications_benefit = ceil(len(benefit_idx_group) / self.benefit_only_apply_to_cheapest_n_matches)
n_groups = min(possible_applications_cond, possible_applications_benefit)
consume_idx = condition_idx_group[:n_groups * self.condition_min_count]
benefit_idx = benefit_idx_group[:n_groups * self.benefit_only_apply_to_cheapest_n_matches]
if collect_potential_discounts is not None:
if n_groups * self.benefit_only_apply_to_cheapest_n_matches > len(benefit_idx_group):
# partially used discount ("for each 1 ticket you buy, get 50% on 2 t-shirts", cart content: 1 ticket
# but only 1 t-shirt) -> 1 shirt definitiv potential discount
for idx in consume_idx:
collect_potential_discounts[idx] = [
(self, n_groups * self.benefit_only_apply_to_cheapest_n_matches - len(benefit_idx_group), -1, subevent_id)
]
if possible_applications_cond * self.benefit_only_apply_to_cheapest_n_matches > len(benefit_idx_group):
# unused discount ("for each 1 ticket you buy, get 50% on 2 t-shirts", cart content: 1 ticket
# but 0 t-shirts) -> 2 shirt maybe potential discount (if the 1 ticket is not consumed by a later discount)
for i, idx in enumerate(condition_idx_group[
n_groups * self.condition_min_count:
possible_applications_cond * self.condition_min_count
]):
collect_potential_discounts[idx] += [
(self, self.benefit_only_apply_to_cheapest_n_matches, i // self.condition_min_count, subevent_id)
]
else:
consume_idx = condition_idx_group
benefit_idx = benefit_idx_group
if collect_potential_discounts is not None:
for idx in consume_idx:
collect_potential_discounts[idx] = [(self, inf, -1, subevent_id)]
for idx in benefit_idx:
previous_price = positions[idx][2]
previous_price = positions[idx].line_price_gross
new_price = round_decimal(
previous_price * (Decimal('100.00') - self.benefit_discount_matching_percent) / Decimal('100.00'),
self.event.currency,
@@ -292,15 +328,16 @@ class Discount(LoggedModel):
result[idx] = new_price
for idx in consume_idx:
result.setdefault(idx, positions[idx][2])
result.setdefault(idx, positions[idx].line_price_gross)
def apply(self, positions: Dict[int, Tuple[int, Optional[int], Decimal, bool, Decimal]]) -> Dict[int, Decimal]:
def apply(self, positions: Dict[int, PositionInfo],
collect_potential_discounts=None) -> Dict[int, Decimal]:
"""
Tries to apply this discount to a cart
:param positions: Dictionary mapping IDs to tuples of the form
``(item_id, subevent_id, line_price_gross, is_addon_to, voucher_discount)``.
:param positions: Dictionary mapping IDs to PositionInfo tuples.
Bundled positions may not be included.
:param collect_potential_discounts: For detailed description, see pretix.base.services.pricing.apply_discounts
:return: A dictionary mapping keys from the input dictionary to new prices. All positions
contained in this dictionary are considered "consumed" and should not be considered
@@ -342,13 +379,13 @@ class Discount(LoggedModel):
if self.subevent_mode == self.SUBEVENT_MODE_MIXED: # also applies to non-series events
if self.condition_min_count:
self._apply_min_count(positions, condition_candidates, benefit_candidates, result)
self._apply_min_count(positions, condition_candidates, benefit_candidates, result, collect_potential_discounts, None)
else:
self._apply_min_value(positions, condition_candidates, benefit_candidates, result)
self._apply_min_value(positions, condition_candidates, benefit_candidates, result, collect_potential_discounts, None)
elif self.subevent_mode == self.SUBEVENT_MODE_SAME:
def key(idx):
return positions[idx][1] or 0 # subevent_id
return positions[idx].subevent_id or 0
# Build groups of candidates with the same subevent, then apply our regular algorithm
# to each group
@@ -357,11 +394,11 @@ class Discount(LoggedModel):
candidate_groups = [(k, list(g)) for k, g in _groups]
for subevent_id, g in candidate_groups:
benefit_g = [idx for idx in benefit_candidates if positions[idx][1] == subevent_id]
benefit_g = [idx for idx in benefit_candidates if positions[idx].subevent_id == subevent_id]
if self.condition_min_count:
self._apply_min_count(positions, g, benefit_g, result)
self._apply_min_count(positions, g, benefit_g, result, collect_potential_discounts, subevent_id)
else:
self._apply_min_value(positions, g, benefit_g, result)
self._apply_min_value(positions, g, benefit_g, result, collect_potential_discounts, subevent_id)
elif self.subevent_mode == self.SUBEVENT_MODE_DISTINCT:
if self.condition_min_value or not self.benefit_same_products:
@@ -377,9 +414,9 @@ class Discount(LoggedModel):
# Build a list of subevent IDs in descending order of frequency
subevent_to_idx = defaultdict(list)
for idx, p in positions.items():
subevent_to_idx[p[1]].append(idx)
subevent_to_idx[p.subevent_id].append(idx)
for v in subevent_to_idx.values():
v.sort(key=lambda idx: positions[idx][2])
v.sort(key=lambda idx: positions[idx].line_price_gross)
subevent_order = sorted(list(subevent_to_idx.keys()), key=lambda s: len(subevent_to_idx[s]), reverse=True)
# Build groups of exactly condition_min_count distinct subevents
@@ -394,7 +431,7 @@ class Discount(LoggedModel):
l = [ll for ll in l if ll in condition_candidates and ll not in current_group]
if cardinality and len(l) != cardinality:
continue
if se not in {positions[idx][1] for idx in current_group}:
if se not in {positions[idx].subevent_id for idx in current_group}:
candidates += l
cardinality = len(l)
@@ -403,7 +440,7 @@ class Discount(LoggedModel):
# Sort the list by prices, then pick one. For "buy 2 get 1 free" we apply a "pick 1 from the start
# and 2 from the end" scheme to optimize price distribution among groups
candidates = sorted(candidates, key=lambda idx: positions[idx][2])
candidates = sorted(candidates, key=lambda idx: positions[idx].line_price_gross)
if len(current_group) < (self.benefit_only_apply_to_cheapest_n_matches or 0):
candidate = candidates[0]
else:
@@ -415,14 +452,14 @@ class Discount(LoggedModel):
if len(current_group) >= max(self.condition_min_count, 1):
candidate_groups.append(current_group)
for c in current_group:
subevent_to_idx[positions[c][1]].remove(c)
subevent_to_idx[positions[c].subevent_id].remove(c)
current_group = []
# Distribute "leftovers"
for se in subevent_order:
if subevent_to_idx[se]:
for group in candidate_groups:
if se not in {positions[idx][1] for idx in group}:
if se not in {positions[idx].subevent_id for idx in group}:
group.append(subevent_to_idx[se].pop())
if not subevent_to_idx[se]:
break
@@ -432,6 +469,8 @@ class Discount(LoggedModel):
positions,
[idx for idx in g if idx in condition_candidates],
[idx for idx in g if idx in benefit_candidates],
result
result,
None,
None
)
return result
+5
View File
@@ -870,10 +870,12 @@ class Event(EventMixin, LoggedModel):
for i in Item.objects.filter(event=other).prefetch_related(
'variations', 'limit_sales_channels', 'require_membership_types',
'variations__limit_sales_channels', 'variations__require_membership_types',
'matched_by_cross_selling_categories',
):
vars = list(i.variations.all())
require_membership_types = list(i.require_membership_types.all())
limit_sales_channels = list(i.limit_sales_channels.all())
matched_by_cross_selling_categories = list(i.matched_by_cross_selling_categories.all())
item_map[i.pk] = i
i.pk = None
i.event = self
@@ -911,6 +913,9 @@ class Event(EventMixin, LoggedModel):
if not v.all_sales_channels:
v.limit_sales_channels.set(self.organizer.sales_channels.filter(identifier__in=[s.identifier for s in limit_sales_channels]))
if matched_by_cross_selling_categories:
i.matched_by_cross_selling_categories.set([category_map[c.pk] for c in matched_by_cross_selling_categories])
for i in self.items.filter(hidden_if_item_available__isnull=False):
i.hidden_if_item_available = item_map[i.hidden_if_item_available_id]
i.save()
+53 -13
View File
@@ -63,14 +63,13 @@ from django_countries.fields import Country
from django_scopes import ScopedManager
from i18nfield.fields import I18nCharField, I18nTextField
from pretix.base.media import MEDIA_TYPES
from pretix.base.models import Event, SubEvent
from pretix.base.models.base import LoggedModel
from pretix.base.models.fields import MultiStringField
from pretix.base.models.tax import TaxedPrice
from pretix.base.timemachine import time_machine_now
from ...helpers.images import ImageSizeValidator
from ..media import MEDIA_TYPES
from .event import Event, SubEvent
from pretix.helpers.images import ImageSizeValidator
class ItemCategory(LoggedModel):
@@ -111,6 +110,33 @@ class ItemCategory(LoggedModel):
'only be bought in combination with a product that has this category configured as a possible '
'source for add-ons.')
)
CROSS_SELLING_MODES = (
(None, _('Normal category')),
('both', _('Normal + cross-selling category')),
('only', _('Cross-selling category')),
)
cross_selling_mode = models.CharField(
choices=CROSS_SELLING_MODES,
null=True,
max_length=5
)
CROSS_SELLING_CONDITION = (
('always', _('Always show in cross-selling step')),
('discounts', _('Only show products that qualify for a discount according to discount rules')),
('products', _('Only show if the cart contains one of the following products')),
)
cross_selling_condition = models.CharField(
verbose_name=_("Cross-selling condition"),
choices=CROSS_SELLING_CONDITION,
null=True,
max_length=10,
)
cross_selling_match_products = models.ManyToManyField(
'pretixbase.Item',
blank=True,
verbose_name=_("Cross-selling condition products"),
related_name="matched_by_cross_selling_categories",
)
class Meta:
verbose_name = _("Product category")
@@ -119,19 +145,31 @@ class ItemCategory(LoggedModel):
def __str__(self):
name = self.internal_name or self.name
if self.is_addon:
return _('{category} (Add-On products)').format(category=str(name))
category_type = self.get_category_type_display()
if category_type:
return _('{category} ({category_type})').format(category=str(name), category_type=category_type)
return str(name)
def get_category_type_display(self):
if self.is_addon:
return _('Add-On products')
return _('Add-on category')
elif self.cross_selling_mode:
return self.get_cross_selling_mode_display()
else:
return None
@property
def category_type(self):
return 'addon' if self.is_addon else 'normal'
return 'addon' if self.is_addon else self.cross_selling_mode or 'normal'
@category_type.setter
def category_type(self, new_value):
if new_value == 'addon':
self.is_addon = True
self.cross_selling_mode = None
else:
self.is_addon = False
self.cross_selling_mode = None if new_value == 'normal' else new_value
def delete(self, *args, **kwargs):
super().delete(*args, **kwargs)
@@ -270,7 +308,7 @@ class SubEventItemVariation(models.Model):
return True
def filter_available(qs, channel='web', voucher=None, allow_addons=False):
def filter_available(qs, channel='web', voucher=None, allow_addons=False, allow_cross_sell=False):
# Channel can currently be a SalesChannel or a str, since we need that compatibility, but a SalesChannel
# makes the query SIGNIFICANTLY faster
from .organizer import SalesChannel
@@ -291,6 +329,8 @@ def filter_available(qs, channel='web', voucher=None, allow_addons=False):
if not allow_addons:
q &= Q(Q(category__isnull=True) | Q(category__is_addon=False))
if not allow_cross_sell:
q &= Q(Q(category__isnull=True) | ~Q(category__cross_selling_mode='only'))
if voucher:
if voucher.item_id:
@@ -304,8 +344,8 @@ def filter_available(qs, channel='web', voucher=None, allow_addons=False):
class ItemQuerySet(models.QuerySet):
def filter_available(self, channel='web', voucher=None, allow_addons=False):
return filter_available(self, channel, voucher, allow_addons)
def filter_available(self, channel='web', voucher=None, allow_addons=False, allow_cross_sell=False):
return filter_available(self, channel, voucher, allow_addons, allow_cross_sell)
class ItemQuerySetManager(ScopedManager(organizer='event__organizer').__class__):
@@ -313,8 +353,8 @@ class ItemQuerySetManager(ScopedManager(organizer='event__organizer').__class__)
super().__init__()
self._queryset_class = ItemQuerySet
def filter_available(self, channel='web', voucher=None, allow_addons=False):
return filter_available(self.get_queryset(), channel, voucher, allow_addons)
def filter_available(self, channel='web', voucher=None, allow_addons=False, allow_cross_sell=False):
return filter_available(self.get_queryset(), channel, voucher, allow_addons, allow_cross_sell)
class Item(LoggedModel):
+8
View File
@@ -2835,6 +2835,14 @@ class OrderPosition(AbstractPosition):
(self.order.event.settings.change_allow_user_addons and ItemAddOn.objects.filter(base_item_id__in=[op.item_id for op in positions]).exists())
)
@property
def code(self):
"""
A ticket code which is unique among all events of a single organizer,
built by the order code and the position number.
"""
return '{order_code}-{position}'.format(order_code=self.order.code, position=self.positionid)
class Transaction(models.Model):
"""
+15 -5
View File
@@ -29,6 +29,8 @@ from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.utils.deconstruct import deconstructible
from django.utils.formats import localize
from django.utils.functional import lazy
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _, pgettext
from i18nfield.fields import I18nCharField
from i18nfield.strings import LazyI18nString
@@ -120,6 +122,8 @@ EU_CURRENCIES = {
}
VAT_ID_COUNTRIES = EU_COUNTRIES | {'CH', 'NO'}
format_html_lazy = lazy(format_html, str)
def is_eu_country(cc):
cc = str(cc)
@@ -193,11 +197,17 @@ class TaxRule(LoggedModel):
eu_reverse_charge = models.BooleanField(
verbose_name=_("Use EU reverse charge taxation rules"),
default=False,
help_text=_("Not recommended. Most events will NOT be qualified for reverse charge since the place of "
"taxation is the location of the event. This option disables charging VAT for all customers "
"outside the EU and for business customers in different EU countries who entered a valid EU VAT "
"ID. Only enable this option after consulting a tax counsel. No warranty given for correct tax "
"calculation. USE AT YOUR OWN RISK.")
help_text=format_html_lazy(
'<span class="label label-warning" data-toggle="tooltip" title="{}">{}</span> {}',
_('This feature will be removed in the future as it does not handle VAT for non-business customers in '
'other EU countries in a way that works for all organizers. Use custom rules instead.'),
_('DEPRECATED'),
_("Not recommended. Most events will NOT be qualified for reverse charge since the place of "
"taxation is the location of the event. This option disables charging VAT for all customers "
"outside the EU and for business customers in different EU countries who entered a valid EU VAT "
"ID. Only enable this option after consulting a tax counsel. No warranty given for correct tax "
"calculation. USE AT YOUR OWN RISK.")
),
)
home_country = FastCountryField(
verbose_name=_('Merchant country'),
+11 -9
View File
@@ -1542,10 +1542,9 @@ def add_items_to_cart(self, event: int, items: List[dict], cart_id: str=None, lo
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
def apply_voucher(self, event: Event, voucher: str, cart_id: str=None, locale='en', sales_channel='web', override_now_dt: datetime=None) -> None:
"""
Removes a list of items from a user's cart.
:param event: The event ID in question
:param voucher: A voucher code
:param session: Session ID of a guest
:param cart_id: The cart ID of the cart to modify
"""
with language(locale), time_machine_now_assigned(override_now_dt):
try:
@@ -1566,10 +1565,10 @@ def apply_voucher(self, event: Event, voucher: str, cart_id: str=None, locale='e
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
def remove_cart_position(self, event: Event, position: int, cart_id: str=None, locale='en', sales_channel='web', override_now_dt: datetime=None) -> None:
"""
Removes a list of items from a user's cart.
Removes an item specified by its position ID from a user's cart.
:param event: The event ID in question
:param position: A cart position ID
:param session: Session ID of a guest
:param cart_id: The cart ID of the cart to modify
"""
with language(locale), time_machine_now_assigned(override_now_dt):
try:
@@ -1590,9 +1589,9 @@ def remove_cart_position(self, event: Event, position: int, cart_id: str=None, l
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
def clear_cart(self, event: Event, cart_id: str=None, locale='en', sales_channel='web', override_now_dt: datetime=None) -> None:
"""
Removes a list of items from a user's cart.
Removes all items from a user's cart.
:param event: The event ID in question
:param session: Session ID of a guest
:param cart_id: The cart ID of the cart to modify
"""
with language(locale), time_machine_now_assigned(override_now_dt):
try:
@@ -1611,13 +1610,15 @@ def clear_cart(self, event: Event, cart_id: str=None, locale='en', sales_channel
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
def set_cart_addons(self, event: Event, addons: List[dict], cart_id: str=None, locale='en',
def set_cart_addons(self, event: Event, addons: List[dict], add_to_cart_items: List[dict], cart_id: str=None, locale='en',
invoice_address: int=None, sales_channel='web', override_now_dt: datetime=None) -> None:
"""
Removes a list of items from a user's cart.
Assigns addons to eligible products in a user's cart, adding and removing the addon products as necessary to
ensure the requested addon state.
:param event: The event ID in question
:param addons: A list of dicts with the keys addon_to, item, variation
:param session: Session ID of a guest
:param add_to_cart_items: A list of dicts with the keys item, variation, count, custom_price, voucher, seat ID
:param cart_id: The cart ID of the cart to modify
"""
with language(locale), time_machine_now_assigned(override_now_dt):
ia = False
@@ -1635,6 +1636,7 @@ def set_cart_addons(self, event: Event, addons: List[dict], cart_id: str=None, l
try:
cm = CartManager(event=event, cart_id=cart_id, invoice_address=ia, sales_channel=sales_channel)
cm.set_addons(addons)
cm.add_new_items(add_to_cart_items)
cm.commit()
except LockTimeoutException:
self.retry()
+3 -2
View File
@@ -1182,10 +1182,11 @@ def process_exit_all(sender, **kwargs):
positions = cl.positions_inside_query(ignore_status=True, at_time=cl.exit_all_at)
for p in positions:
with scope(organizer=cl.event.organizer):
ci = Checkin.objects.create(
ci, created = Checkin.objects.get_or_create(
position=p, list=cl, auto_checked_in=True, type=Checkin.TYPE_EXIT, datetime=cl.exit_all_at
)
checkin_created.send(cl.event, checkin=ci)
if created:
checkin_created.send(cl.event, checkin=ci)
d = cl.exit_all_at.astimezone(cl.event.timezone)
if cl.event.settings.get(f'autocheckin_dst_hack_{cl.pk}'): # move time back if yesterday was DST switch
d -= timedelta(hours=1)
+232
View File
@@ -0,0 +1,232 @@
#
# This file is part of pretix (Community Edition).
#
# Copyright (C) 2014-2020 Raphael Michel and contributors
# Copyright (C) 2020-2021 rami.io GmbH and contributors
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
# Public License as published by the Free Software Foundation in version 3 of the License.
#
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
# this file, see <https://pretix.eu/about/en/license>.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
from collections import defaultdict
from decimal import Decimal
from itertools import groupby
from math import inf
from typing import List
from django.utils.functional import cached_property
from pretix.base.models import CartPosition, ItemCategory, SalesChannel
from pretix.presale.views.event import get_grouped_items
class DummyCategory:
"""
Used to create fake category objects for displaying the same cross-selling category multiple times,
once for each subevent
"""
def __init__(self, category: ItemCategory, subevent):
self.id = category.id
self.name = str(category.name)
self.subevent_name = str(subevent)
self.description = category.description
class CrossSellingService:
def __init__(self, event, sales_channel: SalesChannel, cartpositions: List[CartPosition], customer):
self.event = event
self.sales_channel = sales_channel
self.cartpositions = cartpositions
self.customer = customer
def get_data(self):
if self.event.has_subevents:
subevents = set(pos.subevent for pos in self.cartpositions)
result = (
(DummyCategory(category, subevent),
self._prepare_items(subevent, items_qs, discount_info),
f'subevent_{subevent.pk}_')
for subevent in subevents
for (category, items_qs, discount_info) in self._applicable_categories(subevent.pk)
)
else:
result = (
(category,
self._prepare_items(None, items_qs, discount_info),
'')
for (category, items_qs, discount_info) in self._applicable_categories(0)
)
result = [(category, items, form_prefix) for (category, items, form_prefix) in result if len(items) > 0]
for category, items, form_prefix in result:
category.category_has_discount = any(item.original_price for item in items)
return result
def _applicable_categories(self, subevent_id):
return [
(c, products_qs, discount_info) for (c, products_qs, discount_info) in
(
(c, *self._get_visible_items_for_category(subevent_id, c))
for c in self.event.categories.filter(cross_selling_mode__isnull=False).prefetch_related('items')
)
if products_qs is not None
]
def _get_visible_items_for_category(self, filter_subevent_id, category: ItemCategory):
"""
If this category should be visible in the cross-selling step for a given cart and sales_channel, this method
returns a queryset of the items that should be displayed, as well as a dict giving additional information on them.
:returns: (QuerySet<Item>, dict<(subevent_id, item_pk): (max_count, discount_rule)>)
max_count is `inf` if the item should not be limited
discount_rule is None if the item will not be discounted
"""
if category.cross_selling_mode is None:
return None, {}
if category.cross_selling_condition == 'always':
return category.items.all(), {}
if category.cross_selling_condition == 'products':
match = set(match.pk for match in category.cross_selling_match_products.only('pk')) # TODO prefetch this
return (category.items.all(), {}) if any(pos.item.pk in match for pos in self.cartpositions) else (None, {})
if category.cross_selling_condition == 'discounts':
my_item_pks = [item.id for item in category.items.all()]
potential_discount_items = {
item.pk: (max_count, discount_rule)
for subevent_id, item, max_count, discount_rule in self._potential_discounts_by_subevent_and_item_for_current_cart
if max_count > 0 and item.pk in my_item_pks and item.is_available() and (subevent_id == filter_subevent_id or subevent_id is None)
}
return category.items.filter(pk__in=potential_discount_items), potential_discount_items
@cached_property
def _potential_discounts_by_subevent_and_item_for_current_cart(self):
potential_discounts_by_cartpos = defaultdict(list)
from ..services.pricing import apply_discounts
self._discounted_prices = apply_discounts(
self.event,
self.sales_channel,
[
(cp.item_id, cp.subevent_id, cp.line_price_gross, bool(cp.addon_to), cp.is_bundled,
cp.listed_price - cp.price_after_voucher)
for cp in self.cartpositions
],
collect_potential_discounts=potential_discounts_by_cartpos
)
# flatten potential_discounts_by_cartpos (a dict of lists of potential discounts) into a set of potential discounts
# (which is technically stored as a dict, but we use it as an OrderedSet here)
potential_discount_set = dict.fromkeys(
info for lst in potential_discounts_by_cartpos.values() for info in lst)
# sum up the max_counts and pass them on (also pass on the discount_rules so we can calculate actual discounted prices later):
# group by benefit product
# - max_count for product: sum up max_counts
# - discount_rule for product: take first discount_rule
def discount_info(subevent_id, item, infos_for_item):
infos_for_item = list(infos_for_item)
return (
subevent_id,
item,
sum(max_count for (subevent_id, item, discount_rule, max_count, i) in infos_for_item),
next(discount_rule for (subevent_id, item, discount_rule, max_count, i) in infos_for_item),
)
return [
discount_info(subevent_id, item, infos_for_item) for (subevent_id, item), infos_for_item in
groupby(
sorted(
(
(subevent_id, item, discount_rule, max_count, i)
for (discount_rule, max_count, i, subevent_id) in potential_discount_set.keys()
for item in discount_rule.benefit_limit_products.all()
),
key=lambda tup: (tup[0], tup[1].pk)
),
lambda tup: (tup[0], tup[1]))
]
def _prepare_items(self, subevent, items_qs, discount_info):
items, _btn = get_grouped_items(
self.event,
subevent=subevent,
voucher=None,
channel=self.sales_channel,
base_qs=items_qs,
allow_addons=False,
allow_cross_sell=True,
memberships=(
self.customer.usable_memberships(
for_event=subevent or self.event,
testmode=self.event.testmode
)
if self.customer else None
),
)
new_items = list()
for item in items:
max_count = inf
if item.pk in discount_info:
(max_count, discount_rule) = discount_info[item.pk]
# only benefit_only_apply_to_cheapest_n_matches discounted items have a max_count, all others get 'inf'
if not max_count:
max_count = inf
# calculate discounted price
if discount_rule and discount_rule.benefit_discount_matching_percent > 0:
if not item.has_variations:
item.original_price = item.original_price or item.display_price
previous_price = item.display_price
new_price = (
previous_price * (
(Decimal('100.00') - discount_rule.benefit_discount_matching_percent) / Decimal('100.00'))
)
item.display_price = new_price
else:
# discounts always match "whole" items, not specific variations -> we apply the discount to all
# available variations of the item
for var in item.available_variations:
var.original_price = var.original_price or var.display_price
previous_price = var.display_price
new_price = (
previous_price * (
(Decimal('100.00') - discount_rule.benefit_discount_matching_percent) / Decimal('100.00'))
)
var.display_price = new_price
if not item.has_variations:
# reduce order_max by number of items already in cart (prevent recommending a product the user can't add anyway)
item.order_max = min(
item.order_max - sum(1 for pos in self.cartpositions if pos.item_id == item.pk),
max_count
)
if item.order_max > 0:
new_items.append(item)
else:
new_vars = list()
for var in item.available_variations:
# reduce order_max by number of items already in cart (prevent recommending a product the user can't add anyway)
var.order_max = min(
var.order_max - sum(1 for pos in self.cartpositions if pos.item_id == item.pk and pos.variation_id == var.pk),
max_count
)
if var.order_max > 0:
new_vars.append(var)
if len(new_vars):
item.available_variations = new_vars
new_items.append(item)
return new_items
+15 -5
View File
@@ -20,8 +20,9 @@
# <https://www.gnu.org/licenses/>.
#
import re
from collections import defaultdict
from decimal import Decimal
from typing import List, Optional, Tuple
from typing import List, Optional, Tuple, Union
from django import forms
from django.db.models import Q
@@ -31,6 +32,7 @@ from pretix.base.models import (
AbstractPosition, InvoiceAddress, Item, ItemAddOn, ItemVariation,
SalesChannel, Voucher,
)
from pretix.base.models.discount import Discount, PositionInfo
from pretix.base.models.event import Event, SubEvent
from pretix.base.models.tax import TAXED_ZERO, TaxedPrice, TaxRule
from pretix.base.timemachine import time_machine_now
@@ -155,14 +157,22 @@ def get_line_price(price_after_voucher: Decimal, custom_price_input: Decimal, cu
return price
def apply_discounts(event: Event, sales_channel: str,
positions: List[Tuple[int, Optional[int], Decimal, bool, bool]]) -> List[Decimal]:
def apply_discounts(event: Event, sales_channel: Union[str, SalesChannel],
positions: List[Tuple[int, Optional[int], Decimal, bool, bool, Decimal]],
collect_potential_discounts: Optional[defaultdict]=None) -> List[Tuple[Decimal, Optional[Discount]]]:
"""
Applies any dynamic discounts to a cart
:param event: Event the cart belongs to
:param sales_channel: Sales channel the cart was created with
:param positions: Tuple of the form ``(item_id, subevent_id, line_price_gross, is_addon_to, is_bundled, voucher_discount)``
:param collect_potential_discounts: If a `defaultdict(list)` is supplied, all discounts that could be applied to the cart
based on the "consumed" items, but lack matching "benefitting" items will be collected therein.
The dict will contain a mapping from index in the `positions` list of the item that could be consumed, to a list
of tuples describing the discounts that could be applied in the form `(discount, max_count, grouping_id)`.
`max_count` is either the maximum number of benefitting items that the discount would apply to, or `inf` if that number
is not limited. The `grouping_id` can be used to distinguish several occurrences of the same discount.
:return: A list of ``(new_gross_price, discount)`` tuples in the same order as the input
"""
if isinstance(sales_channel, SalesChannel):
@@ -177,10 +187,10 @@ def apply_discounts(event: Event, sales_channel: str,
).prefetch_related('condition_limit_products', 'benefit_limit_products').order_by('position', 'pk')
for discount in discount_qs:
result = discount.apply({
idx: (item_id, subevent_id, line_price_gross, is_addon_to, voucher_discount)
idx: PositionInfo(item_id, subevent_id, line_price_gross, is_addon_to, voucher_discount)
for idx, (item_id, subevent_id, line_price_gross, is_addon_to, is_bundled, voucher_discount) in enumerate(positions)
if not is_bundled and idx not in new_prices
})
}, collect_potential_discounts)
for k in result.keys():
result[k] = (result[k], discount)
new_prices.update(result)
+13 -2
View File
@@ -30,7 +30,9 @@ from celery import states
from celery.result import AsyncResult
from django.conf import settings
from django.contrib import messages
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.exceptions import (
BadRequest, PermissionDenied, ValidationError,
)
from django.core.files.uploadedfile import UploadedFile
from django.db import transaction
from django.http import HttpResponse, JsonResponse, QueryDict
@@ -131,6 +133,8 @@ class AsyncMixin:
return data
def get_result(self, request):
if not request.GET.get('async_id'):
raise BadRequest("No async_id given")
res = AsyncResult(request.GET.get('async_id'))
if 'ajax' in self.request.GET:
return JsonResponse(self._return_ajax_result(res, timeout=0.25))
@@ -140,7 +144,12 @@ class AsyncMixin:
return self.success(res.info)
else:
return self.error(res.info)
return render(request, 'pretixpresale/waiting.html')
state, info = res.state, res.info
return render(request, 'pretixpresale/waiting.html', {
'started': state in ('PROGRESS', 'STARTED'),
'percentage': info.get('value', 0) if isinstance(info, dict) else 0,
'steps': info.get('steps', []) if isinstance(info, dict) else None,
})
def success(self, value):
smes = self.get_success_message(value)
@@ -208,6 +217,8 @@ class AsyncAction(AsyncMixin):
def get(self, request, *args, **kwargs):
if 'async_id' in request.GET and settings.HAS_CELERY:
if not request.GET.get('async_id'):
raise BadRequest("No async_id given")
return self.get_result(request)
return self.http_method_not_allowed(request)
+59 -2
View File
@@ -40,7 +40,8 @@ from urllib.parse import urlencode
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db.models import Max
from django.db.models import Max, Q
from django.forms import ChoiceField, RadioSelect
from django.forms.formsets import DELETION_FIELD_NAME
from django.urls import reverse
from django.utils.functional import cached_property
@@ -79,11 +80,67 @@ class CategoryForm(I18nModelForm):
'name',
'internal_name',
'description',
'is_addon'
'cross_selling_condition',
'cross_selling_match_products',
]
widgets = {
'description': I18nMarkdownTextarea,
'cross_selling_condition': RadioSelect,
}
field_classes = {
'cross_selling_match_products': SafeModelMultipleChoiceField,
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
tpl = '{} &nbsp; <span class="text-muted">{}</span>'
self.fields['category_type'] = ChoiceField(widget=RadioSelect, choices=(
('normal', mark_safe(tpl.format(
_('Normal category'),
_('Products in this category are regular products displayed on the front page.')
)),),
('addon', mark_safe(tpl.format(
_('Add-on product category'),
_('Products in this category are add-on products and can only be bought as add-ons.')
)),),
('only', mark_safe(tpl.format(
_('Cross-selling category'),
_('Products in this category are regular products, but are only shown in the cross-selling step, '
'according to the configuration below.')
)),),
('both', mark_safe(tpl.format(
_('Normal + cross-selling category'),
_('Products in this category are regular products displayed on the front page, but are additionally '
'shown in the cross-selling step, according to the configuration below.')
)),),
))
self.fields['category_type'].initial = self.instance.category_type
self.fields['cross_selling_condition'].widget.attrs['data-display-dependency'] = '#id_category_type_2,#id_category_type_3'
self.fields['cross_selling_condition'].widget.attrs['data-disable-dependent'] = 'true'
self.fields['cross_selling_condition'].widget.choices = self.fields['cross_selling_condition'].widget.choices[1:]
self.fields['cross_selling_condition'].required = False
self.fields['cross_selling_match_products'].widget = forms.CheckboxSelectMultiple(
attrs={
'class': 'scrolling-multiple-choice',
'data-display-dependency': '#id_cross_selling_condition_2'
}
)
self.fields['cross_selling_match_products'].queryset = self.event.items.filter(
# don't show products which are only visible in addon/cross-sell step themselves
Q(category__isnull=True) | Q(
Q(category__is_addon=False) & Q(Q(category__cross_selling_mode='both') | Q(category__cross_selling_mode__isnull=True))
)
)
def clean(self):
d = super().clean()
if d.get('category_type') == 'only' or d.get('category_type') == 'both':
if not d.get('cross_selling_condition'):
raise ValidationError({'cross_selling_condition': [_('This field is required')]})
self.instance.category_type = d.get('category_type')
return d
class QuestionForm(I18nModelForm):
@@ -41,7 +41,7 @@
{% bootstrap_field form.eu_reverse_charge layout="control" %}
{% bootstrap_field form.home_country layout="control" %}
{% bootstrap_field form.keep_gross_if_rate_changes layout="control" %}
<h3>{% trans "Custom taxation rules" %}</h3>
<h3>{% trans "Custom rules" %}</h3>
<div class="alert alert-warning">
{% blocktrans trimmed %}
These settings are intended for professional users with very specific taxation situations.
@@ -31,6 +31,7 @@
<thead>
<tr>
<th>{% trans "Product categories" %}</th>
<th>{% trans "Category type" %}</th>
<th class="action-col-2"></th>
</tr>
</thead>
@@ -40,6 +41,9 @@
<td>
<strong><a href="{% url "control:event.items.categories.edit" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}">{{ c.internal_name|default:c.name }}</a></strong>
</td>
<td>
{{ c.get_category_type_display }}
</td>
<td class="text-right flip">
<button title="{% trans "Move up" %}" formaction="{% url "control:event.items.categories.up" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-up"{% if forloop.counter0 == 0 and not page_obj.has_previous %} disabled{% endif %}><i class="fa fa-arrow-up"></i></button>
<button title="{% trans "Move down" %}" formaction="{% url "control:event.items.categories.down" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-down"{% if forloop.revcounter0 == 0 and not page_obj.has_next %} disabled{% endif %}><i class="fa fa-arrow-down"></i></button>
@@ -16,7 +16,9 @@
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.description layout="control" %}
{% bootstrap_field form.is_addon layout="control" %}
{% bootstrap_field form.category_type layout="control" horizontal_field_class="big-radio-wrapper col-lg-9" %}
{% bootstrap_field form.cross_selling_condition layout="control" horizontal_field_class="col-lg-9" %}
{% bootstrap_field form.cross_selling_match_products layout="control" %}
</fieldset>
</div>
{% if category %}
@@ -133,7 +133,7 @@
{% endif %}
{{ i.default_price|money:request.event.currency }}
{% if i.original_price %}<strike class="text-muted">{{ i.original_price|money:request.event.currency }}</strike>{% endif %}
{% if i.tax_rule and i.default_price %}
{% if i.tax_rule %}
<br/>
<small class="text-muted">
{% if not i.tax_rule.price_includes_tax %}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -4
View File
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"PO-Revision-Date: 2024-08-27 16:02+0000\n"
"PO-Revision-Date: 2024-09-10 07:17+0000\n"
"Last-Translator: Raphael Michel <michel@rami.io>\n"
"Language-Team: German <https://translate.pretix.eu/projects/pretix/pretix-js/"
"de/>\n"
@@ -572,10 +572,8 @@ msgid "Group of objects"
msgstr "Gruppe von Objekten"
#: pretix/static/pretixcontrol/js/ui/editor.js:899
#, fuzzy
#| msgid "Text object"
msgid "Text object (deprecated)"
msgstr "Text-Objekt"
msgstr "Text-Objekt (veraltet)"
#: pretix/static/pretixcontrol/js/ui/editor.js:901
msgid "Text box"
+3
View File
@@ -4,6 +4,7 @@ AES
Absenderadresse
Absenderinformation
Absendername
ABGEKÜNDIGT
Admin
Adminbereich
Affirm
@@ -25,6 +26,7 @@ Ausgangsscans
ausgeklappt
ausgecheckt
auswahl
Auth
Authentication
Authenticator
Authentifizierungsmechanismus
@@ -36,6 +38,7 @@ Bancontact
BankID
Banking
barcodes
Baskisch
Bcc
BCC
Beispielevent
File diff suppressed because it is too large Load Diff
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"PO-Revision-Date: 2024-08-27 16:00+0000\n"
"PO-Revision-Date: 2024-09-10 07:17+0000\n"
"Last-Translator: Raphael Michel <michel@rami.io>\n"
"Language-Team: German (informal) <https://translate.pretix.eu/projects/"
"pretix/pretix-js/de_Informal/>\n"
@@ -571,10 +571,8 @@ msgid "Group of objects"
msgstr "Gruppe von Objekten"
#: pretix/static/pretixcontrol/js/ui/editor.js:899
#, fuzzy
#| msgid "Text object"
msgid "Text object (deprecated)"
msgstr "Text-Objekt"
msgstr "Text-Objekt (veraltet)"
#: pretix/static/pretixcontrol/js/ui/editor.js:901
msgid "Text box"
@@ -4,6 +4,7 @@ AES
Absenderadresse
Absenderinformation
Absendername
ABGEKÜNDIGT
Admin
Adminbereich
Affirm
@@ -25,6 +26,7 @@ Ausgangsscans
ausgeklappt
ausgecheckt
auswahl
Auth
Authentication
Authenticator
Authentifizierungsmechanismus
@@ -36,6 +38,7 @@ Bancontact
BankID
Banking
barcodes
Baskisch
Bcc
BCC
Beispielevent
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"POT-Creation-Date: 2024-09-26 11:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3 -31
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"POT-Creation-Date: 2024-09-26 11:23+0000\n"
"PO-Revision-Date: 2024-09-06 08:47+0000\n"
"Last-Translator: Albizuri <oier@puntu.eus>\n"
"Language-Team: Basque <https://translate.pretix.eu/projects/pretix/pretix-js/"
@@ -557,17 +557,14 @@ msgid "absent"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:171
#: pretix/static/pretixcontrol/js/ui/editor.js:72
msgid "Check-in QR"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:543
#: pretix/static/pretixcontrol/js/ui/editor.js:387
msgid "The PDF background file could not be loaded for the following reason:"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:894
#: pretix/static/pretixcontrol/js/ui/editor.js:656
msgid "Group of objects"
msgstr ""
@@ -580,44 +577,35 @@ msgid "Text box"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:903
#: pretix/static/pretixcontrol/js/ui/editor.js:663
msgid "Barcode area"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:905
#: pretix/static/pretixcontrol/js/ui/editor.js:665
msgid "Image area"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:907
#: pretix/static/pretixcontrol/js/ui/editor.js:667
msgid "Powered by pretix"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:909
#: pretix/static/pretixcontrol/js/ui/editor.js:669
msgid "Object"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:913
#: pretix/static/pretixcontrol/js/ui/editor.js:673
msgid "Ticket design"
msgstr "Sarrera diseinua"
#: pretix/static/pretixcontrol/js/ui/editor.js:1250
#: pretix/static/pretixcontrol/js/ui/editor.js:972
msgid "Saving failed."
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:1319
#: pretix/static/pretixcontrol/js/ui/editor.js:1370
#: pretix/static/pretixcontrol/js/ui/editor.js:1041
#: pretix/static/pretixcontrol/js/ui/editor.js:1091
msgid "Error while uploading your PDF file, please try again."
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:1353
#: pretix/static/pretixcontrol/js/ui/editor.js:1074
msgid "Do you really want to leave the editor without saving your changes?"
msgstr ""
@@ -634,17 +622,14 @@ msgid "Unknown error."
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:318
#: pretix/static/pretixcontrol/js/ui/main.js:313
msgid "Your color has great contrast and is very easy to read!"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:322
#: pretix/static/pretixcontrol/js/ui/main.js:317
msgid "Your color has decent contrast and is probably good-enough to read!"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:326
#: pretix/static/pretixcontrol/js/ui/main.js:321
msgid ""
"Your color has bad contrast for text on white background, please choose a "
"darker shade."
@@ -652,48 +637,38 @@ msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:491
#: pretix/static/pretixcontrol/js/ui/main.js:511
#: pretix/static/pretixcontrol/js/ui/main.js:475
#: pretix/static/pretixcontrol/js/ui/main.js:495
msgid "Search query"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:509
#: pretix/static/pretixcontrol/js/ui/main.js:493
msgid "All"
msgstr "Guztiak"
#: pretix/static/pretixcontrol/js/ui/main.js:510
#: pretix/static/pretixcontrol/js/ui/main.js:494
msgid "None"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:514
#: pretix/static/pretixcontrol/js/ui/main.js:498
msgid "Selected only"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:847
#: pretix/static/pretixcontrol/js/ui/main.js:828
msgid "Enter page number between 1 and %(max)s."
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:850
#: pretix/static/pretixcontrol/js/ui/main.js:831
msgid "Invalid page number."
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:1008
#: pretix/static/pretixcontrol/js/ui/main.js:989
msgid "Use a different name internally"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:1048
#: pretix/static/pretixcontrol/js/ui/main.js:1029
msgid "Click to close"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/main.js:1123
#: pretix/static/pretixcontrol/js/ui/main.js:1104
msgid "You have unsaved changes!"
msgstr ""
@@ -731,7 +706,8 @@ msgstr "Saskia iraungita"
msgid "The items in your cart are reserved for you for one minute."
msgid_plural "The items in your cart are reserved for you for {num} minutes."
msgstr[0] "Zure saskiko produktuak minutu -ez erreserbatuta daude zuretzat."
msgstr[1] "Zure saskiko produktuak {num} minutuz erreserbatuta daude zuretzat."
msgstr[1] ""
"Zure saskiko produktuak {num} minutuz erreserbatuta daude zuretzat."
#: pretix/static/pretixpresale/js/ui/main.js:203
msgid "The organizer keeps %(currency)s %(amount)s"
@@ -1099,7 +1075,3 @@ msgstr ""
#: pretix/static/pretixpresale/js/widget/widget.js:89
msgid "December"
msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:661
msgid "Text object"
msgstr ""
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -8,8 +8,8 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"PO-Revision-Date: 2024-06-08 18:00+0000\n"
"Last-Translator: David Vaz <davidmgvaz@gmail.com>\n"
"PO-Revision-Date: 2024-09-08 11:04+0000\n"
"Last-Translator: Martin Gross <gross@rami.io>\n"
"Language-Team: Portuguese (Portugal) <https://translate.pretix.eu/projects/"
"pretix/pretix-js/pt_PT/>\n"
"Language: pt_PT\n"
@@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 5.5.5\n"
"X-Generator: Weblate 5.7\n"
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:56
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:62
@@ -292,10 +292,8 @@ msgid "Information required"
msgstr ""
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:58
#, fuzzy
#| msgid "Unknown error."
msgid "Unknown ticket"
msgstr "Erro desconhecido."
msgstr "Bilhete desconhecido"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:59
msgid "Ticket type not allowed here"
@@ -805,21 +803,19 @@ msgstr ""
#: pretix/static/pretixpresale/js/widget/widget.js:20
msgctxt "widget"
msgid "Select"
msgstr ""
msgstr "Selecionar"
#: pretix/static/pretixpresale/js/widget/widget.js:21
#, javascript-format
msgctxt "widget"
msgid "Select %s"
msgstr ""
msgstr "Selecionados %s"
#: pretix/static/pretixpresale/js/widget/widget.js:22
#, fuzzy, javascript-format
#| msgctxt "widget"
#| msgid "See variations"
#, javascript-format
msgctxt "widget"
msgid "Select variant %s"
msgstr "Ver alternativas"
msgstr "Selecione variantes %s"
#: pretix/static/pretixpresale/js/widget/widget.js:23
msgctxt "widget"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+75 -59
View File
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"PO-Revision-Date: 2024-06-26 22:00+0000\n"
"PO-Revision-Date: 2024-09-15 18:00+0000\n"
"Last-Translator: Kristian Feldsam <feldsam@gmail.com>\n"
"Language-Team: Slovak <https://translate.pretix.eu/projects/pretix/pretix-js/"
"sk/>\n"
@@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 5.6.1\n"
"X-Generator: Weblate 5.7\n"
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:56
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:62
@@ -156,7 +156,7 @@ msgstr ""
#: pretix/plugins/statistics/static/pretixplugins/statistics/statistics.js:15
#: pretix/plugins/statistics/static/pretixplugins/statistics/statistics.js:39
msgid "Paid orders"
msgstr ""
msgstr "Zaplatené objednávky"
#: pretix/plugins/statistics/static/pretixplugins/statistics/statistics.js:27
msgid "Total revenue"
@@ -176,15 +176,15 @@ msgstr ""
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:30
msgid "Select a check-in list"
msgstr ""
msgstr "Vyberte zoznam na odbavenie"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:31
msgid "No active check-in lists found."
msgstr ""
msgstr "Nenašli sa žiadne aktívne zoznamy na odbavenie."
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:32
msgid "Switch check-in list"
msgstr ""
msgstr "Prepnúť zoznam odbavení"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:33
msgid "Search results"
@@ -274,7 +274,7 @@ msgstr ""
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:56
msgid "Ticket already used"
msgstr ""
msgstr "Už použitá vstupenka"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:57
msgid "Information required"
@@ -282,7 +282,7 @@ msgstr ""
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:58
msgid "Unknown ticket"
msgstr ""
msgstr "Neznáma vstupenka"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:59
msgid "Ticket type not allowed here"
@@ -318,7 +318,7 @@ msgstr ""
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:68
msgid "Checked-in Tickets"
msgstr ""
msgstr "Odbavené vstupenky"
#: pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.js:69
msgid "Valid Tickets"
@@ -398,6 +398,9 @@ msgid ""
"than one minute, please check your internet connection and then reload this "
"page and try again."
msgstr ""
"Momentálne odosielame vašu požiadavku na server. Ak to trvá dlhšie ako jednu "
"minútu, skontrolujte svoje internetové pripojenie a potom znovu načítajte "
"túto stránku a skúste to znova."
#: pretix/static/pretixbase/js/asynctask.js:301
#: pretix/static/pretixcontrol/js/ui/main.js:71
@@ -546,7 +549,7 @@ msgstr ""
#: pretix/static/pretixcontrol/js/ui/editor.js:171
msgid "Check-in QR"
msgstr ""
msgstr "QR na odbavenie"
#: pretix/static/pretixcontrol/js/ui/editor.js:543
msgid "The PDF background file could not be loaded for the following reason:"
@@ -683,6 +686,8 @@ msgid ""
"The items in your cart are no longer reserved for you. You can still "
"complete your order as long as theyre available."
msgstr ""
"Vstupenky v košíku už nie sú pre Vás rezervované. Objednávku môžete "
"dokončiť, ak sú stále k dispozícii."
#: pretix/static/pretixpresale/js/ui/cart.js:45
msgid "Cart expired"
@@ -691,8 +696,9 @@ msgstr ""
#: pretix/static/pretixpresale/js/ui/cart.js:50
msgid "The items in your cart are reserved for you for one minute."
msgid_plural "The items in your cart are reserved for you for {num} minutes."
msgstr[0] ""
msgstr[1] ""
msgstr[0] "Vstupenky v košíku sú pre Vás rezervované jednu minútu."
msgstr[1] "Vstupenky v košíku sú pre Vás rezervované {num} minúty."
msgstr[2] "Vstupenky v košíku sú pre Vás rezervované {num} minút."
#: pretix/static/pretixpresale/js/ui/main.js:203
msgid "The organizer keeps %(currency)s %(amount)s"
@@ -704,11 +710,11 @@ msgstr ""
#: pretix/static/pretixpresale/js/ui/main.js:227
msgid "Please enter the amount the organizer can keep."
msgstr ""
msgstr "Zadajte sumu, ktorú si organizátor môže ponechať."
#: pretix/static/pretixpresale/js/ui/main.js:449
msgid "Please enter a quantity for one of the ticket types."
msgstr ""
msgstr "Vyberte si prosím aspoň jednu vstupenku."
#: pretix/static/pretixpresale/js/ui/main.js:485
msgid "required"
@@ -730,131 +736,131 @@ msgstr ""
#: pretix/static/pretixpresale/js/widget/widget.js:16
msgctxt "widget"
msgid "Quantity"
msgstr ""
msgstr "Počet"
#: pretix/static/pretixpresale/js/widget/widget.js:17
msgctxt "widget"
msgid "Decrease quantity"
msgstr ""
msgstr "Znížiť počet"
#: pretix/static/pretixpresale/js/widget/widget.js:18
msgctxt "widget"
msgid "Increase quantity"
msgstr ""
msgstr "Zvýšiť počet"
#: pretix/static/pretixpresale/js/widget/widget.js:19
msgctxt "widget"
msgid "Price"
msgstr ""
msgstr "Cena"
#: pretix/static/pretixpresale/js/widget/widget.js:20
msgctxt "widget"
msgid "Select"
msgstr ""
msgstr "Vybrať"
#: pretix/static/pretixpresale/js/widget/widget.js:21
#, javascript-format
msgctxt "widget"
msgid "Select %s"
msgstr ""
msgstr "Vybrať %s"
#: pretix/static/pretixpresale/js/widget/widget.js:22
#, javascript-format
msgctxt "widget"
msgid "Select variant %s"
msgstr ""
msgstr "Vybrať variantu %s"
#: pretix/static/pretixpresale/js/widget/widget.js:23
msgctxt "widget"
msgid "Sold out"
msgstr ""
msgstr "Vypredané"
#: pretix/static/pretixpresale/js/widget/widget.js:24
msgctxt "widget"
msgid "Buy"
msgstr ""
msgstr "Kúpiť"
#: pretix/static/pretixpresale/js/widget/widget.js:25
msgctxt "widget"
msgid "Register"
msgstr ""
msgstr "Registrovať sa"
#: pretix/static/pretixpresale/js/widget/widget.js:26
msgctxt "widget"
msgid "Reserved"
msgstr ""
msgstr "Rezervované"
#: pretix/static/pretixpresale/js/widget/widget.js:27
msgctxt "widget"
msgid "FREE"
msgstr ""
msgstr "ZADARMO"
#: pretix/static/pretixpresale/js/widget/widget.js:28
msgctxt "widget"
msgid "from %(currency)s %(price)s"
msgstr ""
msgstr "z %(currency)s %(price)s"
#: pretix/static/pretixpresale/js/widget/widget.js:29
msgctxt "widget"
msgid "incl. %(rate)s% %(taxname)s"
msgstr ""
msgstr "vrátane %(rate)s% %(taxname)s"
#: pretix/static/pretixpresale/js/widget/widget.js:30
msgctxt "widget"
msgid "plus %(rate)s% %(taxname)s"
msgstr ""
msgstr "plus %(rate)s% %(taxname)s"
#: pretix/static/pretixpresale/js/widget/widget.js:31
msgctxt "widget"
msgid "incl. taxes"
msgstr ""
msgstr "vrátane dane"
#: pretix/static/pretixpresale/js/widget/widget.js:32
msgctxt "widget"
msgid "plus taxes"
msgstr ""
msgstr "plus daň"
#: pretix/static/pretixpresale/js/widget/widget.js:33
#, javascript-format
msgctxt "widget"
msgid "currently available: %s"
msgstr ""
msgstr "aktuálne k dispozícii: %s"
#: pretix/static/pretixpresale/js/widget/widget.js:34
msgctxt "widget"
msgid "Only available with a voucher"
msgstr ""
msgstr "K dispozícii len s poukážkou"
#: pretix/static/pretixpresale/js/widget/widget.js:35
msgctxt "widget"
msgid "Not yet available"
msgstr ""
msgstr "Zatiaľ nedostupné"
#: pretix/static/pretixpresale/js/widget/widget.js:36
msgctxt "widget"
msgid "Not available anymore"
msgstr ""
msgstr "Už nie je k dispozícii"
#: pretix/static/pretixpresale/js/widget/widget.js:37
msgctxt "widget"
msgid "Currently not available"
msgstr ""
msgstr "Momentálne nie je k dispozícii"
#: pretix/static/pretixpresale/js/widget/widget.js:38
#, javascript-format
msgctxt "widget"
msgid "minimum amount to order: %s"
msgstr ""
msgstr "minimálna suma na objednávku: %s"
#: pretix/static/pretixpresale/js/widget/widget.js:39
msgctxt "widget"
msgid "Close ticket shop"
msgstr ""
msgstr "Zatvoriť obchod so vstupenkami"
#: pretix/static/pretixpresale/js/widget/widget.js:40
msgctxt "widget"
msgid "The ticket shop could not be loaded."
msgstr ""
msgstr "Obchod so vstupenkami sa nepodarilo načítať."
#: pretix/static/pretixpresale/js/widget/widget.js:41
msgctxt "widget"
@@ -862,16 +868,18 @@ msgid ""
"There are currently a lot of users in this ticket shop. Please open the shop "
"in a new tab to continue."
msgstr ""
"V súčasnosti je v tomto obchode so vstupenkami veľa používateľov. Ak chcete "
"pokračovať, otvorte obchod v novej karte."
#: pretix/static/pretixpresale/js/widget/widget.js:43
msgctxt "widget"
msgid "Open ticket shop"
msgstr ""
msgstr "Otvoriť obchod so vstupenkami"
#: pretix/static/pretixpresale/js/widget/widget.js:44
msgctxt "widget"
msgid "The cart could not be created. Please try again later"
msgstr ""
msgstr "Nákupný košík sa nepodarilo vytvoriť. Skúste to prosím neskôr"
#: pretix/static/pretixpresale/js/widget/widget.js:45
msgctxt "widget"
@@ -879,11 +887,14 @@ msgid ""
"We could not create your cart, since there are currently too many users in "
"this ticket shop. Please click \"Continue\" to retry in a new tab."
msgstr ""
"Nepodarilo sa nám vytvoriť Váš nákupný košík, pretože v tomto obchode je "
"momentálne príliš veľa používateľov. Kliknutím na tlačidlo „Pokračovať“ to "
"skúste znova v novej karte."
#: pretix/static/pretixpresale/js/widget/widget.js:47
msgctxt "widget"
msgid "Waiting list"
msgstr ""
msgstr "Čakací zoznam"
#: pretix/static/pretixpresale/js/widget/widget.js:48
msgctxt "widget"
@@ -891,86 +902,88 @@ msgid ""
"You currently have an active cart for this event. If you select more "
"products, they will be added to your existing cart."
msgstr ""
"V súčasnosti máte aktívny nákupný košík pre toto podujatie. Ak si vyberiete "
"ďalšie vstupenky, pridajú sa do vášho existujúceho košíka."
#: pretix/static/pretixpresale/js/widget/widget.js:50
msgctxt "widget"
msgid "Resume checkout"
msgstr ""
msgstr "Pokračovať v objednávke"
#: pretix/static/pretixpresale/js/widget/widget.js:51
msgctxt "widget"
msgid "Redeem a voucher"
msgstr ""
msgstr "Uplatnenie poukážky"
#: pretix/static/pretixpresale/js/widget/widget.js:52
msgctxt "widget"
msgid "Redeem"
msgstr ""
msgstr "Uplatniť"
#: pretix/static/pretixpresale/js/widget/widget.js:53
msgctxt "widget"
msgid "Voucher code"
msgstr ""
msgstr "Kód poukážky"
#: pretix/static/pretixpresale/js/widget/widget.js:54
msgctxt "widget"
msgid "Close"
msgstr ""
msgstr "Zatvoriť"
#: pretix/static/pretixpresale/js/widget/widget.js:55
msgctxt "widget"
msgid "Continue"
msgstr ""
msgstr "Pokračovať"
#: pretix/static/pretixpresale/js/widget/widget.js:56
msgctxt "widget"
msgid "Show variants"
msgstr ""
msgstr "Zobraziť varianty"
#: pretix/static/pretixpresale/js/widget/widget.js:57
msgctxt "widget"
msgid "Hide variants"
msgstr ""
msgstr "Skryť varianty"
#: pretix/static/pretixpresale/js/widget/widget.js:58
msgctxt "widget"
msgid "Choose a different event"
msgstr ""
msgstr "Vybrať iné podujatie"
#: pretix/static/pretixpresale/js/widget/widget.js:59
msgctxt "widget"
msgid "Choose a different date"
msgstr ""
msgstr "Vybrať iný dátum"
#: pretix/static/pretixpresale/js/widget/widget.js:60
msgctxt "widget"
msgid "Back"
msgstr ""
msgstr "Späť"
#: pretix/static/pretixpresale/js/widget/widget.js:61
msgctxt "widget"
msgid "Next month"
msgstr ""
msgstr "Nasledujúci mesiac"
#: pretix/static/pretixpresale/js/widget/widget.js:62
msgctxt "widget"
msgid "Previous month"
msgstr ""
msgstr "Predchádzajúci mesiac"
#: pretix/static/pretixpresale/js/widget/widget.js:63
msgctxt "widget"
msgid "Next week"
msgstr ""
msgstr "Nasledujúci týždeň"
#: pretix/static/pretixpresale/js/widget/widget.js:64
msgctxt "widget"
msgid "Previous week"
msgstr ""
msgstr "Predchádzajúci týždeň"
#: pretix/static/pretixpresale/js/widget/widget.js:65
msgctxt "widget"
msgid "Open seat selection"
msgstr ""
msgstr "Zobraziť výber sedadiel"
#: pretix/static/pretixpresale/js/widget/widget.js:66
msgctxt "widget"
@@ -979,11 +992,14 @@ msgid ""
"add yourself to the waiting list. We will then notify if seats are available "
"again."
msgstr ""
"Niektoré alebo všetky kategórie vstupeniek sú v súčasnosti vypredané. Ak "
"chcete, môžete sa pridať na zoznam čakateľov. Budeme vás informovať, ak sa "
"miesta uvoľnia."
#: pretix/static/pretixpresale/js/widget/widget.js:67
msgctxt "widget"
msgid "Load more"
msgstr ""
msgstr "Načítať viac"
#: pretix/static/pretixpresale/js/widget/widget.js:69
msgid "Mo"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+15 -16
View File
@@ -8,16 +8,16 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-27 13:34+0000\n"
"PO-Revision-Date: 2024-06-27 17:00+0000\n"
"Last-Translator: Erik Löfman <erik@disruptiveventures.se>\n"
"Language-Team: Swedish <https://translate.pretix.eu/projects/pretix/pretix-"
"js/sv/>\n"
"PO-Revision-Date: 2024-09-12 03:00+0000\n"
"Last-Translator: Tinna Sandström <tinna@coeo.events>\n"
"Language-Team: Swedish <https://translate.pretix.eu/projects/pretix/"
"pretix-js/sv/>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.1\n"
"X-Generator: Weblate 5.7\n"
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:56
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:62
@@ -727,8 +727,8 @@ msgstr "Varukorgen har gått ut"
#: pretix/static/pretixpresale/js/ui/cart.js:50
msgid "The items in your cart are reserved for you for one minute."
msgid_plural "The items in your cart are reserved for you for {num} minutes."
msgstr[0] "Artiklarna i din varukorg är reserverade för dig i en minut."
msgstr[1] "Artiklarna i din varukorg är reserverade för dig i {num} minuter."
msgstr[0] "Produkterna i din bokning är reserverade för dig i en minut."
msgstr[1] "Produkterna i din bokning är reserverade för dig i {num} minuter."
#: pretix/static/pretixpresale/js/ui/main.js:203
msgid "The organizer keeps %(currency)s %(amount)s"
@@ -819,7 +819,7 @@ msgstr "Köp"
#: pretix/static/pretixpresale/js/widget/widget.js:25
msgctxt "widget"
msgid "Register"
msgstr "Registrera"
msgstr "BOKA"
#: pretix/static/pretixpresale/js/widget/widget.js:26
msgctxt "widget"
@@ -829,7 +829,7 @@ msgstr "Reserverad"
#: pretix/static/pretixpresale/js/widget/widget.js:27
msgctxt "widget"
msgid "FREE"
msgstr "GRATIS"
msgstr "ANTAL"
#: pretix/static/pretixpresale/js/widget/widget.js:28
msgctxt "widget"
@@ -921,7 +921,7 @@ msgstr "Öppna biljettbutik"
#: pretix/static/pretixpresale/js/widget/widget.js:44
msgctxt "widget"
msgid "The cart could not be created. Please try again later"
msgstr "Varukorgen kunde inte skapas. Vänligen försök senare"
msgstr "Bokningen kunde inte skapas. Vänligen försök senare."
#: pretix/static/pretixpresale/js/widget/widget.js:45
msgctxt "widget"
@@ -929,9 +929,8 @@ msgid ""
"We could not create your cart, since there are currently too many users in "
"this ticket shop. Please click \"Continue\" to retry in a new tab."
msgstr ""
"Vi kunde inte skapa din varukorg, då det just nu är många användare i den "
"här biljettbutiken. Klicka på \"Fortsätt\" för att försöka på nytt i en ny "
"flik."
"Vi kunde inte skapa din bokning, då det just nu är många användare i den här "
"biljettbutiken. Klicka på \"Fortsätt\" för att försöka på nytt i en ny flik."
#: pretix/static/pretixpresale/js/widget/widget.js:47
msgctxt "widget"
@@ -944,13 +943,13 @@ msgid ""
"You currently have an active cart for this event. If you select more "
"products, they will be added to your existing cart."
msgstr ""
"Du har för tillfället en aktiv varukorg för den här eventet. Om du väljer "
"fler artiklar, kommer de att läggas till din befintliga varukorg."
"Du har för tillfället en pågående bokning för den här eventet. Om du väljer "
"fler produkter, kommer de att läggas till din befintliga bokning."
#: pretix/static/pretixpresale/js/widget/widget.js:50
msgctxt "widget"
msgid "Resume checkout"
msgstr "Fortsätt med ditt köp"
msgstr "Fortsätt med ditt bokningen"
#: pretix/static/pretixpresale/js/widget/widget.js:51
msgctxt "widget"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1
View File
@@ -9,6 +9,7 @@ acceptor
analytics
anonymize
anonymized
Auth
authenticator
automatical
availabilities
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -669,7 +669,7 @@ class OrganizerActionView(OrganizerBanktransferView, OrganizerPermissionRequired
def _row_key_func(row):
return row['iban'], row['bic']
return row['iban'], row.get('bic') or ''
def _unite_transaction_rows(transaction_rows):
+13 -1
View File
@@ -31,6 +31,8 @@
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under the License.
from datetime import datetime
from django.db.models import Exists, OuterRef, Q
from i18nfield.strings import LazyI18nString
@@ -45,6 +47,7 @@ from pretix.helpers.format import format_map
@app.task(base=ProfiledEventTask, acks_late=True)
def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict, objects: list, items: list,
subevent: int, subevents_from: datetime, subevents_to: datetime,
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list,
attachments: list = None, attach_tickets: bool = False,
attach_ical: bool = False) -> None:
@@ -76,7 +79,7 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
list_id__in=checkin_lists or []
)
),
).prefetch_related('addons'):
).prefetch_related('addons', 'subevent'):
if p.addon_to_id is not None:
continue
@@ -99,6 +102,15 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
if p.attendee_email == o.email and send_to_order:
continue
if subevent and p.subevent_id != subevent:
continue
if subevents_from and p.subevent.date_from < subevents_from:
continue
if subevents_to and p.subevent.date_from >= subevents_to:
continue
try:
with language(o.locale, event.settings.region):
email_context = get_email_context(event=event, order=o, invoice_address=ia, position=p)
+3
View File
@@ -429,6 +429,9 @@ class OrderSendView(BaseSenderView):
kwargs.update({
'recipients': form.cleaned_data['recipients'],
'items': [i.pk for i in form.cleaned_data.get('items')],
'subevent': form.cleaned_data['subevent'].pk if form.cleaned_data.get('subevent') else None,
'subevents_from': form.cleaned_data.get('subevents_from'),
'subevents_to': form.cleaned_data.get('subevents_to'),
'not_checked_in': form.cleaned_data.get('not_checked_in'),
'checkin_lists': [i.pk for i in form.cleaned_data.get('checkin_lists')],
'filter_checkins': form.cleaned_data.get('filter_checkins'),
@@ -10,7 +10,7 @@
<script type="text/plain" id="stripe_payment_intent_client_secret">{{ payment_intent_client_secret }}</script>
{% if payment_intent_next_action_redirect_url %}
<script type="text/plain" id="stripe_payment_intent_next_action_redirect_url">{{ payment_intent_next_action_redirect_url }}</script>
{% endif %}}
{% endif %}
{% if payment_intent_redirect_action_handling %}
<script type="text/plain" id="stripe_payment_intent_redirect_action_handling">{{ payment_intent_redirect_action_handling }}</script>
{% endif %}
+42 -5
View File
@@ -65,6 +65,7 @@ from pretix.base.services.cart import (
CartError, CartManager, add_payment_to_cart, error_messages, get_fees,
set_cart_addons,
)
from pretix.base.services.cross_selling import CrossSellingService
from pretix.base.services.memberships import validate_memberships_in_order
from pretix.base.services.orders import perform_order
from pretix.base.services.tasks import EventTask
@@ -93,7 +94,8 @@ from pretix.presale.views import (
CartMixin, get_cart, get_cart_is_free, get_cart_total,
)
from pretix.presale.views.cart import (
cart_session, create_empty_cart_id, get_or_create_cart_id,
_items_from_post_data, cart_session, create_empty_cart_id,
get_or_create_cart_id,
)
from pretix.presale.views.event import get_grouped_items
from pretix.presale.views.questions import QuestionsViewMixin
@@ -486,9 +488,31 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
label = pgettext_lazy('checkoutflow', 'Add-on products')
icon = 'puzzle-piece'
def _check_is_applicable(self, request):
self.request = request
# check whether addons are applicable
if get_cart(request).filter(item__addons__isnull=False).exists():
return True
# don't re-check whether cross-selling is applicable if we're already past the AddOnsStep
cur_step_identifier = request.resolver_match.kwargs.get('step')
is_past_this_step = any(step.identifier == cur_step_identifier for step in request._checkout_flow[request._checkout_flow.index(self) + 1:])
if is_past_this_step:
applicable = self.cart_session.get('_checkoutflow_addons_applicable', None)
if applicable is not None:
return applicable
# check whether cross-selling is applicable
applicable = self.cross_selling_is_applicable
self.cart_session['_checkoutflow_addons_applicable'] = applicable
return applicable
def is_applicable(self, request):
if not hasattr(request, '_checkoutflow_addons_applicable'):
request._checkoutflow_addons_applicable = get_cart(request).filter(item__addons__isnull=False).exists()
cur_step_identifier = request.resolver_match.kwargs.get('step')
request._checkoutflow_addons_applicable = self._check_is_applicable(request) or cur_step_identifier == self.identifier
return request._checkoutflow_addons_applicable
def is_completed(self, request, warn=False):
@@ -605,10 +629,21 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
formset.append(formsetentry)
return formset
@cached_property
def cross_selling_is_applicable(self):
return any(len(items) > 0 for (category, items, form_prefix) in self.cross_selling_data)
@cached_property
def cross_selling_data(self):
return CrossSellingService(
self.request.event, self.request.sales_channel, self.positions, self.request.customer
).get_data()
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['forms'] = self.forms
ctx['cart'] = self.get_cart()
ctx['cross_selling_data'] = self.cross_selling_data
return ctx
def get_success_message(self, value):
@@ -687,7 +722,7 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
def post(self, request, *args, **kwargs):
self.request = request
data = []
addons = []
for f in self.forms:
for c in f['categories']:
try:
@@ -697,7 +732,7 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
return self.get(request, *args, **kwargs)
for (i, v), (c, price) in selected.items():
data.append({
addons.append({
'addon_to': f['pos'].pk,
'item': i.pk,
'variation': v.pk if v else None,
@@ -705,7 +740,9 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
'price': price,
})
return self.do(self.request.event.id, data, get_or_create_cart_id(self.request),
add_to_cart_items = _items_from_post_data(self.request, warn_if_empty=False)
return self.do(self.request.event.id, addons, add_to_cart_items, get_or_create_cart_id(self.request),
invoice_address=self.invoice_address.pk, locale=get_language(),
sales_channel=request.sales_channel.identifier, override_now_dt=time_machine_now(default=None))
+9 -3
View File
@@ -19,6 +19,7 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
import functools
import hashlib
import ipaddress
import random
@@ -27,7 +28,7 @@ from django import forms
from django.conf import settings
from django.contrib.auth.hashers import check_password
from django.contrib.auth.password_validation import (
password_validators_help_texts, validate_password,
get_password_validators, password_validators_help_texts, validate_password,
)
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core import signing
@@ -271,6 +272,11 @@ class RegistrationForm(forms.Form):
return customer
@functools.lru_cache(maxsize=None)
def get_customer_password_validators():
return get_password_validators(settings.CUSTOMER_AUTH_PASSWORD_VALIDATORS)
class SetPasswordForm(forms.Form):
required_css_class = 'required'
error_messages = {
@@ -311,7 +317,7 @@ class SetPasswordForm(forms.Form):
def clean_password(self):
password1 = self.cleaned_data.get('password', '')
if validate_password(password1, user=self.customer) is not None:
if validate_password(password1, user=self.customer, password_validators=get_customer_password_validators()) is not None:
raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')
return password1
@@ -405,7 +411,7 @@ class ChangePasswordForm(forms.Form):
def clean_password(self):
password1 = self.cleaned_data.get('password', '')
if validate_password(password1, user=self.customer) is not None:
if validate_password(password1, user=self.customer, password_validators=get_customer_password_validators()) is not None:
raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')
return password1
@@ -6,9 +6,12 @@
{% load money %}
{% load thumb %}
{% block inner %}
<p>
{% trans "For some of the products in your cart, you can choose additional options before you continue." %}
</p>
{% if forms %}
<p>
{% trans "For some of the products in your cart, you can choose additional options before you continue." %}
</p>
{% endif %}
<form class="form-horizontal" method="post" data-asynctask
data-asynctask-headline="{% trans "We're now trying to book these add-ons for you!" %}">
{% csrf_token %}
@@ -17,10 +20,12 @@
<details class="panel panel-default" open>
<summary class="panel-heading">
<h3 class="panel-title">
<span class="sr-only">{% trans "Add-ons:" %}</span>
<strong>{{ form.item.name }}{% if form.variation %}
{{ form.variation }}
{% endif %}</strong>
<span>
{% trans "Additional options for" %}
<strong>{{ form.item.name }}{% if form.variation %}
{{ form.variation }}
{% endif %}</strong>
</span>
</h3>
</summary>
<div id="cp{{ form.pos.pk }}">
@@ -46,6 +51,20 @@
</details>
{% endfor %}
</div>
{% if cross_selling_data %}
<details class="panel panel-default cross-selling" open>
<summary class="panel-heading">
<h3 class="panel-title">
{% trans "More recommendations" %}
</h3>
</summary>
<div class="panel-body">
{% include "pretixpresale/event/fragment_product_list.html" with items_by_category=cross_selling_data ev=event %}
</div>
</details>
{% endif %}
<div class="row checkout-button-row">
<div class="col-md-4 col-sm-6">
<a class="btn btn-block btn-default btn-lg"
@@ -5,20 +5,31 @@
{% load thumb %}
{% load eventsignal %}
{% load rich_text %}
{% for tup in items_by_category %}
{% if tup.0 %}
<section aria-labelledby="category-{{ tup.0.id }}"{% if tup.0.description %} aria-describedby="category-info-{{ tup.0.id }}"{% endif %}>
<h3 id="category-{{ tup.0.id }}">{{ tup.0.name }}</h3>
{% if tup.0.description %}
<div id="category-info-{{ tup.0.id }}">{{ tup.0.description|localize|rich_text }}</div>
{% for tup in items_by_category %}{% with category=tup.0 items=tup.1 form_prefix=tup.2 %}
{% if category %}
<section aria-labelledby="{{ form_prefix }}category-{{ category.id }}"{% if category.description %} aria-describedby="{{ form_prefix }}category-info-{{ category.id }}"{% endif %}>
<h3 id="{{ form_prefix }}category-{{ category.id }}">{{ category.name }}
{% if category.subevent_name %}
<small class="text-muted"><i class="fa fa-calendar"></i> {{ category.subevent_name }}</small>
{% endif %}
{% if category.category_has_discount %}
<small class="text-success">
<i class="fa fa-star" aria-hidden="true"></i>
<span class="sr-only">Congratulations!</span>
{% trans "Your order qualifies for a discount" %}
</small>
{% endif %}
</h3>
{% if category.description %}
<div id="{{ form_prefix }}category-info-{{ category.id }}">{{ category.description|localize|rich_text }}</div>
{% endif %}
{% else %}
<section aria-labelledby="category-none">
<h3 id="category-none" class="sr-only">{% trans "Uncategorized items" %}</h3>
<section aria-labelledby="{{ form_prefix }}category-none">
<h3 id="{{ form_prefix }}category-none" class="sr-only">{% trans "Uncategorized items" %}</h3>
{% endif %}
{% for item in tup.1 %}
{% for item in items %}
{% if item.has_variations %}
<article aria-labelledby="item-{{ item.pk }}-legend"{% if item.description %} aria-describedby="item-{{ item.pk }}-description"{% endif %} class="item-with-variations{% if event.settings.show_variations_expanded %} details-open{% endif %}" id="item-{{ item.pk }}">
<article aria-labelledby="{{ form_prefix }}item-{{ item.pk }}-legend"{% if item.description %} aria-describedby="{{ form_prefix }}item-{{ item.pk }}-description"{% endif %} class="item-with-variations{% if event.settings.show_variations_expanded %} details-open{% endif %}" id="{{ form_prefix }}item-{{ item.pk }}">
<div class="row product-row headline">
<div class="col-md-8 col-sm-6 col-xs-12">
{% if item.picture %}
@@ -32,9 +43,9 @@
</a>
{% endif %}
<div class="product-description {% if item.picture %}with-picture{% endif %}">
<h4 id="item-{{ item.pk }}-legend">{{ item.name }}</h4>
<h4 id="{{ form_prefix }}item-{{ item.pk }}-legend">{{ item.name }}</h4>
{% if item.description %}
<div id="item-{{ item.pk }}-description" class="product-description">
<div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description">
{{ item.description|localize|rich_text }}
</div>
{% endif %}
@@ -101,14 +112,14 @@
</div>
<div class="variations {% if not event.settings.show_variations_expanded %}variations-collapsed{% endif %}">
{% for var in item.available_variations %}
<article aria-labelledby="item-{{ item.pk }}-{{ var.pk }}-legend"{% if var.description %} aria-describedby="item-{{ item.pk }}-{{ var.pk }}-description"{% endif %} class="row product-row variation" id="item-{{ item.pk }}-{{ var.pk }}"
<article aria-labelledby="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-legend"{% if var.description %} aria-describedby="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-description"{% endif %} class="row product-row variation" id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}"
{% if not item.free_price %}
data-price="{% if event.settings.display_net_prices %}{{ var.display_price.net|unlocalize }}{% else %}{{ var.display_price.gross|unlocalize }}{% endif %}"
{% endif %}>
<div class="col-md-8 col-sm-6 col-xs-12">
<h5 id="item-{{ item.pk }}-{{ var.pk }}-legend">{{ var }}</h5>
<h5 id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-legend">{{ var }}</h5>
{% if var.description %}
<div id="item-{{ item.pk }}-{{ var.pk }}-description" class="variation-description">
<div id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-description" class="variation-description">
{{ var.description|localize|rich_text }}
</div>
{% endif %}
@@ -139,11 +150,11 @@
<div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price"
id="price-variation-{{ item.pk }}-{{ var.pk }}"
id="{{ form_prefix }}price-variation-{{ item.pk }}-{{ var.pk }}"
{% if not ev.presale_is_running %}disabled{% endif %}
placeholder="0"
min="{% if event.settings.display_net_prices %}{{ var.display_price.net|money_numberfield:event.currency }}{% else %}{{ var.display_price.gross|money_numberfield:event.currency }}{% endif %}"
name="price_{{ item.id }}_{{ var.id }}"
name="{{ form_prefix }}price_{{ item.id }}_{{ var.id }}"
{% if var.suggested_price.gross != var.display_price.gross %}
{% if event.settings.display_net_prices %}
title="{% blocktrans trimmed with item=var.value price=var.display_price.net|money:event.currency %}Modify price for {{ item }}, at least {{ price }}{% endblocktrans %}"
@@ -200,16 +211,16 @@
data-checked-onchange="price-variation-{{ item.pk }}-{{ var.pk }}"
{% endif %}
{% if not ev.presale_is_running %}disabled{% endif %}
id="variation_{{ item.id }}_{{ var.id }}"
name="variation_{{ item.id }}_{{ var.id }}"
id="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}"
name="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}"
aria-label="{% blocktrans with item=item.name var=var %}Add {{ item }}, {{ var }} to cart{% endblocktrans %}"
{% if var.description %} aria-describedby="item-{{ item.pk }}-{{ var.pk }}-description"{% endif %}>
{% if var.description %} aria-describedby="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-description"{% endif %}>
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
{% trans "Select" context "checkbox" %}
</label>
{% else %}
<div class="input-item-count-group">
<button type="button" data-step="-1" data-controls="variation_{{ item.id }}_{{ var.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}"
<button type="button" data-step="-1" data-controls="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}"
{% if not ev.presale_is_running %}disabled{% endif %}>-</button>
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if not ev.presale_is_running %}disabled{% endif %}
@@ -217,10 +228,10 @@
data-checked-onchange="price-variation-{{ item.pk }}-{{ var.pk }}"
{% endif %}
max="{{ var.order_max }}"
id="variation_{{ item.id }}_{{ var.id }}"
name="variation_{{ item.id }}_{{ var.id }}"
id="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}"
name="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}"
aria-label="{% blocktrans with item=item.name var=var.name %}Quantity of {{ item }}, {{ var }} to order{% endblocktrans %}">
<button type="button" data-step="1" data-controls="variation_{{ item.id }}_{{ var.id }}" class="btn btn-default input-item-count-inc" aria-label="{% trans "Increase quantity" %}"
<button type="button" data-step="1" data-controls="{{ form_prefix }}variation_{{ item.id }}_{{ var.id }}" class="btn btn-default input-item-count-inc" aria-label="{% trans "Increase quantity" %}"
{% if not ev.presale_is_running %}disabled{% endif %}>+</button>
</div>
{% endif %}
@@ -234,7 +245,7 @@
</div>
</article>
{% else %}
<article aria-labelledby="item-{{ item.pk }}-legend"{% if item.description %} aria-describedby="item-{{ item.pk }}-description"{% endif %} class="row product-row simple" id="item-{{ item.pk }}"
<article aria-labelledby="{{ form_prefix }}item-{{ item.pk }}-legend"{% if item.description %} aria-describedby="{{ form_prefix }}item-{{ item.pk }}-description"{% endif %} class="row product-row simple" id="{{ form_prefix }}item-{{ item.pk }}"
{% if not item.free_price %}
data-price="{% if event.settings.display_net_prices %}{{ item.display_price.net|unlocalize }}{% else %}{{ item.display_price.gross|unlocalize }}{% endif %}"
{% endif %}>
@@ -250,9 +261,9 @@
</a>
{% endif %}
<div class="product-description {% if item.picture %}with-picture{% endif %}">
<h4 id="item-{{ item.pk }}-legend">{{ item.name }}</h4>
<h4 id="{{ form_prefix }}item-{{ item.pk }}-legend">{{ item.name }}</h4>
{% if item.description %}
<div id="item-{{ item.pk }}-description" class="product-description">
<div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description">
{{ item.description|localize|rich_text }}
</div>
{% endif %}
@@ -293,10 +304,10 @@
<label class="sr-only" for="price-item-{{ item.pk }}">{% blocktrans trimmed with item=item.name currency=event.currency %}Set price in {{ currency }} for {{ item }}{% endblocktrans %}</label>
<span class="input-group-addon" aria-hidden="true">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" placeholder="0"
id="price-item-{{ item.pk }}"
id="{{ form_prefix }}price-item-{{ item.pk }}"
{% if not ev.presale_is_running %}disabled{% endif %}
min="{% if event.settings.display_net_prices %}{{ item.display_price.net|money_numberfield:event.currency }}{% else %}{{ item.display_price.gross|money_numberfield:event.currency }}{% endif %}"
name="price_{{ item.id }}"
name="{{ form_prefix }}price_{{ item.id }}"
{% if item.suggested_price.gross != item.display_price.gross %}
{% if event.settings.display_net_prices %}
title="{% blocktrans trimmed with item=item.name price=item.display_price.net|money:event.currency %}Modify price for {{ item }}, at least {{ price }}{% endblocktrans %}"
@@ -352,15 +363,15 @@
data-checked-onchange="price-item-{{ item.pk }}"
{% endif %}
{% if not ev.presale_is_running %}disabled{% endif %}
name="item_{{ item.id }}" id="item_{{ item.id }}"
name="{{ form_prefix }}item_{{ item.id }}" id="{{ form_prefix }}item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Add {{ item }} to cart{% endblocktrans %}"
{% if item.description %} aria-describedby="item-{{ item.id }}-description"{% endif %}>
{% if item.description %} aria-describedby="{{ form_prefix }}item-{{ item.id }}-description"{% endif %}>
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
{% trans "Select" context "checkbox" %}
</label>
{% else %}
<div class="input-item-count-group">
<button type="button" data-step="-1" data-controls="item_{{ item.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}"
<button type="button" data-step="-1" data-controls="{{ form_prefix }}item_{{ item.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}"
{% if not ev.presale_is_running %}disabled{% endif %}>-</button>
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if not ev.presale_is_running %}disabled{% endif %}
@@ -369,11 +380,11 @@
data-checked-onchange="price-item-{{ item.pk }}"
{% endif %}
max="{{ item.order_max }}"
name="item_{{ item.id }}"
id="item_{{ item.id }}"
name="{{ form_prefix }}item_{{ item.id }}"
id="{{ form_prefix }}item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Quantity of {{ item }} to order{% endblocktrans %}"
{% if item.description %} aria-describedby="item-{{ item.id }}-description"{% endif %}>
<button type="button" data-step="1" data-controls="item_{{ item.id }}" class="btn btn-default input-item-count-inc" aria-label="{% trans "Increase quantity" %}"
{% if item.description %} aria-describedby="{{ form_prefix }}item-{{ item.id }}-description"{% endif %}>
<button type="button" data-step="1" data-controls="{{ form_prefix }}item_{{ item.id }}" class="btn btn-default input-item-count-inc" aria-label="{% trans "Increase quantity" %}"
{% if not ev.presale_is_running %}disabled{% endif %}>+</button>
</div>
{% endif %}
@@ -386,4 +397,4 @@
{% endif %}
{% endfor %}
</section>
{% endfor %}
{% endwith %}{% endfor %}
@@ -31,7 +31,7 @@
<span class="label label-success">{% trans "Book now" %}</span>
{% endif %}
{% endif %}
{% elif event.waiting_list_active and subev.best_availability_state >= 0 %}
{% elif subev.waiting_list_active and subev.best_availability_state >= 0 %}
<span class="label label-warning">{% trans "Waiting list" %}</span>
{% elif subev.best_availability_state == 20 %}
<span class="label label-danger">{% trans "Reserved" %}</span>
@@ -38,7 +38,7 @@
<script src="{% statici18n request.LANGUAGE_CODE %}" async></script>
{% endif %}
{% if request.session.iframe_session %}
{% compress js %}
{% compress js file iframeresizer %}
<script type="text/javascript" src="{% static "iframeresizer/iframeResizer.contentWindow.js" %}"></script>
{% endcompress %}
{% endif %}
@@ -21,6 +21,23 @@
<h1>{% trans "We are processing your request …" %}</h1>
{% if percentage %}
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-{{ percentage|floatformat:0 }}">
</div>
</div>
{% if steps %}
<ol class="steps">
{% for step in steps %}
<li>
<span class="fa fa-fw {% if step.done %}fa-check text-success{% else %}fa-cog fa-spin text-muted{% endif %}"></span>
{{ step.label }}
</li>
{% endfor %}
</ol>
{% endif %}
{% endif %}
<p>
{% trans "If this takes longer than a few minutes, please contact us." %}
</p>
+2 -2
View File
@@ -318,14 +318,14 @@ def cart_exists(request):
def get_cart(request):
from pretix.presale.views.cart import get_or_create_cart_id
qqs = request.event.questions.all()
qqs = qqs.filter(ask_during_checkin=False, hidden=False)
if not hasattr(request, '_cart_cache'):
cart_id = get_or_create_cart_id(request, create=False)
if not cart_id:
request._cart_cache = CartPosition.objects.none()
else:
qqs = request.event.questions.all()
qqs = qqs.filter(ask_during_checkin=False, hidden=False)
request._cart_cache = CartPosition.objects.filter(
cart_id=cart_id, event=request.event
).annotate(
+102 -92
View File
@@ -151,104 +151,114 @@ class CartActionMixin:
except InvoiceAddress.DoesNotExist:
return InvoiceAddress()
def _item_from_post_value(self, key, value, voucher=None, voucher_ignore_if_redeemed=False):
if value.strip() == '' or '_' not in key:
return
if not key.startswith('item_') and not key.startswith('variation_') and not key.startswith('seat_'):
return
parts = key.split("_")
price = self.request.POST.get('price_' + "_".join(parts[1:]), "")
subevent = None
if 'subevent' in self.request.POST:
try:
subevent = int(self.request.POST.get('subevent'))
except ValueError:
pass
if key.startswith('seat_'):
try:
return {
'item': int(parts[1]),
'variation': int(parts[2]) if len(parts) > 2 else None,
'count': 1,
'seat': value,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
def _item_from_post_value(request, key, value, voucher=None, voucher_ignore_if_redeemed=False):
if value.strip() == '' or '_' not in key:
return
subevent = None
if key.startswith('subevent_'):
try:
amount = int(value)
parts = key.split('_', 2)
subevent = int(parts[1])
key = parts[2]
except ValueError:
pass
elif 'subevent' in request.POST:
try:
subevent = int(request.POST.get('subevent'))
except ValueError:
raise CartError(_('Please enter numbers only.'))
if amount < 0:
raise CartError(_('Please enter positive numbers only.'))
elif amount == 0:
return
if key.startswith('item_'):
try:
return {
'item': int(parts[1]),
'variation': None,
'count': amount,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
elif key.startswith('variation_'):
try:
return {
'item': int(parts[1]),
'variation': int(parts[2]),
'count': amount,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
def _items_from_post_data(self):
"""
Parses the POST data and returns a list of dictionaries
"""
# Compatibility patch that makes the frontend code a lot easier
req_items = list(self.request.POST.lists())
if '_voucher_item' in self.request.POST and '_voucher_code' in self.request.POST:
req_items.append((
'%s' % self.request.POST['_voucher_item'], ('1',)
))
pass
items = []
if 'raw' in self.request.POST:
items += json.loads(self.request.POST.get("raw"))
for key, values in req_items:
for value in values:
try:
item = self._item_from_post_value(key, value, self.request.POST.get('_voucher_code'),
voucher_ignore_if_redeemed=self.request.POST.get('_voucher_ignore_if_redeemed') == 'on')
except CartError as e:
messages.error(self.request, str(e))
return
if item:
items.append(item)
if not key.startswith('item_') and not key.startswith('variation_') and not key.startswith('seat_'):
return
if len(items) == 0:
messages.warning(self.request, _('You did not select any products.'))
return []
return items
parts = key.split("_")
price = request.POST.get('price_' + "_".join(parts[1:]), "")
if key.startswith('seat_'):
try:
return {
'item': int(parts[1]),
'variation': int(parts[2]) if len(parts) > 2 else None,
'count': 1,
'seat': value,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
try:
amount = int(value)
except ValueError:
raise CartError(_('Please enter numbers only.'))
if amount < 0:
raise CartError(_('Please enter positive numbers only.'))
elif amount == 0:
return
if key.startswith('item_'):
try:
return {
'item': int(parts[1]),
'variation': None,
'count': amount,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
elif key.startswith('variation_'):
try:
return {
'item': int(parts[1]),
'variation': int(parts[2]),
'count': amount,
'price': price,
'voucher': voucher,
'voucher_ignore_if_redeemed': voucher_ignore_if_redeemed,
'subevent': subevent
}
except ValueError:
raise CartError(_('Please enter numbers only.'))
def _items_from_post_data(request, warn_if_empty=True):
"""
Parses the POST data and returns a list of dictionaries
"""
# Compatibility patch that makes the frontend code a lot easier
req_items = list(request.POST.lists())
if '_voucher_item' in request.POST and '_voucher_code' in request.POST:
req_items.append((
'%s' % request.POST['_voucher_item'], ('1',)
))
pass
items = []
if 'raw' in request.POST:
items += json.loads(request.POST.get("raw"))
for key, values in req_items:
for value in values:
try:
item = _item_from_post_value(request, key, value, request.POST.get('_voucher_code'),
voucher_ignore_if_redeemed=request.POST.get('_voucher_ignore_if_redeemed') == 'on')
except CartError as e:
messages.error(request, str(e))
return
if item:
items.append(item)
if len(items) == 0 and warn_if_empty:
messages.warning(request, _('You did not select any products.'))
return []
return items
@scopes_disabled()
@@ -534,7 +544,7 @@ class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
cs = cart_session(request)
widget_data = cs.get('widget_data', {})
items = self._items_from_post_data()
items = _items_from_post_data(self.request)
if items:
return self.do(self.request.event.id, items, cart_id, translation.get_language(),
self.invoice_address.pk, widget_data, self.request.sales_channel.identifier,
+7 -2
View File
@@ -111,7 +111,8 @@ def item_group_by_category(items):
)
def get_grouped_items(event, *, channel: SalesChannel, subevent=None, voucher=None, require_seat=0, base_qs=None, allow_addons=False,
def get_grouped_items(event, *, channel: SalesChannel, subevent=None, voucher=None, require_seat=0, base_qs=None,
allow_addons=False, allow_cross_sell=False,
quota_cache=None, filter_items=None, filter_categories=None, memberships=None,
ignore_hide_sold_out_for_item_ids=None):
base_qs_set = base_qs is not None
@@ -193,7 +194,9 @@ def get_grouped_items(event, *, channel: SalesChannel, subevent=None, voucher=No
)
)
items = base_qs.using(settings.DATABASE_REPLICA).filter_available(channel=channel.identifier, voucher=voucher, allow_addons=allow_addons).select_related(
items = base_qs.using(settings.DATABASE_REPLICA).filter_available(
channel=channel.identifier, voucher=voucher, allow_addons=allow_addons, allow_cross_sell=allow_cross_sell
).select_related(
'category', 'tax_rule', # for re-grouping
'hidden_if_available',
).prefetch_related(
@@ -263,6 +266,8 @@ def get_grouped_items(event, *, channel: SalesChannel, subevent=None, voucher=No
quotas_to_compute = []
for item in items:
assert item.event_id == event.pk
item.event = event # save a database query if this is looked up
if item.has_variations:
for v in item.available_variations:
for q in v._subevent_quotas:

Some files were not shown because too many files have changed in this diff Show More