Compare commits

..
Author SHA1 Message Date
Martin Gross 7da5d2e0e7 Vite: Add dev CORS 2026-09-01 10:23:16 +02:00
444 changed files with 41079 additions and 49442 deletions

No files matched your search

-2
View File
@@ -1,2 +0,0 @@
# Format pre-vue code with eslint where possible (2026-09-10)
d85e52c83ed3639e040372fd0052e842e4899d90
+1 -1
View File
@@ -123,7 +123,7 @@ jobs:
working-directory: ./src working-directory: ./src
run: make all compress run: make all compress
- name: Install Playwright browsers - name: Install Playwright browsers
run: playwright install chromium --with-deps run: playwright install --with-deps
- name: Run E2E tests - name: Run E2E tests
working-directory: ./src working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/ci_postgres.cfg py.test tests/e2e/ -v --maxfail=10 --tracing=retain-on-failure run: PRETIX_CONFIG_FILE=tests/ci_postgres.cfg py.test tests/e2e/ -v --maxfail=10 --tracing=retain-on-failure
+2 -1
View File
@@ -16,6 +16,8 @@ recursive-include src/pretix/plugins/banktransfer/templates *
recursive-include src/pretix/plugins/banktransfer/static * recursive-include src/pretix/plugins/banktransfer/static *
recursive-include src/pretix/plugins/manualpayment/templates * recursive-include src/pretix/plugins/manualpayment/templates *
recursive-include src/pretix/plugins/manualpayment/static * recursive-include src/pretix/plugins/manualpayment/static *
recursive-include src/pretix/plugins/paypal/templates *
recursive-include src/pretix/plugins/paypal/static *
recursive-include src/pretix/plugins/paypal2/templates * recursive-include src/pretix/plugins/paypal2/templates *
recursive-include src/pretix/plugins/paypal2/static * recursive-include src/pretix/plugins/paypal2/static *
recursive-include src/pretix/plugins/src/pretixdroid/templates * recursive-include src/pretix/plugins/src/pretixdroid/templates *
@@ -42,7 +44,6 @@ recursive-include src *.py
recursive-include src *.svg recursive-include src *.svg
recursive-include src *.txt recursive-include src *.txt
recursive-include src Makefile recursive-include src Makefile
recursive-include src *.pdf
recursive-exclude doc * recursive-exclude doc *
recursive-exclude deployment * recursive-exclude deployment *
+1 -1
View File
@@ -173,7 +173,7 @@ Datetime String in ISO 8601 format ``"2017-12-27T10:00:00Z"``
with timezone (normally UTC) ``"2017-12-27T10:00:00.596934Z"``, with timezone (normally UTC) ``"2017-12-27T10:00:00.596934Z"``,
``"2017-12-27T10:00:00+02:00"`` ``"2017-12-27T10:00:00+02:00"``
Date String in ISO 8601 format ``2017-12-27`` Date String in ISO 8601 format ``2017-12-27``
Multi-lingual string Object of strings ``{"en": "red", "de": "rot", "de-informal": "rot"}`` Multi-lingual string Object of strings ``{"en": "red", "de": "rot", "de_Informal": "rot"}``
Money String with decimal number ``"23.42"`` Money String with decimal number ``"23.42"``
Currency String with ISO 4217 code ``"EUR"``, ``"USD"`` Currency String with ISO 4217 code ``"EUR"``, ``"USD"``
Relative datetime *either* String in ISO 8601 ``"2017-12-27T10:00:00.596934Z"``, Relative datetime *either* String in ISO 8601 ``"2017-12-27T10:00:00.596934Z"``,
+1 -1
View File
@@ -56,7 +56,7 @@ calculated automatically.
}, },
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4", "question": 1,
"answer": "23", "answer": "23",
"options": [] "options": []
} }
+8 -18
View File
@@ -3,14 +3,6 @@
Cart positions Cart positions
============== ==============
.. note::
This API is affected by an upcoming larger change to our API. The API documentation already reflects the future
version. Features or fields not yet available are marked with **NEW**.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
The API provides limited access to the cart position data model. This API currently only allows creating and deleting The API provides limited access to the cart position data model. This API currently only allows creating and deleting
cart positions to reserve quota. cart positions to reserve quota.
@@ -39,13 +31,12 @@ voucher integer Internal ID of
addon_to integer Internal ID of the position this position is an add-on for (or ``null``) addon_to integer Internal ID of the position this position is an add-on for (or ``null``)
is_bundled boolean If ``addon_to`` is set, this shows whether this is a bundled product or an addon product is_bundled boolean If ``addon_to`` is set, this shows whether this is a bundled product or an addon product
subevent integer ID of the date inside an event series this position belongs to (or ``null``) subevent integer ID of the date inside an event series this position belongs to (or ``null``)
answers list of objects Values of data fields (answers to user-defined questions) answers list of objects Answers to user-defined questions
├ datafield string **NEW** The data field's ``identifier`` (internal reference) ├ question integer Internal ID of the answered question
├ answer string Text representation of the answer ├ answer string Text representation of the answer
├ question_identifier string The question's ``identifier`` field
├ options list of integers Internal IDs of selected option(s)s (only for choice types) ├ options list of integers Internal IDs of selected option(s)s (only for choice types)
├ option_identifiers list of strings The ``identifier`` fields of the selected option(s)s └ option_identifiers list of strings The ``identifier`` fields of the selected option(s)s
├ question integer **Deprecated.** Internal ID of the data field
└ question_identifier string **Read-only, deprecated.** The data field's ``identifier`` (internal reference)
seat objects The assigned seat (or ``null``) seat objects The assigned seat (or ``null``)
├ id integer Internal ID of the seat instance ├ id integer Internal ID of the seat instance
├ name string Human-readable seat name ├ name string Human-readable seat name
@@ -208,8 +199,7 @@ Cart position endpoints
* ``bundled`` (optional, expect a list of nested objects of cart positions) * ``bundled`` (optional, expect a list of nested objects of cart positions)
* ``answers`` * ``answers``
* ``datafield`` **NEW** * ``question``
* ``question`` **DEPRECATED**
* ``answer`` * ``answer``
* ``options`` * ``options``
@@ -233,7 +223,7 @@ Cart position endpoints
"attendee_email": null, "attendee_email": null,
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4", "question": 1,
"answer": "23", "answer": "23",
"options": [] "options": []
} }
@@ -295,7 +285,7 @@ Cart position endpoints
"attendee_email": null, "attendee_email": null,
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4", "question": 1,
"answer": "23", "answer": "23",
"options": [] "options": []
} }
@@ -313,7 +303,7 @@ Cart position endpoints
"attendee_email": null, "attendee_email": null,
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4", "question": 1,
"answer": "23", "answer": "23",
"options": [] "options": []
} }
+27 -38
View File
@@ -5,14 +5,6 @@
Check-in Check-in
======== ========
.. note::
This API is affected by an upcoming larger change to our API. The API documentation already reflects the future
version. Features or fields not yet available are marked with **NEW**.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
This page describes special APIs built for ticket scanning apps. For managing check-in configuration or other operations, This page describes special APIs built for ticket scanning apps. For managing check-in configuration or other operations,
please also see :ref:`rest-checkinlists`. The check-in list API also contains endpoints to obtain statistics or log please also see :ref:`rest-checkinlists`. The check-in list API also contains endpoints to obtain statistics or log
failed scans. failed scans.
@@ -32,43 +24,39 @@ Checking a ticket in
passed needs to be from a distinct event. passed needs to be from a distinct event.
:query string expand: Expand a field inside the ``position`` object into a full object. Currently ``subevent``, ``item``, ``variation``, and ``answers.question`` are supported. Can be passed multiple times. :query string expand: Expand a field inside the ``position`` object into a full object. Currently ``subevent``, ``item``, ``variation``, and ``answers.question`` are supported. Can be passed multiple times.
:>json string secret: Scanned QR code corresponding to the ``secret`` attribute of a ticket. :<json string secret: Scanned QR code corresponding to the ``secret`` attribute of a ticket.
:>json string source_type: Type of source the ``secret`` was obtained form. Defaults to ``"barcode"``. :<json string source_type: Type of source the ``secret`` was obtained form. Defaults to ``"barcode"``.
:>json array lists: List of check-in list IDs to search on. No two check-in lists may be from the same event. :<json array lists: List of check-in list IDs to search on. No two check-in lists may be from the same event.
:>json string type: Send ``"exit"`` for an exit and ``"entry"`` (default) for an entry. :<json string type: Send ``"exit"`` for an exit and ``"entry"`` (default) for an entry.
:>json datetime datetime: Specifies the datetime of the check-in. If not supplied, the current time will be used. :<json datetime datetime: Specifies the datetime of the check-in. If not supplied, the current time will be used.
:>json boolean force: Specifies that the check-in should succeed regardless of revoked barcode, previous check-ins or required :<json boolean force: Specifies that the check-in should succeed regardless of revoked barcode, previous check-ins or required
questions that have not been filled. This is usually used to upload offline scans that already happened, questions that have not been filled. This is usually used to upload offline scans that already happened,
because there's no point in validating them since they happened whether they are valid or not. Defaults to ``false``. because there's no point in validating them since they happened whether they are valid or not. Defaults to ``false``.
:>json boolean questions_supported: When this parameter is set to ``true``, handling of questions is supported. If :<json boolean questions_supported: When this parameter is set to ``true``, handling of questions is supported. If
you do not implement question handling in your user interface, you **must** you do not implement question handling in your user interface, you **must**
set this to ``false``. In that case, questions will just be ignored. Defaults set this to ``false``. In that case, questions will just be ignored. Defaults
to ``true``. to ``true``.
:>json boolean ignore_unpaid: Specifies that the check-in should succeed even if the order is in pending state. :<json boolean ignore_unpaid: Specifies that the check-in should succeed even if the order is in pending state.
Defaults to ``false`` and only works when ``include_pending`` is set on the check-in Defaults to ``false`` and only works when ``include_pending`` is set on the check-in
list. list.
:>json object answers: If questions are supported/required, you may/must supply a mapping of ``identifier`` (`internal :<json object answers: If questions are supported/required, you may/must supply a mapping of question IDs to their
reference`) of data fields to their respective answers (**NEW**). respective answers. The answers should always be strings. In case of (multiple-)choice-type
For backwards compatibility, a mapping of data field ``id`` to answer is supported, as well.
The answers should always be strings. In case of (multiple-)choice-type
answers, the string should contain the (comma-separated) IDs of the selected options. answers, the string should contain the (comma-separated) IDs of the selected options.
:>json string nonce: You can set this parameter to a unique random value to identify this check-in. If you're sending :<json string nonce: You can set this parameter to a unique random value to identify this check-in. If you're sending
this request twice with the same nonce, the second request will also succeed but will always this request twice with the same nonce, the second request will also succeed but will always
create only one check-in object even when the previous request was successful as well. This create only one check-in object even when the previous request was successful as well. This
allows for a certain level of idempotency and enables you to re-try after a connection failure. allows for a certain level of idempotency and enables you to re-try after a connection failure.
:>json string exchange_medium_type: To perform an exchange to a reusable medium, pass the type of the new reusable medium :<json string exchange_medium_type: To perform an exchange to a reusable medium, pass the type of the new reusable medium
:>json string exchange_medium_identifier: To perform an exchange to a reusable media, pass the identifier of the new medium :<json string exchange_medium_identifier: To perform an exchange to a reusable media, pass the identifier of the new medium
:>json boolean use_order_locale: Specifies that pretix should use the customer's language (``locale`` field from the :<json boolean use_order_locale: Specifies that pretix should use the customer's language (``locale`` field from the
order) when building texts (currently only the ``reason_explanation`` response field). order) when building texts (currently only the ``reason_explanation`` response field).
Defaults to ``false`` in which case the server will determine the language (currently Defaults to ``false`` in which case the server will determine the language (currently
the event default language, might change in the future with support for the the event default language, might change in the future with support for the
``Accept-Language`` header). ``Accept-Language`` header).
:>json boolean simulate: Do not actually perform the check-in, only simulate the response. The ``position`` response :>json string status: ``"ok"``, ``"incomplete"``, ``"exchange"``, or ``"error"``
object will not reflect the simulated changes. :>json string reason: Reason code, only set on status ``"error"``, see below for possible values.
:<json string status: ``"ok"``, ``"incomplete"``, ``"exchange"``, or ``"error"`` :>json string reason_explanation: Human-readable explanation, only set on status ``"error"`` and reason ``"rules"``, can be null.
:<json string reason: Reason code, only set on status ``"error"``, see below for possible values. :>json object position: Copy of the matching order position (if any was found). The contents are the same as the
:<json string reason_explanation: Human-readable explanation, only set on status ``"error"`` and reason ``"rules"``, can be null.
:<json object position: Copy of the matching order position (if any was found). The contents are the same as the
:ref:`order-position-resource`, with the following differences: (1) The ``checkins`` value :ref:`order-position-resource`, with the following differences: (1) The ``checkins`` value
will only include check-ins for the selected list. (2) An additional boolean property will only include check-ins for the selected list. (2) An additional boolean property
``require_attention`` will inform you whether either the order or the item have the ``require_attention`` will inform you whether either the order or the item have the
@@ -76,13 +64,15 @@ Checking a ticket in
back to values from a parent product or from invoice addresses. (4) Additional properties back to values from a parent product or from invoice addresses. (4) Additional properties
``order__status``, ``order__valid_if_pending``, ``order__require_approval``, and ``order__status``, ``order__valid_if_pending``, ``order__require_approval``, and
``order__locale`` are included with details form the order for convenience. ``order__locale`` are included with details form the order for convenience.
:<json boolean require_attention: Whether or not the ``require_attention`` flag is set on the item or order. :>json boolean require_attention: Whether or not the ``require_attention`` flag is set on the item or order.
:<json list checkin_texts: List of additional texts to show to the user. :>json list checkin_texts: List of additional texts to show to the user.
:<json object list: Excerpt of information about the matching :ref:`check-in list <rest-checkinlists>` (if any was found), :>json object list: Excerpt of information about the matching :ref:`check-in list <rest-checkinlists>` (if any was found),
including the attributes ``id``, ``name``, ``event``, ``subevent``, and ``include_pending``. including the attributes ``id``, ``name``, ``event``, ``subevent``, and ``include_pending``.
:<json object questions: List of questions to be answered for check-in, only set on status ``"incomplete"``. :>json object questions: List of questions to be answered for check-in, only set on status ``"incomplete"``.
:<json object media_policy: Reusable media policy (see documentation on items), only set on status ``"exchange"``. :>json object media_policy: Reusable media policy (see documentation on items), only set on status ``"exchange"``.
:<json object media_type: Reusable media type (see documentation on items), only set on status ``"exchange"``. :>json object media_type: Reusable media type (see documentation on items), only set on status ``"exchange"``.
:>json boolean simulate: Do not actually perform the check-in, only simulate the response. The ``position`` response
object will not reflect the simulated changes.
**Example request**: **Example request**:
@@ -102,7 +92,7 @@ Checking a ticket in
"datetime": null, "datetime": null,
"questions_supported": true, "questions_supported": true,
"answers": { "answers": {
"A1B2C3D4": "XS" "4": "XS"
} }
} }
@@ -328,7 +318,6 @@ Performing a ticket search
], ],
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4",
"question": 12, "question": 12,
"answer": "Foo", "answer": "Foo",
"options": [] "options": []
+10 -21
View File
@@ -5,14 +5,6 @@
Check-in lists Check-in lists
============== ==============
.. note::
This API is affected by an upcoming larger change to our API. The API documentation already reflects the future
version. Features or fields not yet available are marked with **NEW**.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
Resource description Resource description
-------------------- --------------------
@@ -577,7 +569,6 @@ Order position endpoints
], ],
"answers": [ "answers": [
{ {
"datafield": "A1B2C3D4",
"question": 12, "question": 12,
"answer": "Foo", "answer": "Foo",
"options": [] "options": []
@@ -618,29 +609,27 @@ Order position endpoints
:query boolean untrusted_input: If set to true, the lookup parameter is **always** interpreted as a ``secret``, never :query boolean untrusted_input: If set to true, the lookup parameter is **always** interpreted as a ``secret``, never
as an ``id``. This should be always set if you are passing through untrusted, scanned as an ``id``. This should be always set if you are passing through untrusted, scanned
data to avoid guessing of ticket IDs. data to avoid guessing of ticket IDs.
:>json boolean questions_supported: When this parameter is set to ``true``, handling of questions is supported. If :<json boolean questions_supported: When this parameter is set to ``true``, handling of questions is supported. If
you do not implement question handling in your user interface, you **must** you do not implement question handling in your user interface, you **must**
set this to ``false``. In that case, questions will just be ignored. Defaults set this to ``false``. In that case, questions will just be ignored. Defaults
to ``true``. to ``true``.
:>json boolean canceled_supported: When this parameter is set to ``true``, the response code ``canceled`` may be :<json boolean canceled_supported: When this parameter is set to ``true``, the response code ``canceled`` may be
returned. Otherwise, canceled orders will return ``unpaid``. (**Deprecated**, in returned. Otherwise, canceled orders will return ``unpaid``. (**Deprecated**, in
the future, this will be ignored and ``canceled`` may always be returned.) the future, this will be ignored and ``canceled`` may always be returned.)
:>json datetime datetime: Specifies the datetime of the check-in. If not supplied, the current time will be used. :<json datetime datetime: Specifies the datetime of the check-in. If not supplied, the current time will be used.
:>json boolean force: Specifies that the check-in should succeed regardless of revoked barcode, previous check-ins or required :<json boolean force: Specifies that the check-in should succeed regardless of revoked barcode, previous check-ins or required
questions that have not been filled. This is usually used to upload offline scans that already happened, questions that have not been filled. This is usually used to upload offline scans that already happened,
because there's no point in validating them since they happened whether they are valid or not. Defaults to ``false``. because there's no point in validating them since they happened whether they are valid or not. Defaults to ``false``.
:>json string type: Send ``"exit"`` for an exit and ``"entry"`` (default) for an entry. :<json string type: Send ``"exit"`` for an exit and ``"entry"`` (default) for an entry.
:>json boolean ignore_unpaid: Specifies that the check-in should succeed even if the order is in pending state. :<json boolean ignore_unpaid: Specifies that the check-in should succeed even if the order is in pending state.
Defaults to ``false`` and only works when ``include_pending`` is set on the check-in Defaults to ``false`` and only works when ``include_pending`` is set on the check-in
list. list.
:>json string nonce: You can set this parameter to a unique random value to identify this check-in. If you're sending :<json string nonce: You can set this parameter to a unique random value to identify this check-in. If you're sending
this request twice with the same nonce, the second request will also succeed but will always this request twice with the same nonce, the second request will also succeed but will always
create only one check-in object even when the previous request was successful as well. This create only one check-in object even when the previous request was successful as well. This
allows for a certain level of idempotency and enables you to re-try after a connection failure. allows for a certain level of idempotency and enables you to re-try after a connection failure.
:>json object answers: If questions are supported/required, you may/must supply a mapping of ``identifier`` (`internal :<json object answers: If questions are supported/required, you may/must supply a mapping of question IDs to their
reference`) of data fields to their respective answers (**NEW**). respective answers. The answers should always be strings. In case of (multiple-)choice-type
For backwards compatibility, a mapping of data field ``id`` to answer is supported, as well.
The answers should always be strings. In case of (multiple-)choice-type
answers, the string should contain the (comma-separated) IDs of the selected options. answers, the string should contain the (comma-separated) IDs of the selected options.
**Example request**: **Example request**:
@@ -659,7 +648,7 @@ Order position endpoints
"questions_supported": true, "questions_supported": true,
"canceled_supported": true, "canceled_supported": true,
"answers": { "answers": {
"A1B2C3D4": "XS" "4": "XS"
} }
} }
-250
View File
@@ -1,250 +0,0 @@
.. _rest-datafieldoptions:
Data field options
================
.. note::
This API is part of an upcoming larger change to our API. The API documentation already reflects the future
version. Until the change, this resource is still available at ``/questions/(id)/options/``.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
Resource description
--------------------
:ref:`Data fields <rest-datafields>` of type "choice" or "multiple choice" can have different options attached.
As with data fields, data field options exist on two resource paths, depending on whether
the data field is attached to orders or order positions. Therefore, each endpoint below has two
different URLs.
The options resource contains the following public fields:
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Internal ID of the option
position integer An integer, used for sorting
identifier string An arbitrary string that can be used for matching with
other sources.
answer multi-lingual string The displayed value of this option
===================================== ========================== =======================================================
Endpoints
---------
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(datafield)/options/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(datafield)/options/
Returns a list of all options for a given data field.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/datafields/position/11/options/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 2,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 3,
"answer": {"en": "L"}
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
:query boolean active: If set to ``true`` or ``false``, only data fields with this value for the field ``active`` will be
returned.
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param datafield: The ``id`` field of the data field to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event/data field does not exist **or** you have no permission to view this resource.
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(datafield)/options/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(datafield)/options/(id)/
Returns information on one option, identified by its ID.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param datafield: The ``id`` field of the data field to fetch
:param id: The ``id`` field of the option to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(datafield)/options/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(datafield)/options/
Create a new option
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/options/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer of the event/data field to create a option for
:param event: The ``slug`` field of the event to create a option for
:param datafield: The ``id`` field of the data field to create a option for
:statuscode 201: no error
:statuscode 400: The option could not be created due to invalid submitted data.
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to create this resource.
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(datafield)/options/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(datafield)/options/(id)/
Update an option. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of
the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you
want to change.
You can change all fields of the resource except the ``id`` field.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94
{
"position": 3
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param id: The ``id`` field of the data field to modify
:param id: The ``id`` field of the option to modify
:statuscode 200: no error
:statuscode 400: The option could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to change this resource.
.. http:delete:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(datafield)/options/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(datafield)/options/(id)/
Delete an option.
**Example request**:
.. sourcecode:: http
DELETE /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 No Content
Vary: Accept
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param datafield: The ``id`` field of the data field to modify
:param id: The ``id`` field of the option to delete
:statuscode 204: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to delete this resource.
-428
View File
@@ -1,428 +0,0 @@
.. _rest-datafields:
Data fields
=========
.. note::
This API is part of an upcoming larger change to our API. The API documentation already reflects the future
version. Until the change, please keep using the endpoints at ``/questions/``.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
Resource description
--------------------
Data fields define additional fields related to an order or an order position.
By referencing data fields in a questionnaire, you can have customers or staff fill them out -- during or
after checkout (web or POS), during check-in in the ticket scanner app, or in the backend.
There are two different resource paths for data fields, depending on whether the data field is attached
to orders or order positions. Therefore, each endpoint below has two different URLs.
The data field resource contains the following public fields:
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Internal ID of the data field
internal_name string **Required.** An internal field label
identifier string An arbitrary string that can be used for matching with
other sources.
Must be unique per event, across all types of data fields.
type string **Required.** The expected type of data. Valid options:
* ``N`` – number
* ``S`` – one-line string
* ``T`` – multi-line string
* ``B`` – boolean
* ``C`` – choice from a list
* ``M`` – multiple choice from a list
* ``F`` – file upload
* ``D`` – date
* ``H`` – time
* ``W`` – date and time
* ``CC`` – country code (ISO 3666-1 alpha-2)
* ``TEL`` – telephone number
show_during_checkin boolean If ``true``, the value of the data field will be shown
during check-in (if the check-in client supports it).
*Only supported on per-position data fields.*
print_on_invoice boolean If ``true``, the data field will be shown on
invoices.
*Only supported on per-position data fields.*
print_on_invoice_label multi-lingual string **Required if ``print_on_invoice`` is ``true``.** Label
to print on the invoice before the value of this field.
Otherwise `null`.
options list of objects In case of data field type ``C`` or ``M``, this lists the
available objects. Only writable during creation,
use :ref:`separate endpoint <rest-datafieldoptions>` to modify this later.
├ id integer Internal ID of the option
├ position integer An integer, used for sorting
├ identifier string An arbitrary string that can be used for matching with
other sources.
└ answer multi-lingual string The displayed value of this option
valid_number_min string Minimum value for number fields (optional)
valid_number_max string Maximum value for number fields (optional)
valid_date_min date Minimum value for date fields (optional)
valid_date_max date Maximum value for date fields (optional)
valid_datetime_min datetime Minimum value for date and time fields (optional)
valid_datetime_max datetime Maximum value for date and time fields (optional)
valid_file_portrait boolean Turn on file validation for portrait photos
valid_string_length_min integer Minimum length for string fields (optional)
valid_string_length_max integer Maximum length for string fields (optional)
referenced_by_questionnaires list of integers **Read-only.** List of questionnaire IDs that reference
this data field
===================================== ========================== =======================================================
Endpoints
---------
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/
Returns a list of all data fields within a given event.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/datafields/position/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"internal_name": "T-Shirt size",
"type": "C",
"identifier": "WY3TP9SL",
"show_during_checkin": false,
"print_on_invoice": false,
"print_on_invoice_label": null,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"valid_string_length_min": null,
"valid_string_length_max": null,
"valid_file_portrait": false,
"options": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 0,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 1,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 2,
"answer": {"en": "L"}
}
],
"referenced_by_questionnaires": [1]
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
:query string ordering: Manually set the ordering of results. Valid fields to be used are ``id`` and ``position``.
Default: ``position``
:query string identifier: Only return questions with the given identifier string
:query boolean ask_during_checkin: Only return questions that are or are not to be asked during check-in
:query boolean required: Only return questions that are or are not required to fill in
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(id)/
Returns information on one data field, identified by its ID.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"internal_name": "T-Shirt size",
"type": "C",
"identifier": "WY3TP9SL",
"show_during_checkin": false,
"print_on_invoice": false,
"print_on_invoice_label": null,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"valid_string_length_min": null,
"valid_string_length_max": null,
"valid_file_portrait": false,
"options": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 0,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 1,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 2,
"answer": {"en": "L"}
}
],
"referenced_by_questionnaires": [1]
}
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param id: The ``id`` field of the question to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/
Create a new question
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/events/sampleconf/datafields/position/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"internal_name": "T-Shirt size",
"type": "C",
"show_during_checkin": false,
"print_on_invoice": false,
"print_on_invoice_label": null,
"options": [
{
"answer": {"en": "S"}
},
{
"answer": {"en": "M"}
},
{
"answer": {"en": "L"}
}
]
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
"id": 1,
"internal_name": "T-Shirt size",
"type": "C",
"identifier": "WY3TP9SL",
"show_during_checkin": false,
"print_on_invoice": false,
"print_on_invoice_label": null,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"valid_string_length_min": null,
"valid_string_length_max": null,
"valid_file_portrait": false,
"options": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 0,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 1,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 2,
"answer": {"en": "L"}
}
],
"referenced_by_questionnaires": [1]
}
:param organizer: The ``slug`` field of the organizer of the event to create an item for
:param event: The ``slug`` field of the event to create an item for
:statuscode 201: no error
:statuscode 400: The item could not be created due to invalid submitted data.
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to create this resource.
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(id)/
Update a data field. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of
the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you
want to change.
You can change all fields of the resource except the ``options`` field. If
you need to update/delete options please use the nested dedicated endpoints.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94
{
"internal_name": "Clothing size"
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"internal_name": "Clothing size",
"type": "C",
"identifier": "WY3TP9SL",
"show_during_checkin": false,
"print_on_invoice": false,
"print_on_invoice_label": null,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"valid_string_length_min": null,
"valid_string_length_max": null,
"valid_file_portrait": false,
"options": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 0,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 1,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 2,
"answer": {"en": "L"}
}
],
"referenced_by_questionnaires": [1]
}
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param id: The ``id`` field of the question to modify
:statuscode 200: no error
:statuscode 400: The question could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to change this resource.
.. http:delete:: /api/v1/organizers/(organizer)/events/(event)/datafields/position/(id)/
/api/v1/organizers/(organizer)/events/(event)/datafields/order/(id)/
Delete a data field.
**Example request**:
.. sourcecode:: http
DELETE /api/v1/organizers/bigevents/events/sampleconf/datafields/position/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 No Content
Vary: Accept
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param id: The ``id`` field of the question to delete
:statuscode 204: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to delete this resource.
-241
View File
@@ -1,241 +0,0 @@
Event Meta Properties
=====================
Resource description
--------------------
An event meta property is used to to define meta information fields for its events.
This information can be re-used, for example, in ticket layouts.
The event meta property resource contains the following public fields:
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Unique ID for this property
name string Name of the property
default string Value of the default option
required boolean If ``true``, an event can only be taken live if the
property is set. In event series, it's always optional
to set a value for individual dates
protected boolean If ``true``, the value for an event can only be changed
by organizer-level administrators
filter_public boolean If ``true``, this property will be shown to filter
events in the public event list and calendar
public_label string Public name of the property
filter_allowed boolean If ``true``, this property will be shown to filter
events or reports in the backend, and it can also be
used for hidden filter parameters in the frontend
choices list of objects List of JSON objects representing all permitted values
for this property, or ``null`` for no limitation.
Each choice object has a required internal name named
``key`` and optional public name named ``label``
consisting of a dictionary of i18n string translations
===================================== ========================== =======================================================
Endpoints
---------
.. http:get:: /api/v1/organizers/(organizer)/event_meta_properties/
Returns a list of all meta properties for the organizer.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/meta_properties/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"name": "Color",
"default": "blue",
"required": false,
"protected": false,
"filter_public": false,
"public_label": {},
"filter_allowed": true,
"choices": [
{
"key": "blue",
"label": {
"en": "Blue"
},
}
]
}
]
}
:param organizer: The ``slug`` field of the organizer
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
.. http:get:: /api/v1/organizers/(organizer)/event_meta_properties/(id)/
Returns information on one property, identified by its id.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/event_meta_properties/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
{
"id": 1,
"name": "Color",
"default": "blue",
"required": false,
"protected": false,
"filter_public": false,
"public_label": {},
"filter_allowed": true,
"choices": null
}
:param organizer: The ``slug`` field of the organizer
:param id: The ``id`` field of the meta property to retrieve
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
.. http:post:: /api/v1/organizers/(organizer)/event_meta_properties/
Creates a new meta property
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/event_meta_properties/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"name": "ref-code",
"default": "abcde",
"required": true,
"choices": null
}
**Example response**:
.. sourcecode:: http
{
"id": 2,
"name": "reference",
"default": "abcde",
"required": true,
"protected": false,
"filter_public": false,
"public_label": null,
"filter_allowed": true,
"choices": null
}
:param organizer: The ``slug`` field of the organizer
:statuscode 201: no error
:statuscode 400: The meta property could not be created due to invalid submitted data.
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to create this resource.
.. http:patch:: /api/v1/organizers/(organizer)/event_meta_properties/(id)/
Update a meta property. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide
all fields of the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the
fields that you want to change.
You can change all fields of the resource except the ``id`` field.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/event_meta_properties/2/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94
{
"required": false
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 3,
"name": "reference",
"default": "abcde",
"required": false,
"protected": false,
"filter_public": false,
"public_label": null,
"filter_allowed": true,
"choices": null
}
:param organizer: The ``slug`` field of the organizer
:param id: The ``id`` field of the meta property to modify
:statuscode 200: no error
:statuscode 400: The property could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to change this resource.
.. http:delete:: /api/v1/organizers/(organizer)/event_meta_properties/(id)/
Delete a meta property.
**Example request**:
.. sourcecode:: http
DELETE /api/v1/organizers/bigevents/event_meta_properties/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 No Content
Vary: Accept
:param organizer: The ``slug`` field of the organizer
:param id: The ``id`` field of the meta property to delete
:statuscode 204: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to delete this resource.
+15 -17
View File
@@ -110,7 +110,7 @@ Endpoints
"plugins": [ "plugins": [
"pretix.plugins.banktransfer", "pretix.plugins.banktransfer",
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2", "pretix.plugins.paypal",
"pretix.plugins.ticketoutputpdf" "pretix.plugins.ticketoutputpdf"
], ],
"all_sales_channels": false, "all_sales_channels": false,
@@ -199,7 +199,7 @@ Endpoints
"plugins": [ "plugins": [
"pretix.plugins.banktransfer", "pretix.plugins.banktransfer",
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2", "pretix.plugins.paypal",
"pretix.plugins.ticketoutputpdf" "pretix.plugins.ticketoutputpdf"
], ],
"valid_keys": { "valid_keys": {
@@ -262,7 +262,7 @@ Endpoints
"item_meta_properties": {}, "item_meta_properties": {},
"plugins": [ "plugins": [
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2" "pretix.plugins.paypal"
], ],
"all_sales_channels": true, "all_sales_channels": true,
"limit_sales_channels": [] "limit_sales_channels": []
@@ -299,7 +299,7 @@ Endpoints
"item_meta_properties": {}, "item_meta_properties": {},
"plugins": [ "plugins": [
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2" "pretix.plugins.paypal"
], ],
"all_sales_channels": true, "all_sales_channels": true,
"limit_sales_channels": [], "limit_sales_channels": [],
@@ -364,7 +364,7 @@ Endpoints
"item_meta_properties": {}, "item_meta_properties": {},
"plugins": [ "plugins": [
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2" "pretix.plugins.paypal"
], ],
"all_sales_channels": true, "all_sales_channels": true,
"limit_sales_channels": [] "limit_sales_channels": []
@@ -401,7 +401,7 @@ Endpoints
"item_meta_properties": {}, "item_meta_properties": {},
"plugins": [ "plugins": [
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2" "pretix.plugins.paypal"
], ],
"all_sales_channels": true, "all_sales_channels": true,
"limit_sales_channels": [], "limit_sales_channels": [],
@@ -438,7 +438,7 @@ Endpoints
"plugins": [ "plugins": [
"pretix.plugins.banktransfer", "pretix.plugins.banktransfer",
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2", "pretix.plugins.paypal",
"pretix.plugins.pretixdroid" "pretix.plugins.pretixdroid"
] ]
} }
@@ -475,7 +475,7 @@ Endpoints
"plugins": [ "plugins": [
"pretix.plugins.banktransfer", "pretix.plugins.banktransfer",
"pretix.plugins.stripe", "pretix.plugins.stripe",
"pretix.plugins.paypal2", "pretix.plugins.paypal",
"pretix.plugins.pretixdroid" "pretix.plugins.pretixdroid"
], ],
"all_sales_channels": true, "all_sales_channels": true,
@@ -566,7 +566,7 @@ organizer level.
Content-Type: application/json Content-Type: application/json
{ {
"region": "DE", "imprint_url": "https://pretix.eu",
… …
} }
@@ -579,14 +579,12 @@ organizer level.
Content-Type: application/json Content-Type: application/json
{ {
"region": "imprint_url":
{ {
"value": "DE", "value": "https://pretix.eu",
"label": "Region", "label": "Imprint URL",
"readonly": false, "readonly": false,
"help_text": "Will be used to determine date and time formatting as well as default country for customer "help_text": "This should point e.g. to a part of your website that has your contact details and legal information."
addresses and phone numbers. For formatting, this takes less priority than the language and
is therefore mostly relevant for languages used in different regions globally (like English)."
} }
}, },
… …
@@ -622,7 +620,7 @@ organizer level.
Content-Type: application/json Content-Type: application/json
{ {
"region": "DE" "imprint_url": "https://example.org/imprint/"
} }
**Example response**: **Example response**:
@@ -634,7 +632,7 @@ organizer level.
Content-Type: application/json Content-Type: application/json
{ {
"region": "DE", "imprint_url": "https://example.org/imprint/",
… …
} }
-4
View File
@@ -12,7 +12,6 @@ at :ref:`plugin-docs`.
organizers organizers
events events
subevents subevents
event_meta_properties
taxrules taxrules
categories categories
items items
@@ -21,9 +20,6 @@ at :ref:`plugin-docs`.
item_add-ons item_add-ons
item_meta_properties item_meta_properties
item_program_times item_program_times
datafields
datafield_options
questionnaires
questions questions
question_options question_options
quotas quotas
+5 -13
View File
@@ -37,9 +37,12 @@ tax_rule integer The internal
admission boolean ``true`` for items that grant admission to the event admission boolean ``true`` for items that grant admission to the event
(such as primary tickets) and ``false`` for others (such as primary tickets) and ``false`` for others
(such as add-ons or merchandise). (such as add-ons or merchandise).
personalized boolean **DEPRECATED.** ``true`` for items that require personalization according personalized boolean ``true`` for items that require personalization according
to event settings. Only affects system-level fields, not to event settings. Only affects system-level fields, not
custom questions. Defaults to ``false``. custom questions. Currently only allowed for products with
``admission`` set to ``true``. For backwards compatibility,
when creating new items and this field is not given, it defaults
to the same value as ``admission``.
position integer An integer, used for sorting position integer An integer, used for sorting
picture file A product picture to be displayed in the shop picture file A product picture to be displayed in the shop
(can be ``null``). (can be ``null``).
@@ -230,17 +233,6 @@ meta_data object Values set fo
The ``program_times`` attribute has been added. The ``program_times`` attribute has been added.
.. versionchanged:: 2027.1
The ``personalized`` attribute has been deprecated.
For compatibility with existing applications:
* When retrieving products, `personalized` is `True` if any attached questionnaire asks for `attendee_name` and/or `attendee_email`.
* When creating a new product, setting the `personalized` field to `True` will attach the "Attendee data" questionnaire to the new product. If no such questionnaire exists, it will be created.
Before, the `personalized` field defaulted to the same value as `admission`. Now, it defaults to `false`.
* When updating a product, the `personalized` field cannot be changed, returning an HTTP 400 error if attempted.
Notes Notes
----- -----
+12 -63
View File
@@ -9,14 +9,6 @@
Orders Orders
====== ======
.. note::
This API is affected by an upcoming larger change to our API. The API documentation already reflects the future
version. Features or fields not yet available are marked with **NEW**.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
Order resource Order resource
-------------- --------------
@@ -127,11 +119,6 @@ cancellation_date datetime Time of order c
plugin_data object Additional data added by plugins. plugin_data object Additional data added by plugins.
use_gift_cards list of strings List of unique gift card secrets that are used to pay use_gift_cards list of strings List of unique gift card secrets that are used to pay
for this order. for this order.
answers list of objects **NEW** Values of data fields (answers to user-defined questions)
├ datafield string The data field's ``identifier`` (internal reference)
├ answer string Text representation of the answer
├ options list of integers Internal IDs of selected option(s)s (only for choice types)
└ option_identifiers list of strings The ``identifier`` fields of the selected option(s)s
===================================== ========================== ======================================================= ===================================== ========================== =======================================================
@@ -175,10 +162,6 @@ answers list of objects **NEW** Values
The ``use_gift_cards`` attribute has been added. The ``use_gift_cards`` attribute has been added.
.. versionchanged:: 2027.1
The ``answers`` attribute has been added.
.. _order-position-resource: .. _order-position-resource:
Order position resource Order position resource
@@ -248,13 +231,12 @@ print_logs list of objects List of print j
downloads list of objects List of ticket download options downloads list of objects List of ticket download options
├ output string Ticket output provider (e.g. ``pdf``, ``passbook``) ├ output string Ticket output provider (e.g. ``pdf``, ``passbook``)
└ url string Download URL └ url string Download URL
answers list of objects Values of data fields (answers to user-defined questions) answers list of objects Answers to user-defined questions
├ datafield string **NEW** The data field's ``identifier`` (internal reference) ├ question integer Internal ID of the answered question
├ answer string Text representation of the answer ├ answer string Text representation of the answer (URL if answer is a file)
├ question_identifier string The question's ``identifier`` field
├ options list of integers Internal IDs of selected option(s)s (only for choice types) ├ options list of integers Internal IDs of selected option(s)s (only for choice types)
├ option_identifiers list of strings The ``identifier`` fields of the selected option(s)s └ option_identifiers list of strings The ``identifier`` fields of the selected option(s)s
├ question integer **Deprecated.** Internal ID of the data field
└ question_identifier string **Read-only, deprecated.** The data field's ``identifier`` (internal reference)
seat objects The assigned seat. Can be ``null``. seat objects The assigned seat. Can be ``null``.
├ id integer Internal ID of the seat instance ├ id integer Internal ID of the seat instance
├ name string Human-readable seat name ├ name string Human-readable seat name
@@ -470,11 +452,10 @@ List of all orders
], ],
"answers": [ "answers": [
{ {
"datafield": "WY3TP9SL",
"question": 12, "question": 12,
"question_identifier": "WY3TP9SL", "question_identifier": "WY3TP9SL",
"answer": "Foo", "answer": "Foo",
"option_identifiers": [], "option_idenfiters": [],
"options": [] "options": []
} }
], ],
@@ -507,15 +488,7 @@ List of all orders
], ],
"refunds": [], "refunds": [],
"cancellation_date": null, "cancellation_date": null,
"plugin_data": {}, "plugin_data": {}
"answers": [
{
"datafield": "XYZ12345",
"answer": "42",
"option_identifiers": [],
"options": []
}
]
} }
] ]
} }
@@ -726,7 +699,6 @@ Fetching individual orders
], ],
"answers": [ "answers": [
{ {
"datafield": "WY3TP9SL",
"question": 12, "question": 12,
"question_identifier": "WY3TP9SL", "question_identifier": "WY3TP9SL",
"answer": "Foo", "answer": "Foo",
@@ -763,15 +735,7 @@ Fetching individual orders
], ],
"refunds": [], "refunds": [],
"cancellation_date": null, "cancellation_date": null,
"plugin_data": {}, "plugin_data": {}
"answers": [
{
"datafield": "XYZ12345",
"answer": "42",
"option_identifiers": [],
"options": []
}
]
} }
:param organizer: The ``slug`` field of the organizer to fetch :param organizer: The ``slug`` field of the organizer to fetch
@@ -1115,8 +1079,7 @@ Creating orders
* ``discount`` (optional, only possible if ``price`` is set; attention: if this is set to not-``null`` on any position, automatic calculation of discounts will not run) * ``discount`` (optional, only possible if ``price`` is set; attention: if this is set to not-``null`` on any position, automatic calculation of discounts will not run)
* ``answers`` * ``answers``
* ``datafield`` (**NEW**) * ``question``
* ``question`` (**DEPRECATED**)
* ``answer`` * ``answer``
* ``options`` * ``options``
@@ -1151,12 +1114,6 @@ Creating orders
order isn't completely paid after its creation with ``use_gift_cards``, then a subsequent request to the payment order isn't completely paid after its creation with ``use_gift_cards``, then a subsequent request to the payment
endpoint is needed. endpoint is needed.
* **NEW** ``answers`` (optional). Values for order-level data fields.
* ``datafield``
* ``answer``
* ``options``
If you want to use add-on products, you need to set the ``positionid`` fields of all positions manually If you want to use add-on products, you need to set the ``positionid`` fields of all positions manually
to incrementing integers starting with ``1``. Then, you can reference one of these to incrementing integers starting with ``1``. Then, you can reference one of these
IDs in the ``addon_to`` field of another position. Note that all add_ons for a specific position need to come IDs in the ``addon_to`` field of another position. Note that all add_ons for a specific position need to come
@@ -1204,12 +1161,6 @@ Creating orders
"internal_reference": "", "internal_reference": "",
"vat_id": "" "vat_id": ""
}, },
"answers": [
{
"datafield": "XYZ12345",
"answer": "42"
}
],
"positions": [ "positions": [
{ {
"positionid": 1, "positionid": 1,
@@ -1223,7 +1174,7 @@ Creating orders
"addon_to": null, "addon_to": null,
"answers": [ "answers": [
{ {
"datafield": "WY3TP9SL", "question": 1,
"answer": "23", "answer": "23",
"options": [] "options": []
} }
@@ -1733,7 +1684,6 @@ List of all order positions
], ],
"answers": [ "answers": [
{ {
"datafield": "WY3TP9SL",
"question": 12, "question": 12,
"question_identifier": "WY3TP9SL", "question_identifier": "WY3TP9SL",
"answer": "Foo", "answer": "Foo",
@@ -1913,7 +1863,6 @@ Fetching individual positions
], ],
"answers": [ "answers": [
{ {
"datafield": "WY3TP9SL",
"question": 12, "question": 12,
"question_identifier": "WY3TP9SL", "question_identifier": "WY3TP9SL",
"answer": "Foo", "answer": "Foo",
@@ -2022,7 +1971,7 @@ Manipulating individual positions
* ``answers``: If specified, you will need to provide **all** answers for this order position. * ``answers``: If specified, you will need to provide **all** answers for this order position.
Validation is handled the same way as when creating orders through the API. You are therefore Validation is handled the same way as when creating orders through the API. You are therefore
expected to provide ``datafield``, ``answer``, and possibly ``options``. ``question`` is deprecated. ``question_identifier`` expected to provide ``question``, ``answer``, and possibly ``options``. ``question_identifier``
and ``option_identifiers`` will be ignored. As a special case, you can submit the magic value and ``option_identifiers`` will be ignored. As a special case, you can submit the magic value
``"file:keep"`` as the answer to a file question to keep the current value without re-uploading it. ``"file:keep"`` as the answer to a file question to keep the current value without re-uploading it.
@@ -2118,7 +2067,7 @@ Manipulating individual positions
* ``state`` * ``state``
* ``answers``: Validation is handled the same way as when creating orders through the API. You are therefore * ``answers``: Validation is handled the same way as when creating orders through the API. You are therefore
expected to provide ``datafield``, ``answer``, and possibly ``options``. ``question`` is deprecated. ``question_identifier`` expected to provide ``question``, ``answer``, and possibly ``options``. ``question_identifier``
and ``option_identifiers`` will be ignored. As a special case, you can submit the magic value and ``option_identifiers`` will be ignored. As a special case, you can submit the magic value
``"file:keep"`` as the answer to a file question to keep the current value without re-uploading it. ``"file:keep"`` as the answer to a file question to keep the current value without re-uploading it.
+224 -2
View File
@@ -1,7 +1,229 @@
Question options Question options
================ ================
.. warning:: This resource is **deprecated**. Resource description
--------------------
New applications must use the :ref:`rest-datafieldoptions` resource. Questions of type "choice" or "multiple choice" can have different options attached.
The options resource contains the following public fields:
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Internal ID of the option
position integer An integer, used for sorting
identifier string An arbitrary string that can be used for matching with
other sources.
answer multi-lingual string The displayed value of this option
===================================== ========================== =======================================================
Endpoints
---------
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/questions/(question)/options/
Returns a list of all options for a given question.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/questions/11/options/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
},
{
"id": 2,
"identifier": "DFEMJWMJ",
"position": 2,
"answer": {"en": "M"}
},
{
"id": 3,
"identifier": "W9AH7RDE",
"position": 3,
"answer": {"en": "L"}
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
:query boolean active: If set to ``true`` or ``false``, only questions with this value for the field ``active`` will be
returned.
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param question: The ``id`` field of the question to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event/question does not exist **or** you have no permission to view this resource.
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/questions/(question)/options/(id)/
Returns information on one option, identified by its ID.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/questions/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param question: The ``id`` field of the question to fetch
:param id: The ``id`` field of the option to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/questions/(question)/options/
Creates a new option
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/events/sampleconf/questions/1/options/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer of the event/question to create a option for
:param event: The ``slug`` field of the event to create a option for
:param question: The ``id`` field of the question to create a option for
:statuscode 201: no error
:statuscode 400: The option could not be created due to invalid submitted data.
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to create this resource.
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/questions/(question)/options/(id)/
Update an option. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of
the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you
want to change.
You can change all fields of the resource except the ``id`` field.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/events/sampleconf/questions/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94
{
"position": 3
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 1,
"identifier": "LVETRWVU",
"position": 1,
"answer": {"en": "S"}
}
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param id: The ``id`` field of the question to modify
:param id: The ``id`` field of the option to modify
:statuscode 200: no error
:statuscode 400: The option could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to change this resource.
.. http:delete:: /api/v1/organizers/(organizer)/events/(event)/questions/(id)/options/(id)/
Delete an option.
**Example request**:
.. sourcecode:: http
DELETE /api/v1/organizers/bigevents/events/sampleconf/questions/1/options/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 No Content
Vary: Accept
:param organizer: The ``slug`` field of the organizer to modify
:param event: The ``slug`` field of the event to modify
:param id: The ``id`` field of the question to modify
:param id: The ``id`` field of the option to delete
:statuscode 204: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to delete this resource.
-379
View File
@@ -1,379 +0,0 @@
.. _rest-questionnaires:
Questionnaires
=========
.. note::
This API is part of an upcoming larger change to our API. The API documentation already reflects the future
version. Until the change, please keep using the endpoints at ``/questions/``.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
Questionnaires are attached to one or more products, and a product can have multiple questionnaires.
They consist of questionnaire rows, each of which can be one of the following:
Reference to system field
To reference a system field, use one of the identifier strings from the table below in the row's `datafield` attribute.
Currently, system fields are only defined on order positions, not on orders.
=============== =========================== ============================
Container Identifier Label
=============== =========================== ============================
Order position `"@attendee_name_parts"` Attendee name
Order position `"@attendee_email"` Attendee email
Order position `"@company"` Company
Order position `"@street"` Street
Order position `"@zipcode"` ZIP code
Order position `"@city"` City
Order position `"@state"` State
Order position `"@country"` Country
=============== =========================== ============================
Reference to user-defined data field
To reference a :ref:`user-defined data field <rest-datafields>`, use its internal reference (`identifier`)
in the row's `datafield` attribute.
Static explanation text / subheading
To add a static text block, set the row's `datafield` attribute to `null`. In this case, the text
from the `label` attribute is displayed as a subheading, and the `help_text` attribute as a normal paragraph.
Resource description
--------------------
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Internal ID of the questionnaire
type string The type of questionnaire. Valid options:
* ``order_purchase`` — Order-wide, before purchase
* ``position_purchase`` — Per product, before purchase
* ``position_attendee`` — Per product, via attendee link
* ``position_checkin`` — Per product, at check-in
* ``position_hidden`` — Per product, hidden
internal_name string Internal label for the questionnaire.
items list of integers List of item IDs this questionnaire is assigned to.
*Only supported on per-product questionnaires.*
position integer An integer, used for sorting
all_sales_channels boolean If ``true`` (default), the questions from this questionnaire
are asked on all sales channels.
limit_sales_channels list of strings List of sales channel identifiers the questions are asked on
if ``all_sales_channels`` is ``false``.
rows list of objects List of all questionnaire rows.
├ datafield string Reference to a data field (see above)
├ required boolean If ``true``, the question needs to be filled out.
├ label multi-lingual string The field label shown to the customer. In case of a static
text block, the subheading.
├ help_text multi-lingual string The help text shown to the customer.
├ dependency_datafield string ``datafield`` reference of a different row in the same
questionnaire.
The current question will only be shown if the question
given in this attribute is set to one of the values given
in ``dependency_values``.
├ dependency_values list of strings If ``dependency_datafield`` is set to reference a boolean
data field, this should be ``["True"]`` or ``["False"]``.
Otherwise, it should be a list of ``identifier`` values
of question options.
├ rendered_help_text string **Read-only.** Markdown contents from help_text rendered
to HTML
===================================== ========================== =======================================================
Endpoints
---------
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/questionnaires/
Returns a list of all questionnaires within a given event.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/questionnaires/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"type": "position_purchase",
"internal_name": "Attendee data",
"items": [1, 2],
"position": 0,
"all_sales_channels": true,
"limit_sales_channels": [],
"rows": [
{
"datafield": "@attendee_name_parts",
"required": false,
"label": {"en": "Attendee name"},
"help_text": {},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": ""
},
{
"datafield": "@attendee_email",
"required": false,
"label": {"en": "Attendee email"},
"help_text": {"en": "*We'll send you our program guide a few days before the event.*"},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": "<em>We'll send you our program guide a few days before the event.</em>"
}
]
},
{
"id": 2,
"type": "order_purchase",
"internal_name": "Per-order questions",
"items": [],
"position": 0,
"all_sales_channels": true,
"limit_sales_channels": [],
"rows": [
{
"datafield": "87Y8DCS9",
"required": false,
"label": {"en": "How did you find us?"},
"help_text": {},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": ""
}
]
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
:query string ordering: Manually set the ordering of results. Valid fields to be used are ``id`` and ``position``.
Default: ``position``
:query string type: Only return questionnaires with the given type
:query string items: Only return questionnaires associated with the given item (internal item ID)
:query boolean sales_channel: Only return questionnaires visible on the given sales channel (sales channel identifier string)
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/questionnaires/(id)/
Returns information on one questionnaire, identified by its ID.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/questionnaires/2/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 2,
"type": "order_purchase",
"internal_name": "Per-order questions",
"items": [],
"position": 0,
"all_sales_channels": true,
"limit_sales_channels": [],
"rows": [
{
"datafield": "87Y8DCS9",
"required": false,
"label": {"en": "How did you find us?"},
"help_text": {},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": ""
}
]
}
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param id: The ``id`` field of the questionnaire to fetch
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to view this resource.
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/questionnaires/
Create a new questionnaire
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/events/sampleconf/questionnaires/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"type": "order_purchase",
"internal_name": "Per-order questions",
"position": 0,
"all_sales_channels": true,
"rows": [
{
"datafield": "87Y8DCS9",
"required": false,
"label": {"en": "How did you find us?"}
}
]
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
"id": 2,
"type": "order_purchase",
"internal_name": "Per-order questions",
"items": [],
"position": 0,
"all_sales_channels": true,
"limit_sales_channels": [],
"rows": [
{
"datafield": "87Y8DCS9",
"required": false,
"label": {"en": "How did you find us?"},
"help_text": {},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": ""
}
]
}
:param organizer: The ``slug`` field of the organizer of the event to create a questionnaire for
:param event: The ``slug`` field of the event to create a questionnaire for
:statuscode 201: no error
:statuscode 400: The questionnaire could not be created due to invalid submitted data.
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to create this resource.
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/questionnaires/(id)/
Update a questionnaire. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of
the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you
want to change.
You can only change all ``rows`` en bloc, or keep all of them unchanged in case of a ``PATCH``. If you
change ``rows``, you need to specify all fields of the resource.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/events/sampleconf/questionnaires/2/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"internal_name": "Questions asked per order"
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 2,
"type": "order_purchase",
"internal_name": "Questions asked per order",
"items": [],
"position": 0,
"all_sales_channels": true,
"limit_sales_channels": [],
"rows": [
{
"datafield": "87Y8DCS9",
"required": false,
"label": {"en": "How did you find us?"},
"help_text": {},
"dependency_datafield": null,
"dependency_values": [],
"rendered_help_text": ""
}
]
}
:param organizer: The ``slug`` field of the organizer of the questionnaire to modify
:param event: The ``slug`` field of the event of the questionnaire to modify
:param id: The ``id`` field of the questionnaire to modify
:statuscode 200: no error
:statuscode 400: The questionnaire could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to change this resource.
.. http:delete:: /api/v1/organizers/(organizer)/events/(event)/questionnaires/(id)/
Delete a questionnaire.
**Example request**:
.. sourcecode:: http
DELETE /api/v1/organizers/bigevents/events/sampleconf/questionnaires/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 No Content
Vary: Accept
:param organizer: The ``slug`` field of the organizer of the questionnaire to modify
:param event: The ``slug`` field of the event of the questionnaire to modify
:param id: The ``id`` field of the questionnaire to delete
:statuscode 204: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer/event does not exist **or** you have no permission to delete this resource.
+1 -40
View File
@@ -8,23 +8,10 @@
Questions Questions
========= =========
.. warning:: This resource is **deprecated**. It is only provided for compatibility with existing applications
and should not be used in new development.
New applications must use the :ref:`rest-datafields` and :ref:`rest-questionnaires` resources.
The new version is expected to be released for hosted pretix early December and for self-hosted pretix with
version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
This resource will continue to work in read-only mode on events where the
:ref:`questionnaire configuration <rest-questionnaires>` is compatible with the old data model.
If incompatible configuration is detected, all endpoints return HTTP 410.
Resource description Resource description
-------------------- --------------------
Questions define additional fields related to an order position that need to be filled out by customers during checkout. Questions define additional fields that need to be filled out by customers during checkout.
The question resource contains the following public fields: The question resource contains the following public fields:
.. rst-class:: rest-resource-table .. rst-class:: rest-resource-table
@@ -97,10 +84,6 @@ dependency_value string An old version
The ``show_during_checkin`` attribute has been added. The ``show_during_checkin`` attribute has been added.
.. versionchanged:: 2026.[TODO]
The questions resource was deprecated and replaced by the :ref:`rest-datafields` and :ref:`rest-questionnaires` resources.
Endpoints Endpoints
--------- ---------
@@ -266,13 +249,6 @@ Endpoints
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/questions/ .. http:post:: /api/v1/organizers/(organizer)/events/(event)/questions/
.. warning:: This endpoint is **deprecated** and will be removed as part of an upcoming API change.
The new version is expected to be released for hosted pretix early December and for self-hosted
pretix with version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
After the change, instead create a :ref:`data field <rest-datafields>` first, then add
it to a :ref:`questionnaire <rest-questionnaires>`.
Creates a new question Creates a new question
**Example request**: **Example request**:
@@ -375,13 +351,6 @@ Endpoints
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/questions/(id)/ .. http:patch:: /api/v1/organizers/(organizer)/events/(event)/questions/(id)/
.. warning:: This endpoint is **deprecated** and will be removed as part of an upcoming API change.
The new version is expected to be released for hosted pretix early December and for self-hosted
pretix with version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
After the change, instead update the relevant :ref:`data field <rest-datafields>`, or
the reference to it inside a :ref:`questionnaire <rest-questionnaires>`.
Update a question. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of Update a question. You can also use ``PUT`` instead of ``PATCH``. With ``PUT``, you have to provide all fields of
the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you the resource, other fields will be reset to default. With ``PATCH``, you only need to provide the fields that you
want to change. want to change.
@@ -468,14 +437,6 @@ Endpoints
.. http:delete:: /api/v1/organizers/(organizer)/events/(event)/questions/(id)/ .. http:delete:: /api/v1/organizers/(organizer)/events/(event)/questions/(id)/
.. warning:: This endpoint is **deprecated** and will be removed as part of an upcoming API change.
The new version is expected to be released for hosted pretix early December and for self-hosted
pretix with version 2027.1.
You can find more information `on our blog <https://pretix.eu/about/en/blog/20261110-questionnaires/>`_.
After the change, insteadremove the questionnaire child from its :ref:`questionnaire <rest-questionnaires>`,
or delete the relevant :ref:`data field <rest-datafields>`.
Delete a question. Delete a question.
**Example request**: **Example request**:
+5 -17
View File
@@ -57,7 +57,6 @@ seating_plan integer If reserved sea
seat_category_mapping object An object mapping categories of the seating plan seat_category_mapping object An object mapping categories of the seating plan
(strings) to items in the event (integers or ``null``). (strings) to items in the event (integers or ``null``).
last_modified datetime Last modification of this object last_modified datetime Last modification of this object
comment string Internal comment for this subevent (or ``null``)
===================================== ========================== ======================================================= ===================================== ========================== =======================================================
.. versionchanged:: 2023.8.0 .. versionchanged:: 2023.8.0
@@ -118,10 +117,7 @@ Endpoints
} }
], ],
"variation_price_overrides": [], "variation_price_overrides": [],
"meta_data": {}, "meta_data": {}
"frontpage_text": {},
"last_modified": "2017-12-01T10:00:30Z",
"comment": "internal comment"
} }
] ]
} }
@@ -191,9 +187,7 @@ Endpoints
} }
], ],
"variation_price_overrides": [], "variation_price_overrides": [],
"meta_data": {}, "meta_data": {}
"last_modified": "2017-12-01T10:00:30Z",
"comment": ""
} }
@@ -230,9 +224,7 @@ Endpoints
} }
], ],
"variation_price_overrides": [], "variation_price_overrides": [],
"meta_data": {}, "meta_data": {}
"last_modified": "2017-12-01T10:00:30Z",
"comment": ""
} }
@@ -290,9 +282,7 @@ Endpoints
} }
], ],
"variation_price_overrides": [], "variation_price_overrides": [],
"meta_data": {}, "meta_data": {}
"last_modified": "2017-12-01T10:00:30Z",
"comment": ""
} }
:param organizer: The ``slug`` field of a valid organizer :param organizer: The ``slug`` field of a valid organizer
@@ -453,9 +443,7 @@ Endpoints
} }
], ],
"variation_price_overrides": [], "variation_price_overrides": [],
"meta_data": {}, "meta_data": {}
"last_modified": "2017-12-01T10:00:30Z",
"comment": ""
} }
] ]
} }
-1
View File
@@ -116,7 +116,6 @@ Endpoints
:query integer page: The page number in case of a multi-page result set, default is 1 :query integer page: The page number in case of a multi-page result set, default is 1
:query string code: Only show the voucher with the given voucher code. :query string code: Only show the voucher with the given voucher code.
:query string search: Only show the voucher with the given query found in the code, tag, or comment.
:query integer max_usages: Only show vouchers with the given maximal number of usages. :query integer max_usages: Only show vouchers with the given maximal number of usages.
:query integer redeemed: Only show vouchers with the given number of redemptions. Note that this doesn't tell you if :query integer redeemed: Only show vouchers with the given number of redemptions. Note that this doesn't tell you if
the voucher can still be redeemed, as this also depends on ``max_usages``. See the the voucher can still be redeemed, as this also depends on ``max_usages``. See the
+1 -2
View File
@@ -11,8 +11,7 @@ Core
---- ----
.. automodule:: pretix.base.signals .. automodule:: pretix.base.signals
:members: periodic_task, event_live_issues, event_copy_data, email_filter, :members: periodic_task, event_live_issues, event_copy_data, email_filter, register_notification_types, notification,
register_notification_types, event_notification_sent, organizer_notification_sent,
item_copy_data, register_sales_channel_types, register_global_settings, quota_availability, global_email_filter, item_copy_data, register_sales_channel_types, register_global_settings, quota_availability, global_email_filter,
register_ticket_secret_generators, gift_card_transaction_display, register_ticket_secret_generators, gift_card_transaction_display,
register_text_placeholders, register_mail_placeholders, device_info_updated, register_text_placeholders, register_mail_placeholders, device_info_updated,
+2 -2
View File
@@ -1,6 +1,6 @@
sphinx==9.0.* sphinx==9.1.*
sphinx-rtd-theme~=3.1.0 sphinx-rtd-theme~=3.1.0
sphinxcontrib-httpdomain~=2.2.1 sphinxcontrib-httpdomain~=2.0.0
sphinxcontrib-images~=1.0.1 sphinxcontrib-images~=1.0.1
sphinxcontrib-jquery~=4.1 sphinxcontrib-jquery~=4.1
sphinxcontrib-spelling~=8.0.2 sphinxcontrib-spelling~=8.0.2
+2 -2
View File
@@ -1,7 +1,7 @@
-e ../ -e ../
sphinx==9.0.* sphinx==9.1.*
sphinx-rtd-theme~=3.1.0 sphinx-rtd-theme~=3.1.0
sphinxcontrib-httpdomain~=2.2.1 sphinxcontrib-httpdomain~=2.0.0
sphinxcontrib-images~=1.0.1 sphinxcontrib-images~=1.0.1
sphinxcontrib-jquery~=4.1 sphinxcontrib-jquery~=4.1
sphinxcontrib-spelling~=8.0.2 sphinxcontrib-spelling~=8.0.2
+1 -57
View File
@@ -8,63 +8,7 @@ import vuePug from 'eslint-plugin-vue-pug'
const ignores = globalIgnores([ const ignores = globalIgnores([
'**/node_modules', '**/node_modules',
'**/dist', '**/dist'
// Vendored code
'src/pretix/static/leaflet',
'src/pretix/static/clipboard',
'src/pretix/static/cropper',
'src/pretix/static/lightbox',
'src/pretix/static/are-you-sure',
'src/pretix/static/vuejs',
'src/pretix/static/fontawesome',
'src/pretix/static/typeahead',
'src/pretix/static/moment',
'src/pretix/static/pdfjs',
'src/pretix/static/sortable',
'src/pretix/static/iframeresizer',
'src/pretix/static/bootstrap',
'src/pretix/static/d3',
'src/pretix/static/jsi18n',
'src/pretix/static/fabric',
'src/pretix/static/datetimepicker',
'src/pretix/static/charts',
'src/pretix/static/fileupload',
'src/pretix/static/seating',
'src/pretix/static/rest_framework',
'src/pretix/static/select2',
'src/pretix/static/schema',
'src/pretix/static/slider',
'src/pretix/static/jquery',
'src/pretix/static/colorpicker',
'src/pretix/static/rrule',
'src/pretix/static/pretixcontrol/js/jquery.qrcode.min.js',
'src/pretix/static/pretixpresale/js/widget/docready.js',
// Pre-vue JS code
'src/pretix/static/pretixbase/js/addressform.js',
'src/pretix/static/pretixbase/js/asynctask.js',
'src/pretix/static/pretixbase/js/details.js',
'src/pretix/static/pretixbase/js/gettextstub.js',
'src/pretix/static/pretixbase/js/i18nstring.js',
'src/pretix/static/pretixcontrol/js/menu.js',
'src/pretix/static/pretixcontrol/js/ui/editor.js',
'src/pretix/static/pretixcontrol/js/ui/geo.js',
'src/pretix/static/pretixcontrol/js/ui/main.js',
'src/pretix/static/pretixcontrol/js/ui/subevent.js',
'src/pretix/static/pretixcontrol/js/ui/variations.js',
'src/pretix/static/pretixcontrol/js/ui/webauthn.js',
'src/pretix/static/pretixpresale/js/ui/cart.js',
'src/pretix/static/pretixpresale/js/ui/main.js',
'src/pretix/static/pretixpresale/js/ui/questions.js',
'src/pretix/static/pretixpresale/js/widget/floatformat.js',
'src/pretix/static/pretixpresale/js/widget/widget.js',
'src/pretix/plugins/banktransfer/static',
'src/pretix/plugins/paypal2/static',
'src/pretix/plugins/statistics/static',
'src/pretix/plugins/stripe/static',
// Plugin checkouts
'local',
// docs
'doc',
]) ])
export default defineConfig([ export default defineConfig([
+321 -279
View File
File diff suppressed because it is too large. Load diff
+31 -30
View File
@@ -27,26 +27,26 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"arabic-reshaper==3.1.0", # Support for Arabic in reportlab "arabic-reshaper==3.0.1", # Support for Arabic in reportlab
"babel", "babel",
"BeautifulSoup4==4.15.*", "BeautifulSoup4==4.15.*",
"bleach==6.4.*", "bleach==6.4.*",
"celery==5.6.*", "celery==5.6.*",
"chardet==5.2.*", "chardet==5.2.*",
"cryptography>=50.0.2", "cryptography>=50.0.0",
"css-inline==0.24.*", "css-inline==0.21.*",
"defusedcsv>=3.0.0", "defusedcsv>=3.0.0",
"dnspython==2.9.*", "dnspython==2.*",
"Django[argon2]==5.2.*,>=5.2.17", "Django[argon2]==5.2.*",
"django-bootstrap3==26.3", "django-bootstrap3==26.2",
"django-compressor==4.6.0", "django-compressor==4.6.0",
"django-countries==9.1.*", "django-countries==9.0.*",
"django-filter==26.2", "django-filter==26.1",
"django-formset-js-improved==0.5.0.5", "django-formset-js-improved==0.5.0.5",
"django-formtools==2.7", "django-formtools==2.7",
"django-hierarkey==2.0.*,>=2.0.2", "django-hierarkey==2.0.*,>=2.0.2",
"django-hijack==3.7.*", "django-hijack==3.7.*",
"django-i18nfield==1.12.*", "django-i18nfield==1.11.*",
"django-libsass==0.9", "django-libsass==0.9",
"django-localflavor==5.1", "django-localflavor==5.1",
"django-markup", "django-markup",
@@ -56,46 +56,49 @@ dependencies = [
"django-querytagger==0.0.3", "django-querytagger==0.0.3",
"django-redis==7.0.*", "django-redis==7.0.*",
"django-scopes==2.1.*", "django-scopes==2.1.*",
"django-statici18n==2.8.*", "django-statici18n==2.7.*",
"djangorestframework>=3.18.3", "djangorestframework==3.17.*",
"dnspython==2.8.*",
"drf_ujson2==1.7.*", "drf_ujson2==1.7.*",
"geoip2==5.*", "geoip2==5.*",
"importlib_metadata==9.*", # Polyfill, we can probably drop this once we require Python 3.10+
"isoweek", "isoweek",
"jsonschema", "jsonschema",
"kombu==5.7.*", "kombu==5.6.*",
"libsass==0.23.*", "libsass==0.23.*",
"lxml", "lxml",
"markdown==3.11.2", "markdown==3.10.3", # 3.3.5 requires importlib-metadata>=4.4, but django-bootstrap3 requires importlib-metadata<3.
# We can upgrade markdown again once django-bootstrap3 upgrades or once we drop Python 3.6 and 3.7
"mt-940==4.30.*", "mt-940==4.30.*",
"oauthlib==3.3.*", "oauthlib==3.3.*",
"openpyxl==3.1.*", "openpyxl==3.1.*",
"packaging", "packaging",
"paypalrestsdk==1.13.*", "paypalrestsdk==1.13.*",
"paypal-checkout-serversdk==1.0.*", "paypal-checkout-serversdk==1.0.*",
"PyJWT==2.15.*", "PyJWT==2.13.*",
"phonenumberslite==9.0.*", "phonenumberslite==9.0.*",
"Pillow==13.0.*", "Pillow==12.3.*",
"pretix-plugin-build", "pretix-plugin-build",
"protobuf==7.36.*", "protobuf==7.36.*",
"psycopg2-binary", "psycopg2-binary",
"pycountry", "pycountry",
"pycparser==3.12", "pycparser==3.0",
"pycryptodome==3.24.*", "pycryptodome==3.23.*",
"pypdf==6.21.*", "pypdf==6.5.*",
"python-bidi==0.6.*", # Support for Arabic in reportlab "python-bidi==0.6.*", # Support for Arabic in reportlab
"python-dateutil==4.0.*", "python-dateutil==2.9.*",
"pytz", "pytz",
"pytz-deprecation-shim==0.1.*", "pytz-deprecation-shim==0.1.*",
"pyuca", "pyuca",
"qrcode==8.2", "qrcode==8.2",
"redis==7.4.*", "redis==7.4.*",
"reportlab==5.1.*", "reportlab==5.0.*",
"requests==2.34.*", "requests==2.34.*",
"sentry-sdk==2.75.*", "sentry-sdk==2.68.*",
"sepaxml==2.7.*", "sepaxml==2.7.*",
"stripe==7.9.*", "stripe==7.9.*",
"text-unidecode==1.*", "text-unidecode==1.*",
"tlds>=2026102900", "tlds>=2026072401",
"tqdm==4.*", "tqdm==4.*",
"ua-parser==1.0.*", "ua-parser==1.0.*",
"vobject==0.9.*", "vobject==0.9.*",
@@ -109,25 +112,23 @@ dev = [
"aiohttp==3.14.*", "aiohttp==3.14.*",
"coverage", "coverage",
"coveralls", "coveralls",
"fakeredis==2.40.*", "fakeredis==2.37.*",
"flake8==7.5.*", "flake8==7.3.*",
"freezegun", "freezegun",
"isort==9.0.*", "isort==8.0.*",
"pep8-naming==0.15.*", "pep8-naming==0.15.*",
"potypo", "potypo",
"pytest-asyncio>=1.4.1.post1", "pytest-asyncio>=1.4.0",
"pytest-cache", "pytest-cache",
"pytest-cov", "pytest-cov",
"pytest-django==4.*", "pytest-django==4.*",
"pytest-mock==3.17.*", "pytest-mock==3.15.*",
"pytest-sugar", "pytest-sugar",
"pytest-xdist==3.8.*", "pytest-xdist==3.8.*",
"pytest-playwright", "pytest-playwright",
"pytest-base-url", "pytest==9.1.*",
"pytest==9.2.*",
"playwright", "playwright",
"responses", "responses",
"pypdfium2"
] ]
[project.entry-points."distutils.commands"] [project.entry-points."distutils.commands"]
+1
View File
@@ -26,6 +26,7 @@ ignore =
src/tests/plugins/* src/tests/plugins/*
src/tests/plugins/badges/* src/tests/plugins/badges/*
src/tests/plugins/banktransfer/* src/tests/plugins/banktransfer/*
src/tests/plugins/paypal/*
src/tests/plugins/paypal2/* src/tests/plugins/paypal2/*
src/tests/plugins/pretixdroid/* src/tests/plugins/pretixdroid/*
src/tests/plugins/stripe/* src/tests/plugins/stripe/*
-2
View File
@@ -30,5 +30,3 @@ npminstall:
npmbuild: npmbuild:
npm run build npm run build
licenseheaders:
licenseheaders -t ../.licenseheader -E .py -x "*/migrations/*.py"
+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 # 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/>. # <https://www.gnu.org/licenses/>.
# #
__version__ = "2026.10.0.dev0" __version__ = "2026.8.0.dev0"
+1 -1
View File
@@ -76,7 +76,7 @@ class DeviceTokenAuthentication(TokenAuthentication):
except DeviceLastSeen.DoesNotExist: except DeviceLastSeen.DoesNotExist:
# First request from device, create model, ignore result. Use get_or_create to be safe # First request from device, create model, ignore result. Use get_or_create to be safe
# against concurrent create requests # against concurrent create requests
DeviceLastSeen.objects.get_or_create(device=device, defaults={"last_seen": now()}) DeviceLastSeen.objects.get_or_create(device=device, last_seen=now())
else: else:
if now() - last_seen_obj.last_seen < timedelta(seconds=10): if now() - last_seen_obj.last_seen < timedelta(seconds=10):
# We don't need to know the last seen info of a device to more precision than this, # We don't need to know the last seen info of a device to more precision than this,
+1
View File
@@ -155,6 +155,7 @@ class PretixScanNoSyncNoSearchSecurityProfile(AllowListSecurityProfile):
('POST', 'api-v1:upload'), ('POST', 'api-v1:upload'),
('POST', 'api-v1:checkinrpc.redeem'), ('POST', 'api-v1:checkinrpc.redeem'),
('POST', 'api-v1:checkinrpc.annul'), ('POST', 'api-v1:checkinrpc.annul'),
('GET', 'api-v1:checkinrpc.search'),
) )
-4
View File
@@ -101,10 +101,6 @@ class OAuthAccessToken(AbstractAccessToken):
self.expires = now() - timedelta(hours=1) self.expires = now() - timedelta(hours=1)
self.save(update_fields=['expires']) self.save(update_fields=['expires'])
def is_valid(self, scopes=None):
# Can maybe be removed after upgrading django-oauth-toolkit to 3.4.1
return super().is_valid(scopes) and self.application.is_usable(None)
class OAuthRefreshToken(AbstractRefreshToken): class OAuthRefreshToken(AbstractRefreshToken):
application = models.ForeignKey( application = models.ForeignKey(
+3 -12
View File
@@ -35,13 +35,10 @@
import logging import logging
from django.conf import settings from django.conf import settings
from django.core.exceptions import ( from django.core.exceptions import PermissionDenied
PermissionDenied, ValidationError as DjangoValidationError,
)
from django.db import transaction from django.db import transaction
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.html import strip_tags
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from django_countries.serializers import CountryFieldMixin from django_countries.serializers import CountryFieldMixin
from pytz import common_timezones from pytz import common_timezones
@@ -221,6 +218,8 @@ class EventSerializer(SalesChannelMigrationMixin, I18nAwareModelSerializer):
if self.instance is None: if self.instance is None:
raise ValidationError(_('Events cannot be created as \'live\'. Quotas and payment must be added to the ' raise ValidationError(_('Events cannot be created as \'live\'. Quotas and payment must be added to the '
'event before sales can go live.')) 'event before sales can go live.'))
else:
self.instance.clean_live()
return value return value
@cached_property @cached_property
@@ -430,14 +429,6 @@ class EventSerializer(SalesChannelMigrationMixin, I18nAwareModelSerializer):
event.set_active_plugins(plugins) event.set_active_plugins(plugins)
event.save() event.save()
live = validated_data.get('live') or event.live
if live:
event.refresh_from_db()
try:
event.clean_live()
except DjangoValidationError as e:
raise ValidationError({'live': [strip_tags(m) for m in e.messages]})
return event return event
-8
View File
@@ -156,8 +156,6 @@ class ExportFormDataField(serializers.Field):
return JobRunSerializer(exporter=exporter).to_internal_value(data["export_form_data"]) return JobRunSerializer(exporter=exporter).to_internal_value(data["export_form_data"])
else: else:
return data['export_form_data'] return data['export_form_data']
else: # partial PATCH without export_form_data keeps it unchanged
return self.parent.instance.export_form_data
class ScheduledExportSerializer(serializers.ModelSerializer): class ScheduledExportSerializer(serializers.ModelSerializer):
@@ -190,12 +188,6 @@ class ScheduledExportSerializer(serializers.ModelSerializer):
raise ValidationError('Please enter less than 25 recipients.') raise ValidationError('Please enter less than 25 recipients.')
return d return d
def validate(self, attrs):
attrs = super().validate(attrs)
if self.instance and self.instance.pk and 'export_identifier' in attrs and self.instance.export_identifier != attrs['export_identifier']:
raise ValidationError({"export_identifier": "export_identifier cannot be changed for existing exports."})
return attrs
class ScheduledEventExportSerializer(ScheduledExportSerializer): class ScheduledEventExportSerializer(ScheduledExportSerializer):
+1 -9
View File
@@ -37,8 +37,6 @@ from collections import OrderedDict
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from rest_framework import serializers from rest_framework import serializers
from pretix.api.auth.utils import get_session_key_for_api_request
def remove_duplicates_from_list(data): def remove_duplicates_from_list(data):
return list(OrderedDict.fromkeys(data)) return list(OrderedDict.fromkeys(data))
@@ -85,16 +83,10 @@ class UploadedFileField(serializers.Field):
request = self.context.get('request', None) request = self.context.get('request', None)
try: try:
cf = CachedFile.objects.get( cf = CachedFile.objects.get(
session_key=f'api-upload-{str(type(request.user or request.auth))}-{(request.user or request.auth).pk}',
file__isnull=False, file__isnull=False,
pk=data[len("file:"):], pk=data[len("file:"):],
) )
if cf.session_key == "api-upload-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-09, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_request(request):
self.fail('not_found')
except (ValidationError, IndexError): # invalid uuid except (ValidationError, IndexError): # invalid uuid
self.fail('not_found') self.fail('not_found')
except CachedFile.DoesNotExist: except CachedFile.DoesNotExist:
+4 -7
View File
@@ -261,9 +261,7 @@ class ItemAddOnSerializer(serializers.ModelSerializer):
def validate(self, data): def validate(self, data):
data = super().validate(data) data = super().validate(data)
full_data = self.to_internal_value(self.to_representation(self.instance)) if self.instance else {} ItemAddOn.clean_max_min_count(data.get('max_count'), data.get('min_count'))
full_data.update(data)
ItemAddOn.clean_max_min_count(full_data.get('max_count'), full_data.get('min_count'))
return data return data
@@ -378,8 +376,7 @@ class ItemSerializer(SalesChannelMigrationMixin, I18nAwareModelSerializer):
def validate_bundles(self, value): def validate_bundles(self, value):
if not self.instance: if not self.instance:
for b_data in value: for b_data in value:
ItemBundle.clean_count(b_data.get('count', 1)) ItemBundle.clean_itemvar(self.context['event'], b_data['bundled_item'], b_data['bundled_variation'])
ItemBundle.clean_itemvar(self.context['event'], b_data.get('bundled_item'), b_data.get('bundled_variation'))
return value return value
def validate_addons(self, value): def validate_addons(self, value):
@@ -387,8 +384,8 @@ class ItemSerializer(SalesChannelMigrationMixin, I18nAwareModelSerializer):
for addon_data in value: for addon_data in value:
ItemAddOn.clean_categories(self.context['event'], None, self.instance, addon_data['addon_category']) ItemAddOn.clean_categories(self.context['event'], None, self.instance, addon_data['addon_category'])
ItemAddOn.clean_min_count(addon_data.get('min_count', 0)) ItemAddOn.clean_min_count(addon_data.get('min_count', 0))
ItemAddOn.clean_max_count(addon_data.get('max_count', 1)) ItemAddOn.clean_max_count(addon_data.get('max_count', 0))
ItemAddOn.clean_max_min_count(addon_data.get('max_count', 1), addon_data.get('min_count', 0)) ItemAddOn.clean_max_min_count(addon_data.get('max_count', 0), addon_data.get('min_count', 0))
return value return value
def validate_program_times(self, value): def validate_program_times(self, value):
-2
View File
@@ -197,8 +197,6 @@ class ReusableMediaSerializer(I18nAwareModelSerializer):
'linked_giftcard', 'linked_giftcard',
'info', 'info',
'notes', 'notes',
# When adding fields, check if they should be hidden in ReusableMediaViewSet
# for cross-organizer lookups
) )
+7 -28
View File
@@ -41,7 +41,6 @@ from rest_framework.exceptions import ValidationError
from rest_framework.relations import SlugRelatedField from rest_framework.relations import SlugRelatedField
from rest_framework.reverse import reverse from rest_framework.reverse import reverse
from pretix.api.auth.utils import get_session_key_for_api_request
from pretix.api.serializers import CompatDecimalField, CompatibleJSONField from pretix.api.serializers import CompatDecimalField, CompatibleJSONField
from pretix.api.serializers.event import SubEventSerializer from pretix.api.serializers.event import SubEventSerializer
from pretix.api.serializers.forms import form_field_to_serializer_field from pretix.api.serializers.forms import form_field_to_serializer_field
@@ -117,7 +116,6 @@ class TransmissionInfoSerializer(serializers.Serializer):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
for k, v in transmission_type.invoice_address_form_fields.items(): for k, v in transmission_type.invoice_address_form_fields.items():
self.fields[k] = form_field_to_serializer_field(v) self.fields[k] = form_field_to_serializer_field(v)
self.fields[k].required = False # invoice_address_form_fields_required is checked by parent serializer
class InvoiceAddressSerializer(I18nAwareModelSerializer): class InvoiceAddressSerializer(I18nAwareModelSerializer):
@@ -260,21 +258,16 @@ class AnswerSerializer(I18nAwareModelSerializer):
if data['answer'] == 'file:keep': if data['answer'] == 'file:keep':
return data return data
try: try:
ao = self.context["request"].user or self.context["request"].auth
cf = CachedFile.objects.get( cf = CachedFile.objects.get(
session_key=f'api-upload-{str(type(ao))}-{ao.pk}',
file__isnull=False, file__isnull=False,
pk=data['answer'][len("file:"):], pk=data['answer'][len("file:"):],
) )
if cf.session_key == "api-upload-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-09, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_request(self.context["request"]):
raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data['answer']))
except (ValidationError, IndexError): # invalid uuid except (ValidationError, IndexError): # invalid uuid
raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data['answer'])) raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data))
except CachedFile.DoesNotExist: except CachedFile.DoesNotExist:
raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data['answer'])) raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data))
allowed_types = ( allowed_types = (
'image/png', 'image/jpeg', 'image/gif', 'application/pdf' 'image/png', 'image/jpeg', 'image/gif', 'application/pdf'
@@ -1241,9 +1234,6 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
return None return None
if pp not in self.context['event'].get_payment_providers(): if pp not in self.context['event'].get_payment_providers():
raise ValidationError('The given payment provider is not known.') raise ValidationError('The given payment provider is not known.')
if pp == "giftcard":
raise serializers.ValidationError("Cannot create giftcard payment. Use `use_gift_cards` instead")
return pp return pp
def validate_payment_info(self, info): def validate_payment_info(self, info):
@@ -1964,15 +1954,10 @@ class OrderPaymentCreateSerializer(I18nAwareModelSerializer):
model = OrderPayment model = OrderPayment
fields = ('state', 'amount', 'payment_date', 'provider', 'info') fields = ('state', 'amount', 'payment_date', 'provider', 'info')
def validate_provider(self, value):
if value == "giftcard":
raise serializers.ValidationError("Cannot create giftcard payment")
return value
def create(self, validated_data): def create(self, validated_data):
payment = OrderPayment(order=self.context['order'], **validated_data) order = OrderPayment(order=self.context['order'], **validated_data)
payment.save() order.save()
return payment return order
class OrderRefundCreateSerializer(I18nAwareModelSerializer): class OrderRefundCreateSerializer(I18nAwareModelSerializer):
@@ -1984,12 +1969,6 @@ class OrderRefundCreateSerializer(I18nAwareModelSerializer):
model = OrderRefund model = OrderRefund
fields = ('state', 'source', 'amount', 'payment', 'execution_date', 'provider', 'info', 'comment') fields = ('state', 'source', 'amount', 'payment', 'execution_date', 'provider', 'info', 'comment')
def validate_provider(self, value):
if value == "giftcard":
raise serializers.ValidationError("Cannot create giftcard payment")
return value
def create(self, validated_data): def create(self, validated_data):
pid = validated_data.pop('payment', None) pid = validated_data.pop('payment', None)
if pid: if pid:
+10 -88
View File
@@ -28,7 +28,6 @@ from django.db import transaction
from django.db.models import Q from django.db.models import Q
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.translation import gettext, gettext_lazy as _ from django.utils.translation import gettext, gettext_lazy as _
from i18nfield.rest_framework import I18nField
from rest_framework import serializers from rest_framework import serializers
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
@@ -41,7 +40,7 @@ from pretix.api.serializers.settings import SettingsSerializer
from pretix.base.auth import get_auth_backends from pretix.base.auth import get_auth_backends
from pretix.base.i18n import get_language_without_region from pretix.base.i18n import get_language_without_region
from pretix.base.models import ( from pretix.base.models import (
Customer, Device, EventMetaProperty, GiftCard, GiftCardTransaction, Customer, Device, GiftCard, GiftCardAcceptance, GiftCardTransaction,
Membership, MembershipType, OrderPosition, Organizer, ReusableMedium, Membership, MembershipType, OrderPosition, Organizer, ReusableMedium,
SalesChannel, SeatingPlan, Team, TeamAPIToken, TeamInvite, User, SalesChannel, SeatingPlan, Team, TeamAPIToken, TeamInvite, User,
) )
@@ -269,7 +268,15 @@ class GiftCardSerializer(I18nAwareModelSerializer):
data = super().validate(data) data = super().validate(data)
if 'secret' in data: if 'secret' in data:
s = data['secret'] s = data['secret']
qs = self.context["organizer"].accepted_gift_cards.filter(secret=s) qs = GiftCard.objects.filter(
secret=s
).filter(
Q(issuer=self.context["organizer"]) |
Q(issuer__in=GiftCardAcceptance.objects.filter(
acceptor=self.context["organizer"],
active=True,
).values_list('issuer', flat=True))
)
if self.instance: if self.instance:
qs = qs.exclude(pk=self.instance.pk) qs = qs.exclude(pk=self.instance.pk)
if qs.exists(): if qs.exists():
@@ -633,88 +640,3 @@ class OrganizerSettingsSerializer(SettingsSerializer):
) )
# TODO: make sure pub is always correct # TODO: make sure pub is always correct
return 'pub/' + fname return 'pub/' + fname
class MetaPropertyListField(serializers.ListField):
def __init__(self, *args, **kwargs):
kwargs["validators"] = kwargs.pop("validators", [])
def validate_keys_unique(choices):
if not choices:
return
keys = [c.get("key") for c in choices]
if len(set(keys)) < len(keys):
raise ValidationError("The key for each meta property value option must be unique.")
kwargs["validators"].append(
validate_keys_unique
)
super().__init__(*args, **kwargs)
class MetaPropertyDictField(serializers.DictField):
def __init__(self, **kwargs):
self.label_child = kwargs.pop("label_child", I18nField())
super().__init__(**kwargs)
def to_representation(self, value):
# django added unneccessary keys DELETE, ORDER through formsets, filter them here for backwards compat
d = {
"key": value["key"]
}
if "label" in value:
d["label"] = self.label_child.to_representation(value["label"])
return super().to_representation(d)
def to_internal_value(self, data):
if not isinstance(data, dict):
raise ValidationError("Meta property value options must be a dict.")
if not isinstance(data.get("key"), str):
raise ValidationError("Meta property value options must have a key of type string.")
if any(k not in {"key", "label"} for k in data.keys()):
raise ValidationError("Meta property value options may only have a key and optionally a label.")
if "label" in data:
try:
data["label"] = self.label_child.to_internal_value(data["label"])
except ValidationError as e:
raise ValidationError({"label": e.detail})
return super().to_internal_value(data)
class EventMetaPropertiesSerializer(I18nAwareModelSerializer):
choices = MetaPropertyListField(
child=MetaPropertyDictField(
label_child=I18nField()
),
allow_null=True,
)
class Meta:
model = EventMetaProperty
fields = (
'id', 'name', 'default', 'required', 'protected', 'filter_public', 'public_label', 'filter_allowed',
'choices'
)
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)
choices = full_data.get("choices")
default = full_data.get("default")
if choices and default:
choice_keys = [c.get("key") for c in choices]
if default not in choice_keys:
raise ValidationError("You cannot set a default value that is not a valid value.")
if not choices and "choices" in data:
# normalize empty dict to None
data["choices"] = None
return data
-1
View File
@@ -68,7 +68,6 @@ orga_router.register(r'scheduled_exports', exporters.ScheduledOrganizerExportVie
orga_router.register(r'exporters', exporters.OrganizerExportersViewSet, basename='exporters') orga_router.register(r'exporters', exporters.OrganizerExportersViewSet, basename='exporters')
orga_router.register(r'transactions', order.OrganizerTransactionViewSet) orga_router.register(r'transactions', order.OrganizerTransactionViewSet)
orga_router.register(r'orderpositions', order.OrganizerOrderPositionViewSet, basename='orderpositions') orga_router.register(r'orderpositions', order.OrganizerOrderPositionViewSet, basename='orderpositions')
orga_router.register(r'event_meta_properties', organizer.EventMetaPropertiesViewSet)
team_router = routers.DefaultRouter() team_router = routers.DefaultRouter()
team_router.register(r'members', organizer.TeamMemberViewSet) team_router.register(r'members', organizer.TeamMemberViewSet)
+1 -8
View File
@@ -50,7 +50,6 @@ from rest_framework.generics import ListAPIView
from rest_framework.permissions import SAFE_METHODS from rest_framework.permissions import SAFE_METHODS
from rest_framework.response import Response from rest_framework.response import Response
from pretix.api.auth.utils import get_session_key_for_api_auth
from pretix.api.serializers.checkin import ( from pretix.api.serializers.checkin import (
CheckinListSerializer, CheckinRPCAnnulInputSerializer, CheckinListSerializer, CheckinRPCAnnulInputSerializer,
CheckinRPCRedeemInputSerializer, MiniCheckinListSerializer, CheckinRPCRedeemInputSerializer, MiniCheckinListSerializer,
@@ -332,16 +331,10 @@ with scopes_disabled():
def _handle_file_upload(data, user, auth): def _handle_file_upload(data, user, auth):
try: try:
cf = CachedFile.objects.get( cf = CachedFile.objects.get(
session_key=f'api-upload-{str(type(user or auth))}-{(user or auth).pk}',
file__isnull=False, file__isnull=False,
pk=data[len("file:"):], pk=data[len("file:"):],
) )
if cf.session_key == "api-upload-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-09, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_auth(user, auth):
raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data))
except (ValidationError, BaseValidationError, IndexError): # invalid uuid except (ValidationError, BaseValidationError, IndexError): # invalid uuid
raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data)) raise ValidationError('The submitted file ID "{fid}" was not found.'.format(fid=data))
except CachedFile.DoesNotExist: except CachedFile.DoesNotExist:
+34 -48
View File
@@ -21,6 +21,7 @@
# #
from datetime import timedelta from datetime import timedelta
from celery.result import AsyncResult
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from django.http import Http404 from django.http import Http404
@@ -48,7 +49,6 @@ from pretix.base.services.export import (
ExportError, export, init_event_exporters, init_organizer_exporters, ExportError, export, init_event_exporters, init_organizer_exporters,
multiexport, multiexport,
) )
from pretix.helpers.celery import get_task_result
from pretix.helpers.http import ChunkBasedFileResponse from pretix.helpers.http import ChunkBasedFileResponse
@@ -75,7 +75,7 @@ class ExportersMixin:
@action(detail=True, methods=['GET'], url_name='download', url_path='download/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)') @action(detail=True, methods=['GET'], url_name='download', url_path='download/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)')
def download(self, *args, **kwargs): def download(self, *args, **kwargs):
cf = get_object_or_404(CachedFile, id=kwargs['cfid'], web_download=True) cf = get_object_or_404(CachedFile, id=kwargs['cfid'])
if not cf.allowed_for_session(self.request, "exporters-api"): if not cf.allowed_for_session(self.request, "exporters-api"):
return Response( return Response(
{'status': 'failed', 'message': 'Unknown file ID or export failed'}, {'status': 'failed', 'message': 'Unknown file ID or export failed'},
@@ -91,7 +91,7 @@ class ExportersMixin:
status=status.HTTP_410_GONE status=status.HTTP_410_GONE
) )
res = get_task_result(kwargs['asyncid'], task_name=self.task) res = AsyncResult(kwargs['asyncid'])
if res.failed(): if res.failed():
if isinstance(res.info, dict) and res.info['exc_type'] == 'ExportError': if isinstance(res.info, dict) and res.info['exc_type'] == 'ExportError':
msg = res.info['exc_message'] msg = res.info['exc_message']
@@ -139,7 +139,6 @@ class ExportersMixin:
class EventExportersViewSet(ExportersMixin, viewsets.ViewSet): class EventExportersViewSet(ExportersMixin, viewsets.ViewSet):
permission = None permission = None
task = export
@cached_property @cached_property
def exporters(self): def exporters(self):
@@ -174,7 +173,6 @@ class EventExportersViewSet(ExportersMixin, viewsets.ViewSet):
class OrganizerExportersViewSet(ExportersMixin, viewsets.ViewSet): class OrganizerExportersViewSet(ExportersMixin, viewsets.ViewSet):
permission = None permission = None
task = multiexport
@cached_property @cached_property
def exporters(self): def exporters(self):
@@ -274,8 +272,6 @@ class ScheduledEventExportViewSet(ScheduledExportersViewSet):
perm_holder = self.request.auth if isinstance(self.request.auth, (TeamAPIToken, Device)) else self.request.user perm_holder = self.request.auth if isinstance(self.request.auth, (TeamAPIToken, Device)) else self.request.user
if not perm_holder.has_event_permission(self.request.organizer, self.request.event, exporter.get_required_event_permission()): if not perm_holder.has_event_permission(self.request.organizer, self.request.event, exporter.get_required_event_permission()):
raise PermissionDenied("No permission to edit exports you could not run.") raise PermissionDenied("No permission to edit exports you could not run.")
# An additional check for the new config, such as on organizer level, is not necessary. Since the event is
# fixed and the export_identifier is read-only, the update cannot include a meaningful change of permissions.
serializer.save(event=self.request.event) serializer.save(event=self.request.event)
serializer.instance.compute_next_run() serializer.instance.compute_next_run()
@@ -348,41 +344,6 @@ class ScheduledOrganizerExportViewSet(ScheduledExportersViewSet):
)) ))
return {e.identifier: e for e in exporters} return {e.identifier: e for e in exporters}
def _check_permission_for_export(self, identifier, form_data):
perm_holder = (
self.request.auth if isinstance(self.request.auth, (Device, TeamAPIToken)) else self.request.user
)
exporter = self.exporters.get(identifier)
if not exporter:
raise PermissionDenied("No access to exporter.")
if isinstance(exporter, OrganizerLevelExportMixin):
if not perm_holder.has_organizer_permission(
self.request.organizer, exporter.get_required_organizer_permission(), request=self.request,
):
raise PermissionDenied("No permission to edit exports you could not run.")
else:
if form_data.get("all_events", False):
if isinstance(self.request.auth, Device):
if not self.request.auth.all_events:
raise PermissionDenied("No permission to edit exports you could not run.")
elif isinstance(self.request.auth, TeamAPIToken):
if not self.request.auth.team.all_events:
raise PermissionDenied("No permission to edit exports you could not run.")
elif self.request.user.is_authenticated:
if not self.request.user.teams.filter(
TeamQuerySet.event_permission_q(exporter.get_required_event_permission()),
organizer=self.request.organizer,
all_events=True,
).exists():
raise PermissionDenied("No permission to edit exports you could not run.")
else:
events_selected = form_data.get("events", [])
events_permission = set(perm_holder.get_events_with_permission(
exporter.get_required_event_permission(), request=self.request
).values_list("pk", flat=True))
if not all(e in events_permission for e in events_selected):
raise PermissionDenied("No permission to edit exports you could not run.")
@transaction.atomic() @transaction.atomic()
def perform_update(self, serializer): def perform_update(self, serializer):
if not self.request.user.is_authenticated or self.request.user != serializer.instance.owner: if not self.request.user.is_authenticated or self.request.user != serializer.instance.owner:
@@ -390,12 +351,37 @@ class ScheduledOrganizerExportViewSet(ScheduledExportersViewSet):
# user B has settings permission (= they can see the export configuration), but not enough permission # user B has settings permission (= they can see the export configuration), but not enough permission
# to run the export themselves. Without this check, user B could modify the export and add themselves # to run the export themselves. Without this check, user B could modify the export and add themselves
# as a recipient. Thereby, user B would gain access to data they can't have. # as a recipient. Thereby, user B would gain access to data they can't have.
self._check_permission_for_export(serializer.instance.export_identifier, serializer.instance.export_form_data) exporter = self.exporters.get(serializer.instance.export_identifier)
# After we checked that the API user can work with the original export, we also need to check that they can if not exporter:
# work with the changed export, otherwise they could change e.g. from "some events" to "all events" and add raise PermissionDenied("No access to exporter.")
# themselves as a recipient. perm_holder = (self.request.auth if isinstance(self.request.auth, (Device, TeamAPIToken))
if serializer.validated_data.get('export_form_data') is not None: else self.request.user)
self._check_permission_for_export(serializer.instance.export_identifier, serializer.validated_data['export_form_data']) if isinstance(exporter, OrganizerLevelExportMixin):
if not perm_holder.has_organizer_permission(
self.request.organizer, exporter.get_required_organizer_permission(), request=self.request,
):
raise PermissionDenied("No permission to edit exports you could not run.")
else:
if serializer.instance.export_form_data.get("all_events", False):
if isinstance(self.request.auth, Device):
if not self.request.auth.all_events:
raise PermissionDenied("No permission to edit exports you could not run.")
elif isinstance(self.request.auth, TeamAPIToken):
if not self.request.auth.team.all_events:
raise PermissionDenied("No permission to edit exports you could not run.")
elif self.request.user.is_authenticated:
if not self.request.user.teams.filter(
TeamQuerySet.event_permission_q(exporter.get_required_event_permission()),
all_events=True,
).exists():
raise PermissionDenied("No permission to edit exports you could not run.")
else:
events_selected = serializer.instance.export_form_data.get("events", [])
events_permission = set(perm_holder.get_events_with_permission(
exporter.get_required_event_permission(), request=self.request
).values_list("pk", flat=True))
if not all(e in events_permission for e in events_selected):
raise PermissionDenied("No permission to edit exports you could not run.")
serializer.save(organizer=self.request.organizer) serializer.save(organizer=self.request.organizer)
serializer.instance.compute_next_run() serializer.instance.compute_next_run()
+4 -13
View File
@@ -39,7 +39,7 @@ from pretix.api.serializers.media import (
) )
from pretix.base.media import MEDIA_TYPES from pretix.base.media import MEDIA_TYPES
from pretix.base.models import ( from pretix.base.models import (
Checkin, GiftCardAcceptance, GiftCardTransaction, OrderPosition, Checkin, GiftCard, GiftCardAcceptance, GiftCardTransaction, OrderPosition,
ReusableMedium, ReusableMedium,
) )
from pretix.base.models.orders import PrintLog from pretix.base.models.orders import PrintLog
@@ -88,7 +88,7 @@ class ReusableMediaViewSet(viewsets.ModelViewSet):
), ),
Prefetch( Prefetch(
'linked_giftcard', 'linked_giftcard',
queryset=self.request.organizer.accepted_gift_cards.annotate( queryset=GiftCard.objects.annotate(
cached_value=Coalesce(Subquery(s), Decimal('0.00')) cached_value=Coalesce(Subquery(s), Decimal('0.00'))
) )
) )
@@ -183,18 +183,9 @@ class ReusableMediaViewSet(viewsets.ModelViewSet):
type=s.validated_data["type"], type=s.validated_data["type"],
identifier=s.validated_data["identifier"], identifier=s.validated_data["identifier"],
) )
m.customer = None # not relevant for cross-organizer
s = self.get_serializer(m) s = self.get_serializer(m)
data = s.data return Response({"result": s.data})
# Remove fields that are not relevant for cross-organizer usage
data["customer"] = None
data["linked_orderposition"] = None
data["linked_orderpositions"] = []
data["info"] = {}
data["notes"] = None
data["claim_token"] = None
data["label"] = None
return Response({"result": data})
except ReusableMedium.DoesNotExist: except ReusableMedium.DoesNotExist:
mt = MEDIA_TYPES.get(s.validated_data["type"]) mt = MEDIA_TYPES.get(s.validated_data["type"])
if mt: if mt:
+1 -1
View File
@@ -1683,7 +1683,7 @@ class PaymentViewSet(CreateModelMixin, viewsets.ReadOnlyModelViewSet):
@action(detail=True, methods=['POST']) @action(detail=True, methods=['POST'])
def confirm(self, request, **kwargs): def confirm(self, request, **kwargs):
payment = self.get_object() payment = self.get_object()
force = request.data.get('force', False) if request.data else False force = request.data.get('force', False)
send_mail = request.data.get('send_email', True) if request.data else True send_mail = request.data.get('send_email', True) if request.data else True
if payment.state not in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED): if payment.state not in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED):
+4 -51
View File
@@ -44,16 +44,15 @@ from pretix.api.models import OAuthAccessToken
from pretix.api.pagination import TotalOrderingFilter from pretix.api.pagination import TotalOrderingFilter
from pretix.api.serializers.organizer import ( from pretix.api.serializers.organizer import (
CustomerCreateSerializer, CustomerSerializer, DeviceSerializer, CustomerCreateSerializer, CustomerSerializer, DeviceSerializer,
EventMetaPropertiesSerializer, GiftCardSerializer, GiftCardSerializer, GiftCardTransactionSerializer, MembershipSerializer,
GiftCardTransactionSerializer, MembershipSerializer,
MembershipTypeSerializer, OrganizerSerializer, OrganizerSettingsSerializer, MembershipTypeSerializer, OrganizerSerializer, OrganizerSettingsSerializer,
SalesChannelSerializer, SeatingPlanSerializer, TeamAPITokenSerializer, SalesChannelSerializer, SeatingPlanSerializer, TeamAPITokenSerializer,
TeamInviteSerializer, TeamMemberSerializer, TeamSerializer, TeamInviteSerializer, TeamMemberSerializer, TeamSerializer,
) )
from pretix.base.models import ( from pretix.base.models import (
Customer, Device, Event, EventMetaProperty, GiftCard, GiftCardTransaction, Customer, Device, Event, GiftCard, GiftCardTransaction, LogEntry,
LogEntry, Membership, MembershipType, Organizer, SalesChannel, SeatingPlan, Membership, MembershipType, Organizer, SalesChannel, SeatingPlan, Team,
Team, TeamAPIToken, TeamInvite, User, TeamAPIToken, TeamInvite, User,
) )
from pretix.base.plugins import ( from pretix.base.plugins import (
PLUGIN_LEVEL_EVENT, PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID, PLUGIN_LEVEL_EVENT, PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID,
@@ -847,49 +846,3 @@ class SalesChannelViewSet(viewsets.ModelViewSet):
data={'id': instance.pk} data={'id': instance.pk}
) )
instance.delete() instance.delete()
class EventMetaPropertiesViewSet(viewsets.ModelViewSet):
serializer_class = EventMetaPropertiesSerializer
queryset = EventMetaProperty.objects.none()
write_permission = 'organizer.settings.general:write'
def get_queryset(self):
return self.request.organizer.meta_properties.all()
def get_serializer_context(self):
ctx = super().get_serializer_context()
ctx['organizer'] = self.request.organizer
return ctx
@transaction.atomic()
def perform_destroy(self, instance):
instance.log_action(
'pretix.property.deleted',
user=self.request.user,
auth=self.request.auth,
data={'id': instance.pk}
)
instance.delete()
@transaction.atomic()
def perform_create(self, serializer):
inst = serializer.save(organizer_id=self.request.organizer.pk)
serializer.instance.log_action(
'pretix.property.created',
user=self.request.user,
auth=self.request.auth,
data=self.request.data,
)
return inst
@transaction.atomic()
def perform_update(self, serializer):
inst = serializer.save(organizer_id=self.request.organizer.pk)
serializer.instance.log_action(
'pretix.property.changed',
user=self.request.user,
auth=self.request.auth,
data=self.request.data,
)
return inst
+18 -41
View File
@@ -21,6 +21,7 @@
# #
from datetime import timedelta from datetime import timedelta
from celery.result import AsyncResult
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
@@ -32,14 +33,12 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.reverse import reverse from rest_framework.reverse import reverse
from pretix.api.auth.utils import get_session_key_for_api_request
from pretix.api.serializers.shredders import ( from pretix.api.serializers.shredders import (
JobRunSerializer, ShredderSerializer, JobRunSerializer, ShredderSerializer,
) )
from pretix.base.models import CachedFile from pretix.base.models import CachedFile
from pretix.base.services.shredder import export, shred from pretix.base.services.shredder import export, shred
from pretix.base.shredder import shred_constraints from pretix.base.shredder import shred_constraints
from pretix.helpers.celery import get_task_result
from pretix.helpers.http import ChunkBasedFileResponse from pretix.helpers.http import ChunkBasedFileResponse
@@ -69,14 +68,8 @@ class ShreddersMixin:
cf = get_object_or_404( cf = get_object_or_404(
CachedFile, CachedFile,
id=kwargs['cfid'], id=kwargs['cfid'],
session_key=f'api-shredder-{str(type(self.request.user or self.request.auth))}-{(self.request.user or self.request.auth).pk}'
) )
if cf.session_key == "api-shredder-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-10, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_request(self.request, prefix='api-shredder'):
raise Http404()
if cf.file: if cf.file:
resp = ChunkBasedFileResponse(cf.file.file, content_type=cf.type) resp = ChunkBasedFileResponse(cf.file.file, content_type=cf.type)
resp['Content-Disposition'] = 'attachment; filename="{}"'.format(cf.filename).encode("ascii", "ignore") resp['Content-Disposition'] = 'attachment; filename="{}"'.format(cf.filename).encode("ascii", "ignore")
@@ -87,7 +80,7 @@ class ShreddersMixin:
status=status.HTTP_410_GONE status=status.HTTP_410_GONE
) )
res = get_task_result(kwargs['asyncid'], task_name=export) res = AsyncResult(kwargs['asyncid'])
if res.failed(): if res.failed():
if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'): if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'):
msg = res.info['exc_message'] msg = res.info['exc_message']
@@ -108,7 +101,7 @@ class ShreddersMixin:
@action(detail=False, methods=['GET'], url_name='status', url_path='status/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)') @action(detail=False, methods=['GET'], url_name='status', url_path='status/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)')
def status(self, *args, **kwargs): def status(self, *args, **kwargs):
if settings.HAS_CELERY: if settings.HAS_CELERY:
res = get_task_result(kwargs['asyncid'], task_name=shred) res = AsyncResult(kwargs['asyncid'])
if res.failed(): if res.failed():
if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'): if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'):
msg = res.info['exc_message'] msg = res.info['exc_message']
@@ -125,53 +118,37 @@ class ShreddersMixin:
) )
try: try:
cf = CachedFile.objects.get( CachedFile.objects.get(
id=kwargs['cfid'], id=kwargs['cfid'],
session_key=f'api-shredder-{str(type(self.request.user or self.request.auth))}-{(self.request.user or self.request.auth).pk}'
) )
if cf.session_key == "api-shredder-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-10, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_request(self.request, prefix='api-shredder'):
raise CachedFile.DoesNotExist()
except CachedFile.DoesNotExist: except CachedFile.DoesNotExist:
return Response( return Response(
{'status': 'gone', 'message': 'May have succeeded or timed out'}, {'status': 'gone', 'message': 'May have succeeded or timed out'},
status=status.HTTP_410_GONE status=status.HTTP_410_GONE
) )
if settings.HAS_CELERY: return Response(
return Response( {
{ 'status': 'running' if res.state in ('PROGRESS', 'STARTED', 'SUCCESS') else 'waiting',
'status': 'running' if res.state in ('PROGRESS', 'STARTED', 'SUCCESS') else 'waiting', },
}, status=status.HTTP_409_CONFLICT
status=status.HTTP_409_CONFLICT )
)
else:
# This can't happen for clients who follow the api spec. They would need have to constructed the url themselves
# from a valid shredder cached file, e.g. by modifying the URL retured by `export`.
raise Http404()
@action(detail=False, methods=['POST'], url_name='shred', url_path='shred/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)') @action(detail=False, methods=['POST'], url_name='shred', url_path='shred/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)')
def shred(self, *args, **kwargs): def shred(self, *args, **kwargs):
cf = get_object_or_404( cf = get_object_or_404(
CachedFile, CachedFile,
id=kwargs['cfid'], id=kwargs['cfid'],
session_key=f'api-shredder-{str(type(self.request.user or self.request.auth))}-{(self.request.user or self.request.auth).pk}'
) )
if cf.session_key == "api-shredder-<class 'django.contrib.auth.models.AnonymousUser'>-None":
# OK, backwards-compatibility of a security bug fixed 2026-10, delete this at some point, but should
# also be harmless because all files with this key are expired one day after deployment of this fix
# and no new files with this key are created
pass
elif cf.session_key != get_session_key_for_api_request(self.request, prefix='api-shredder'):
raise Http404()
if cf.file: if cf.file:
async_result = self.do_shred(cf) async_result = self.do_shred(cf)
url_kwargs = self.kwargs | { url_kwargs = {
'asyncid': str(async_result.id), 'asyncid': str(async_result.id),
'cfid': str(cf.id), 'cfid': str(cf.id),
} }
url_kwargs.update(self.kwargs)
return Response({ return Response({
'status': reverse('api-v1:shredders-status', kwargs=url_kwargs, request=self.request), 'status': reverse('api-v1:shredders-status', kwargs=url_kwargs, request=self.request),
}, status=status.HTTP_202_ACCEPTED) }, status=status.HTTP_202_ACCEPTED)
@@ -181,7 +158,7 @@ class ShreddersMixin:
status=status.HTTP_410_GONE status=status.HTTP_410_GONE
) )
res = get_task_result(kwargs['asyncid'], task_name=export) res = AsyncResult(kwargs['asyncid'])
if res.failed(): if res.failed():
if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'): if isinstance(res.info, dict) and res.info['exc_type'] in ('ShredError', 'ExportError'):
msg = res.info['exc_message'] msg = res.info['exc_message']
@@ -207,7 +184,7 @@ class ShreddersMixin:
cf = CachedFile(web_download=False) cf = CachedFile(web_download=False)
cf.date = now() cf.date = now()
cf.expires = now() + timedelta(hours=2) cf.expires = now() + timedelta(hours=2)
cf.session_key = get_session_key_for_api_request(self.request, prefix='api-shredder') cf.session_key = f'api-shredder-{str(type(self.request.user or self.request.auth))}-{(self.request.user or self.request.auth).pk}'
cf.save() cf.save()
d = serializer.data d = serializer.data
for k, v in d.items(): for k, v in d.items():
@@ -247,7 +224,7 @@ class EventShreddersViewSet(ShreddersMixin, viewsets.ViewSet):
return export.apply_async(args=( return export.apply_async(args=(
self.request.event.id, self.request.event.id,
list(shredders), list(shredders),
get_session_key_for_api_request(self.request, prefix='api-shredder'), f'api-shredder-{str(type(self.request.user or self.request.auth))}-{(self.request.user or self.request.auth).pk}',
str(cf.pk) str(cf.pk)
)) ))
+1 -2
View File
@@ -33,7 +33,6 @@ from rest_framework.views import APIView
from pretix.api.auth.device import DeviceTokenAuthentication from pretix.api.auth.device import DeviceTokenAuthentication
from pretix.api.auth.permission import AnyAuthenticatedClientPermission from pretix.api.auth.permission import AnyAuthenticatedClientPermission
from pretix.api.auth.token import TeamTokenAuthentication from pretix.api.auth.token import TeamTokenAuthentication
from pretix.api.auth.utils import get_session_key_for_api_request
from pretix.base.models import CachedFile from pretix.base.models import CachedFile
from pretix.helpers.images import ( from pretix.helpers.images import (
IMAGE_TYPES, validate_uploaded_file_for_valid_image, IMAGE_TYPES, validate_uploaded_file_for_valid_image,
@@ -79,7 +78,7 @@ class UploadView(APIView):
web_download=False, web_download=False,
filename=file_obj.name, filename=file_obj.name,
type=content_type, type=content_type,
session_key=get_session_key_for_api_request(request) session_key=f'api-upload-{str(type(request.user or request.auth))}-{(request.user or request.auth).pk}'
) )
cf.file.save(file_obj.name, file_obj) cf.file.save(file_obj.name, file_obj)
cf.save() cf.save()
-4
View File
@@ -40,7 +40,6 @@ with scopes_disabled():
class VoucherFilter(FilterSet): class VoucherFilter(FilterSet):
active = BooleanFilter(method='filter_active') active = BooleanFilter(method='filter_active')
code = CharFilter(lookup_expr='iexact') code = CharFilter(lookup_expr='iexact')
search = CharFilter(method='search_qs')
class Meta: class Meta:
model = Voucher model = Voucher
@@ -55,9 +54,6 @@ with scopes_disabled():
return queryset.filter(Q(redeemed__gte=F('max_usages')) | return queryset.filter(Q(redeemed__gte=F('max_usages')) |
(Q(valid_until__isnull=False) & Q(valid_until__lte=now()))) (Q(valid_until__isnull=False) & Q(valid_until__lte=now())))
def search_qs(self, qs, name, value):
return qs.filter(Q(code__icontains=value) | Q(tag__icontains=value) | Q(comment__icontains=value))
class VoucherViewSet(viewsets.ModelViewSet): class VoucherViewSet(viewsets.ModelViewSet):
serializer_class = VoucherSerializer serializer_class = VoucherSerializer
+2 -5
View File
@@ -239,9 +239,8 @@ def oidc_validate_authorization(provider, code, redirect_uri, pkce_code_verifier
) )
) )
if 'email_verified' in userinfo and userinfo['email_verified'] not in (True, 1, "1", "True", "true", "TRUE"): if 'email_verified' in userinfo and not userinfo['email_verified']:
# Documented criteria for using a provider with pretix: # todo: how universal is this, do we need to make this configurable?
# "The SSO provider only allows verified accounts to log in or the SSO provider sends the claim email_verified. "
raise ValidationError(_('The email address on this account is not yet verified. Please first confirm the ' raise ValidationError(_('The email address on this account is not yet verified. Please first confirm the '
'email address in your customer account.')) 'email address in your customer account.'))
@@ -264,8 +263,6 @@ def oidc_validate_authorization(provider, code, redirect_uri, pkce_code_verifier
) )
) )
profile['oidc_claims'] = userinfo
return profile return profile
+6 -10
View File
@@ -27,9 +27,8 @@ from datetime import timedelta
from functools import cached_property from functools import cached_property
from typing import List, Optional, Protocol from typing import List, Optional, Protocol
from django.conf import settings import sentry_sdk
from django.db import DatabaseError, transaction from django.db import DatabaseError, transaction
from django.utils.functional import classproperty
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@@ -102,8 +101,9 @@ class OutboundSyncProvider:
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
self.close() self.close()
@classproperty @classmethod
def display_name(cls): # noqa: N805 @property
def display_name(cls):
return str(cls.identifier) return str(cls.identifier)
@classmethod @classmethod
@@ -236,9 +236,7 @@ class OutboundSyncProvider:
# model changes saved by set_sync_error / clear_in_flight calls below # model changes saved by set_sync_error / clear_in_flight calls below
if sq.failed_attempts >= self.max_attempts: if sq.failed_attempts >= self.max_attempts:
logger.exception('Failed to sync order (max attempts exceeded)') logger.exception('Failed to sync order (max attempts exceeded)')
if settings.SENTRY_ENABLED: sentry_sdk.capture_exception(e)
import sentry_sdk
sentry_sdk.capture_exception(e)
sq.set_sync_error("exceeded", e.messages, e.full_message) sq.set_sync_error("exceeded", e.messages, e.full_message)
else: else:
logger.info( logger.info(
@@ -249,9 +247,7 @@ class OutboundSyncProvider:
sq.clear_in_flight() sq.clear_in_flight()
except Exception as e: except Exception as e:
logger.exception('Failed to sync order (unhandled exception)') logger.exception('Failed to sync order (unhandled exception)')
if settings.SENTRY_ENABLED: sentry_sdk.capture_exception(e)
import sentry_sdk
sentry_sdk.capture_exception(e)
sq.set_sync_error("internal", [], str(e)) sq.set_sync_error("internal", [], str(e))
@cached_property @cached_property
+1 -5
View File
@@ -160,11 +160,7 @@ class CustomerListExporter(OrganizerLevelExportMixin, MultiSheetListExporter):
] ]
if name_scheme and len(name_scheme['fields']) > 1: if name_scheme and len(name_scheme['fields']) > 1:
for k, label, w in name_scheme['fields']: for k, label, w in name_scheme['fields']:
row.append( row.append(obj.attendee_name_parts.get(k, ''))
obj.attendee_name_parts.get(k, '')
if obj.attendee_name_parts
else ''
)
yield row yield row
def get_filename(self): def get_filename(self):
+4 -27
View File
@@ -54,7 +54,6 @@ from ...control.forms.filter import get_all_payment_providers
from ...helpers import GroupConcat from ...helpers import GroupConcat
from ...helpers.iter import chunked_iterable from ...helpers.iter import chunked_iterable
from ..exporter import BaseExporter, MultiSheetListExporter from ..exporter import BaseExporter, MultiSheetListExporter
from ..invoicing.transmission import get_transmission_types
from ..services.export import ExportError from ..services.export import ExportError
from ..services.invoices import invoice_pdf_task from ..services.invoices import invoice_pdf_task
from ..signals import ( from ..signals import (
@@ -198,7 +197,7 @@ class InvoiceDataExporter(InvoiceExporterMixin, MultiSheetListExporter):
def iterate_sheet(self, form_data, sheet): def iterate_sheet(self, form_data, sheet):
_ = gettext _ = gettext
if sheet == 'invoices': if sheet == 'invoices':
headers = [ yield [
_('Invoice number'), _('Invoice number'),
_('Date'), _('Date'),
_('Order code'), _('Order code'),
@@ -231,18 +230,8 @@ class InvoiceDataExporter(InvoiceExporterMixin, MultiSheetListExporter):
_('Total value (without taxes)'), _('Total value (without taxes)'),
_('Payment matching IDs'), _('Payment matching IDs'),
_('Payment providers'), _('Payment providers'),
_('Transmission type'),
_('Transmission status'),
_('Transmission date'),
] ]
transmission_types = get_transmission_types()
for tt in transmission_types:
for c in tt.describe_info_columns():
headers.append(str(tt.verbose_name) + ': ' + str(c))
yield headers
p_providers = OrderPayment.objects.filter( p_providers = OrderPayment.objects.filter(
order=OuterRef('order'), order=OuterRef('order'),
state__in=(OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED, state__in=(OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED,
@@ -253,7 +242,7 @@ class InvoiceDataExporter(InvoiceExporterMixin, MultiSheetListExporter):
'm' 'm'
).order_by() ).order_by()
base_qs = self.invoices_queryset(form_data) base_qs = self.invoices_queryset(form_data)\
qs = base_qs.select_related( qs = base_qs.select_related(
'order', 'refers' 'order', 'refers'
@@ -291,7 +280,7 @@ class InvoiceDataExporter(InvoiceExporterMixin, MultiSheetListExporter):
if mid: if mid:
pmis.append(mid) pmis.append(mid)
pmi = '\n'.join(pmis) pmi = '\n'.join(pmis)
line = [ yield [
i.full_invoice_no, i.full_invoice_no,
date_format(i.date, "SHORT_DATE_FORMAT"), date_format(i.date, "SHORT_DATE_FORMAT"),
i.order.code, i.order.code,
@@ -326,20 +315,8 @@ class InvoiceDataExporter(InvoiceExporterMixin, MultiSheetListExporter):
', '.join([ ', '.join([
str(self.providers.get(p, p)) for p in sorted(set((i.payment_providers or '').split(','))) str(self.providers.get(p, p)) for p in sorted(set((i.payment_providers or '').split(',')))
if p and p != 'free' if p and p != 'free'
]), ])
i.transmission_type_instance.verbose_name,
i.get_transmission_status_display(),
date_format(i.transmission_date, "SHORT_DATETIME_FORMAT") if i.transmission_date else "",
] ]
for tt in transmission_types:
if tt.identifier == i.transmission_type:
described = dict(tt.describe_info(i.invoice_to_transmission_info, i.invoice_to_country, i.invoice_to_is_business))
for c in tt.describe_info_columns():
line.append(described.get(c, ""))
else:
for c in tt.describe_info_columns():
line.append("")
yield line
elif sheet == 'lines': elif sheet == 'lines':
yield [ yield [
_('Invoice number'), _('Invoice number'),
+5 -6
View File
@@ -55,10 +55,9 @@ from openpyxl.comments import Comment
from openpyxl.styles import Font, PatternFill from openpyxl.styles import Font, PatternFill
from pretix.base.models import ( from pretix.base.models import (
Checkin, GiftCardTransaction, Invoice, InvoiceAddress, Order, Checkin, GiftCard, GiftCardTransaction, Invoice, InvoiceAddress, Order,
OrderPosition, Question, OrderPosition, Question,
) )
from pretix.base.models.giftcards import GiftCard
from pretix.base.models.orders import ( from pretix.base.models.orders import (
OrderFee, OrderPayment, OrderRefund, Transaction, OrderFee, OrderPayment, OrderRefund, Transaction,
) )
@@ -1327,12 +1326,12 @@ class GiftcardRedemptionListExporter(ListExporter):
order__event__in=self.events, order__event__in=self.events,
provider='giftcard', provider='giftcard',
state__in=(OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED), state__in=(OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED),
).order_by('created').select_related("order__event__organizer") ).order_by('created')
refunds = OrderRefund.objects.filter( refunds = OrderRefund.objects.filter(
order__event__in=self.events, order__event__in=self.events,
provider='giftcard', provider='giftcard',
state=OrderRefund.REFUND_STATE_DONE state=OrderRefund.REFUND_STATE_DONE
).order_by('created').select_related("order__event__organizer") ).order_by('created')
objs = sorted(list(payments) + list(refunds), key=lambda o: (o.order.code, o.created)) objs = sorted(list(payments) + list(refunds), key=lambda o: (o.order.code, o.created))
@@ -1349,9 +1348,9 @@ class GiftcardRedemptionListExporter(ListExporter):
obj.order.code, obj.order.code,
obj.full_id, obj.full_id,
obj.created.astimezone(tz).date().strftime('%Y-%m-%d'), obj.created.astimezone(tz).date().strftime('%Y-%m-%d'),
gc.secret if gc.accepted_by(obj.order.event.organizer) else '?', gc.secret,
obj.amount * (-1 if isinstance(obj, OrderRefund) else 1), obj.amount * (-1 if isinstance(obj, OrderRefund) else 1),
gc.issuer.slug gc.issuer
] ]
yield row yield row
+17 -30
View File
@@ -350,22 +350,16 @@ class WrappedPhonePrefixSelect(Select):
return super().render(name, value or self.initial, *args, **kwargs) return super().render(name, value or self.initial, *args, **kwargs)
def get_context(self, name, value, attrs): def get_context(self, name, value, attrs):
# self.choices is lazy evaluated, needs to be realized to be modifiable if value and self.choices[1][0] != value:
choices = list(self.choices) matching_choices = len([1 for p, c in self.choices if p == value])
if value and choices[1][0] != value:
matching_choices = len([1 for p, c in choices if p == value])
if matching_choices > 1: if matching_choices > 1:
# Some countries share a phone prefix, for example +1 is used all over the Americas. # Some countries share a phone prefix, for example +1 is used all over the Americas.
# This causes a UX problem: If the default value or the existing data is +12125552368, # This causes a UX problem: If the default value or the existing data is +12125552368,
# the widget will just show the first <option> entry with value="+1" as selected, # the widget will just show the first <option> entry with value="+1" as selected,
# which alphabetically is America Samoa, although most numbers statistically are from # which alphabetically is America Samoa, although most numbers statistically are from
# the US. As a workaround, we detect this case and add an additional choice value with # the US. As a workaround, we detect this case and add an aditional choice value with
# just <option value="+1">+1</option> without an explicit country. # just <option value="+1">+1</option> without an explicit country.
self.choices = [ self.choices.insert(1, (value, value))
choices[0],
(value, value),
*choices[1:],
]
context = super().get_context(name, value, attrs) context = super().get_context(name, value, attrs)
return context return context
@@ -600,16 +594,12 @@ class PortraitImageField(SizeValidationMixin, ExtValidationMixin, forms.FileFiel
image = ImageOps.exif_transpose(image) image = ImageOps.exif_transpose(image)
if f._cropdata: if f._cropdata:
left = int(f._cropdata.get('x', 0)) image = image.crop((
top = int(f._cropdata.get('y', 0)) f._cropdata.get('x', 0),
right = left + int(f._cropdata.get('width', image.width)) f._cropdata.get('y', 0),
bottom = top + int(f._cropdata.get('height', image.height)) f._cropdata.get('x', 0) + f._cropdata.get('width', image.width),
if left >= image.width or top >= image.height or right > image.width or bottom > image.height: f._cropdata.get('y', 0) + f._cropdata.get('height', image.height),
raise ValidationError( ))
self.error_messages['max_dimension'],
code='max_dimension',
)
image = image.crop((left, top, right, bottom))
with BytesIO() as output: with BytesIO() as output:
# This might use a lot of memory, but temporary files are not a good option since # This might use a lot of memory, but temporary files are not a good option since
# we don't control the cleanup # we don't control the cleanup
@@ -909,7 +899,7 @@ class BaseQuestionsForm(forms.Form):
field.widget.attrs['data-question-dependency-values'] = escapejson_attr(json.dumps(q.dependency_values)) field.widget.attrs['data-question-dependency-values'] = escapejson_attr(json.dumps(q.dependency_values))
if q.type != 'M': if q.type != 'M':
field.widget.attrs['required'] = q.required and not self.all_optional field.widget.attrs['required'] = q.required and not self.all_optional
field._required = q.required and not self.all_optional field._required = q.required and not self.all_optional
field.required = False field.required = False
return field return field
@@ -1206,9 +1196,8 @@ class TicketLevelQuestionsForm(BaseQuestionsForm):
return field return field
def clean(self): def clean(self):
from pretix.base.addressvalidation import ( # local import to prevent impact on startup time from pretix.base.addressvalidation import \
validate_address, validate_address # local import to prevent impact on startup time
)
d = super().clean() d = super().clean()
@@ -1449,9 +1438,8 @@ class BaseInvoiceAddressForm(forms.ModelForm):
self.fields['transmission_type'].widget.attrs['data-trigger-address-info'] = 'on' self.fields['transmission_type'].widget.attrs['data-trigger-address-info'] = 'on'
def clean(self): def clean(self):
from pretix.base.addressvalidation import ( # local import to prevent impact on startup time from pretix.base.addressvalidation import \
validate_address, validate_address # local import to prevent impact on startup time
)
data = self.cleaned_data data = self.cleaned_data
@@ -1505,12 +1493,11 @@ class BaseInvoiceAddressForm(forms.ModelForm):
"vat_id": _("This field is required.") "vat_id": _("This field is required.")
}) })
if self.validate_vat_id and self.instance.vat_id_validated and not any(v in self.changed_data for v in ('is_business', 'vat_id', 'country')): if self.validate_vat_id and self.instance.vat_id_validated and 'vat_id' not in self.changed_data:
pass # Skip re-validation if it is validated pass # Skip re-validation if it is validated
elif self.validate_vat_id and vat_id_applicable: elif self.validate_vat_id and vat_id_applicable:
try: try:
requester_id = self.request.event.settings.invoice_address_from_vat_id normalized_id = validate_vat_id(data.get('vat_id'), str(data.get('country')))
normalized_id = validate_vat_id(data.get('vat_id'), str(data.get('country')), requester_id)
self.instance.vat_id_validated = bool(normalized_id) self.instance.vat_id_validated = bool(normalized_id)
self.instance.vat_id = data['vat_id'] = normalized_id self.instance.vat_id = data['vat_id'] = normalized_id
except VATIDFinalError as e: except VATIDFinalError as e:
+2 -2
View File
@@ -82,8 +82,8 @@ class UserSettingsForm(forms.ModelForm):
class User2FADeviceAddForm(forms.Form): class User2FADeviceAddForm(forms.Form):
name = forms.CharField(label=_('Device name'), max_length=64) name = forms.CharField(label=_('Device name'), max_length=64)
devicetype = forms.ChoiceField(label=_('Device type'), widget=forms.RadioSelect, choices=( devicetype = forms.ChoiceField(label=_('Device type'), widget=forms.RadioSelect, choices=(
('otp_totp.totpdevice', _('Smartphone with the Authenticator application')), ('totp', _('Smartphone with the Authenticator application')),
('pretixbase.webauthndevice', _('WebAuthn-compatible hardware token (e.g. Yubikey)')), ('webauthn', _('WebAuthn-compatible hardware token (e.g. Yubikey)')),
)) ))
+1 -3
View File
@@ -173,13 +173,11 @@ class UploadedFileWidget(forms.ClearableFileInput):
@property @property
def url(self): def url(self):
from pretix.base.templatetags.safelink import answer_url
token = get_token(self.request, self.answer) token = get_token(self.request, self.answer)
if self.request.resolver_match.namespace == 'control': if self.request.resolver_match.namespace == 'control':
return self.answer.backend_file_url + '?token=' + token return self.answer.backend_file_url + '?token=' + token
else: else:
return answer_url(self.request, self.answer) return self.answer.frontend_file_url + '?token=' + token
def get_context(self, name, value, attrs): def get_context(self, name, value, attrs):
# Browsers can't recognize that the server already has a file uploaded # Browsers can't recognize that the server already has a file uploaded
+2 -2
View File
@@ -71,8 +71,8 @@ class EmailTransmissionType(TransmissionType):
def transmission_info_to_form_data(self, transmission_info: dict) -> dict: def transmission_info_to_form_data(self, transmission_info: dict) -> dict:
return { return {
"transmission_email_other": bool((transmission_info or {}).get("transmission_email_address")), "transmission_email_other": bool(transmission_info.get("transmission_email_address")),
"transmission_email_address": (transmission_info or {}).get("transmission_email_address"), "transmission_email_address": transmission_info.get("transmission_email_address"),
} }
def form_data_to_transmission_info(self, form_data: dict) -> dict: def form_data_to_transmission_info(self, form_data: dict) -> dict:
+19 -22
View File
@@ -131,27 +131,6 @@ class PeppolIdValidator:
def __init__(self, validate_online=False): def __init__(self, validate_online=False):
self.validate_online = validate_online self.validate_online = validate_online
def _validate_peppol_id_online(self, value):
base_hostnames = ['participant.sml.prod.tech.peppol.org', 'participant.sml.test.tech.peppol.org']
smp_id = base64.b32encode(hashlib.sha256(value.lower().encode()).digest()).decode().rstrip("=")
for base_hostname in base_hostnames:
smp_domain = f'{smp_id}.iso6523-actorid-upis.{base_hostname}'
resolver = dns.resolver.Resolver()
try:
answers = resolver.resolve(smp_domain, 'NAPTR', lifetime=1.0)
if answers:
return value
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
# ID not registered, do not set found=True
pass
except Exception: # noqa
# Error likely on our end or infrastructure is down, allow user to proceed
return value
raise ValidationError(
_("The Peppol participant ID is not registered on the Peppol network."),
)
def __call__(self, value): def __call__(self, value):
if ":" not in value: if ":" not in value:
raise ValidationError(_("A Peppol participant ID always starts with a prefix, followed by a colon (:).")) raise ValidationError(_("A Peppol participant ID always starts with a prefix, followed by a colon (:)."))
@@ -167,7 +146,25 @@ class PeppolIdValidator:
params={"number": prefix}) params={"number": prefix})
if self.validate_online: if self.validate_online:
value = self._validate_peppol_id_online(value) base_hostnames = ['edelivery.tech.ec.europa.eu', 'acc.edelivery.tech.ec.europa.eu']
smp_id = base64.b32encode(hashlib.sha256(value.lower().encode()).digest()).decode().rstrip("=")
for base_hostname in base_hostnames:
smp_domain = f'{smp_id}.iso6523-actorid-upis.{base_hostname}'
resolver = dns.resolver.Resolver()
try:
answers = resolver.resolve(smp_domain, 'NAPTR', lifetime=1.0)
if answers:
return value
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
# ID not registered, do not set found=True
pass
except Exception: # noqa
# Error likely on our end or infrastructure is down, allow user to proceed
return value
raise ValidationError(
_("The Peppol participant ID is not registered on the Peppol network."),
)
return value return value
@@ -107,9 +107,6 @@ class TransmissionType:
def transmission_info_to_form_data(self, transmission_info: dict) -> dict: def transmission_info_to_form_data(self, transmission_info: dict) -> dict:
return transmission_info return transmission_info
def describe_info_columns(self):
return [f.label for f in self.invoice_address_form_fields.values()]
def describe_info(self, transmission_info: dict, country: Country, is_business: bool): def describe_info(self, transmission_info: dict, country: Country, is_business: bool):
form_data = self.transmission_info_to_form_data(transmission_info) form_data = self.transmission_info_to_form_data(transmission_info)
data = [] data = []
@@ -1,49 +0,0 @@
# Generated by Django 5.2.17 on 2026-09-21 11:30
import django.db.models.deletion
from django.db import migrations, models
def fix_unshredded_invoices(apps, _):
Invoice = apps.get_model("pretixbase", "Invoice")
InvoiceLine = apps.get_model("pretixbase", "InvoiceLine")
ignore_fields = (
# bool/int fields are not listed and skipped automatically
'prefix', 'invoice_no', 'full_invoice_no', 'invoice_from', 'invoice_from_name', 'invoice_from_zipcode',
'invoice_from_city', 'invoice_from_state', 'invoice_from_country', 'invoice_from_tax_id',
'invoice_from_vat_id', 'locale', 'payment_provider_stamp', 'footer_text', 'foreign_currency_display',
'foreign_currency_source', 'transmission_type', 'transmission_provider', 'transmission_status',
)
for i in Invoice.objects.filter(shredded=True):
for f in Invoice._meta.fields:
if f.name in ignore_fields:
continue
val = getattr(i, f.name, None)
if val and isinstance(val, str):
setattr(i, f.name, "█")
elif val and isinstance(val, list): # jsonfield
setattr(i, f.name, [])
elif val and isinstance(val, dict): # jsonfield
setattr(i, f.name, {"_shredded": True})
i.save()
InvoiceLine.objects.filter(
attendee_name__isnull=False,
invoice__shredded=True
).update(attendee_name="█")
class Migration(migrations.Migration):
dependencies = [
("pretixbase", "0310_question_valid_string_length_min"),
]
operations = [
migrations.RunPython(
fix_unshredded_invoices,
migrations.RunPython.noop,
),
]
+51 -21
View File
@@ -24,6 +24,7 @@ import uuid
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.signals import post_delete from django.db.models.signals import post_delete
from django.dispatch import receiver from django.dispatch import receiver
from django.urls import reverse from django.urls import reverse
@@ -150,29 +151,12 @@ class LoggingMixin:
logentry = LogEntry(content_object=self, user=user, action_type=action, event=event, logentry = LogEntry(content_object=self, user=user, action_type=action, event=event,
organizer_id=organizer_id, **kwargs) organizer_id=organizer_id, **kwargs)
if isinstance(data, dict): if isinstance(data, dict):
# sensitivekeys are matched whether contained, not exactly sensitivekeys = ['password', 'secret', 'api_key']
sensitivekeys = [
'auth',
'key',
'token',
'password',
'Password',
'_pass',
'salt',
'secret',
]
def clean_recursive(d): for sensitivekey in sensitivekeys:
data = d for k, v in data.items():
data_iterator = d.items() if isinstance(d, dict) else enumerate(d) if (sensitivekey in k) and v:
for k, v in data_iterator:
if v and any([sensitivekey in str(k) for sensitivekey in sensitivekeys]):
data[k] = "********" data[k] = "********"
elif isinstance(v, (list, dict)):
data[k] = clean_recursive(v)
return data
data = clean_recursive(data)
logentry.data = json.dumps(data, cls=CustomJSONEncoder, sort_keys=True) logentry.data = json.dumps(data, cls=CustomJSONEncoder, sort_keys=True)
elif data: elif data:
@@ -244,3 +228,49 @@ class LoggedModel(models.Model, LoggingMixin):
return LogEntry.objects.filter( return LogEntry.objects.filter(
content_type=self.logs_content_type, object_id=self.pk content_type=self.logs_content_type, object_id=self.pk
).select_related('user', 'event', 'event__organizer', 'oauth_application', 'api_token', 'device') ).select_related('user', 'event', 'event__organizer', 'oauth_application', 'api_token', 'device')
class LockModel:
def refresh_for_update(self, fields=None, using=None, **kwargs):
"""
Like refresh_from_db(), but with select_for_update().
See also https://code.djangoproject.com/ticket/28344
"""
if fields is not None:
if not fields:
return
if any(LOOKUP_SEP in f for f in fields):
raise ValueError(
'Found "%s" in fields argument. Relations and transforms '
'are not allowed in fields.' % LOOKUP_SEP)
hints = {'instance': self}
db_instance_qs = self.__class__._base_manager.db_manager(using, hints=hints).filter(pk=self.pk).select_for_update(**kwargs)
# Use provided fields, if not set then reload all non-deferred fields.
deferred_fields = self.get_deferred_fields()
if fields is not None:
fields = list(fields)
db_instance_qs = db_instance_qs.only(*fields)
elif deferred_fields:
fields = [f.attname for f in self._meta.concrete_fields
if f.attname not in deferred_fields]
db_instance_qs = db_instance_qs.only(*fields)
db_instance = db_instance_qs.get()
non_loaded_fields = db_instance.get_deferred_fields()
for field in self._meta.concrete_fields:
if field.attname in non_loaded_fields:
# This field wasn't refreshed - skip ahead.
continue
setattr(self, field.attname, getattr(db_instance, field.attname))
# Clear cached foreign keys.
if field.is_relation and field.is_cached(self):
field.delete_cached_value(self)
# Clear cached relations.
for field in self._meta.related_objects:
if field.is_cached(self):
field.delete_cached_value(self)
self._state.db = db_instance._state.db
+1 -2
View File
@@ -93,7 +93,7 @@ class Gate(LoggedModel):
if instance: if instance:
qs = qs.exclude(pk=instance.pk) qs = qs.exclude(pk=instance.pk)
if qs.exists(): if qs.exists():
raise ValidationError(_('This identifier is already used for a different gate.')) raise ValidationError(_('This identifier is already used for a different question.'))
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.identifier: if not self.identifier:
@@ -166,7 +166,6 @@ class Device(LoggedModel):
) )
security_profile = models.CharField( security_profile = models.CharField(
max_length=190, max_length=190,
verbose_name=_('Security profile'),
default='full', default='full',
null=True, null=True,
blank=False blank=False
+6 -20
View File
@@ -83,8 +83,6 @@ from .organizer import Organizer, Team
if TYPE_CHECKING: if TYPE_CHECKING:
from hierarkey.proxy import HierarkeyProxy from hierarkey.proxy import HierarkeyProxy
from .organizer import SalesChannel
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -338,18 +336,12 @@ class EventMixin:
return safe_string(json.dumps(eventdict)) return safe_string(json.dumps(eventdict))
@classmethod @classmethod
def annotated(cls, qs, channel: "str | SalesChannel | list[SalesChannel]", voucher=None): def annotated(cls, qs, channel, voucher=None):
# Channel can currently be a SalesChannel or a str, since we need that compatibility, but a SalesChannel # Channel can currently be a SalesChannel or a str, since we need that compatibility, but a SalesChannel
# makes the query SIGNIFICANTLY faster # makes the query SIGNIFICANTLY faster
from pretix.base.models import Item, ItemVariation, Quota, SalesChannel from pretix.base.models import Item, ItemVariation, Quota, SalesChannel
assert isinstance(channel, (SalesChannel, str, list)) assert isinstance(channel, (SalesChannel, str))
if isinstance(channel, SalesChannel):
channel = [channel]
if isinstance(channel, list):
assert all(isinstance(c, SalesChannel) for c in channel)
sq_active_item = Item.objects.using(settings.DATABASE_REPLICA).filter_available(channel=channel, voucher=voucher).filter( sq_active_item = Item.objects.using(settings.DATABASE_REPLICA).filter_available(channel=channel, voucher=voucher).filter(
Q(variations__isnull=True) Q(variations__isnull=True)
@@ -372,8 +364,8 @@ class EventMixin:
q_variation &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__identifier=channel)) q_variation &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__identifier=channel))
q_variation &= Q(Q(item__all_sales_channels=True) | Q(item__limit_sales_channels__identifier=channel)) q_variation &= Q(Q(item__all_sales_channels=True) | Q(item__limit_sales_channels__identifier=channel))
else: else:
q_variation &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__in=channel)) q_variation &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels=channel))
q_variation &= Q(Q(item__all_sales_channels=True) | Q(item__limit_sales_channels__in=channel)) q_variation &= Q(Q(item__all_sales_channels=True) | Q(item__limit_sales_channels=channel))
if voucher: if voucher:
if voucher.variation_id: if voucher.variation_id:
@@ -1669,17 +1661,11 @@ class SubEvent(EventMixin, LoggedModel):
return qs_annotated return qs_annotated
@classmethod @classmethod
def annotated(cls, qs, channel: "str | SalesChannel | list[SalesChannel]", voucher=None): def annotated(cls, qs, channel, voucher=None):
from .items import SubEventItem, SubEventItemVariation from .items import SubEventItem, SubEventItemVariation
from .organizer import SalesChannel from .organizer import SalesChannel
assert isinstance(channel, (SalesChannel, str, list)) assert isinstance(channel, (str, SalesChannel))
if isinstance(channel, SalesChannel):
channel = [channel]
if isinstance(channel, list):
assert all(isinstance(c, SalesChannel) for c in channel)
qs = super().annotated(qs, channel, voucher=voucher) qs = super().annotated(qs, channel, voucher=voucher)
qs = qs.annotate( qs = qs.annotate(
+10 -17
View File
@@ -313,14 +313,7 @@ def filter_available(qs, channel='web', voucher=None, allow_addons=False, allow_
# makes the query SIGNIFICANTLY faster # makes the query SIGNIFICANTLY faster
from .organizer import SalesChannel from .organizer import SalesChannel
assert isinstance(channel, (SalesChannel, str, list)) assert isinstance(channel, (SalesChannel, str))
if isinstance(channel, SalesChannel):
channel = [channel]
if isinstance(channel, list):
assert all(isinstance(c, SalesChannel) for c in channel)
q = ( q = (
# IMPORTANT: If this is updated, also update the ItemVariation query # IMPORTANT: If this is updated, also update the ItemVariation query
# in models/event.py: EventMixin.annotated() # in models/event.py: EventMixin.annotated()
@@ -332,7 +325,7 @@ def filter_available(qs, channel='web', voucher=None, allow_addons=False, allow_
if isinstance(channel, str): if isinstance(channel, str):
q &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__identifier=channel)) q &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__identifier=channel))
else: else:
q &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels__in=channel)) q &= Q(Q(all_sales_channels=True) | Q(limit_sales_channels=channel))
if not allow_addons: if not allow_addons:
q &= Q(Q(category__isnull=True) | Q(category__is_addon=False)) q &= Q(Q(category__isnull=True) | Q(category__is_addon=False))
@@ -1057,8 +1050,10 @@ class Item(LoggedModel):
replace_year = valid_until.year replace_year = valid_until.year
replace_month = valid_until.month + self.validity_dynamic_duration_months replace_month = valid_until.month + self.validity_dynamic_duration_months
replace_year += (replace_month - 1) // 12
replace_month = ((replace_month - 1) % 12) + 1 while replace_month > 12:
replace_month -= 12
replace_year += 1
max_day = calendar.monthrange(replace_year, replace_month)[1] max_day = calendar.monthrange(replace_year, replace_month)[1]
replace_date = date( replace_date = date(
year=replace_year, year=replace_year,
@@ -1343,8 +1338,6 @@ class ItemVariation(models.Model):
quotacounter[q] += b.count quotacounter[q] += b.count
for q, n in quotacounter.items(): for q, n in quotacounter.items():
if n == 0:
continue
a = q.availability(count_waitinglist=count_waitinglist, _cache=_cache) a = q.availability(count_waitinglist=count_waitinglist, _cache=_cache)
if a[1] is None: if a[1] is None:
continue continue
@@ -1488,8 +1481,8 @@ class ItemAddOn(models.Model):
@staticmethod @staticmethod
def clean_max_count(max_count): def clean_max_count(max_count):
if max_count < 1: if max_count < 0:
raise ValidationError(_('The maximum count needs to be greater than zero.')) raise ValidationError(_('The maximum count needs to be equal to or greater than zero.'))
@staticmethod @staticmethod
def clean_max_min_count(max_count, min_count): def clean_max_min_count(max_count, min_count):
@@ -1570,8 +1563,8 @@ class ItemBundle(models.Model):
@staticmethod @staticmethod
def clean_count(count): def clean_count(count):
if count < 1: if count < 0:
raise ValidationError(_('The count needs to be greater than zero.')) raise ValidationError(_('The count needs to be equal to or greater than zero.'))
class Question(LoggedModel): class Question(LoggedModel):
+61 -9
View File
@@ -93,7 +93,7 @@ from ...testutils.middleware import debugflags_var
from ._transactions import ( from ._transactions import (
_fail, _transactions_mark_order_clean, _transactions_mark_order_dirty, _fail, _transactions_mark_order_clean, _transactions_mark_order_dirty,
) )
from .base import LoggedModel from .base import LockModel, LoggedModel
from .event import Event, SubEvent from .event import Event, SubEvent
from .items import Item, ItemVariation, Question, QuestionOption, Quota from .items import Item, ItemVariation, Question, QuestionOption, Quota
@@ -136,7 +136,7 @@ class OrderQuerySet(models.QuerySet):
return order return order
class Order(LoggedModel): class Order(LockModel, LoggedModel):
""" """
An order is created when a user clicks 'buy' on his cart. It holds An order is created when a user clicks 'buy' on his cart. It holds
several OrderPositions and is connected to a user. It has an several OrderPositions and is connected to a user. It has an
@@ -626,14 +626,47 @@ class Order(LoggedModel):
self.save(update_fields=['last_modified']) self.save(update_fields=['last_modified'])
def set_expires(self, now_dt=None, subevents=None): def set_expires(self, now_dt=None, subevents=None):
from pretix.base.services.payment import compute_payment_deadline now_dt = now_dt or now()
tz = ZoneInfo(self.event.settings.timezone)
self.expires = compute_payment_deadline( sales_channel_suffix = "_" + self.sales_channel.identifier.replace(".", "_")
event=self.event, if not (mode := self.event.settings.get(f'payment_term_mode{sales_channel_suffix}')):
sales_channel=self.sales_channel, mode = self.event.settings.get('payment_term_mode')
now_dt=now_dt, sales_channel_suffix = ""
subevents=subevents,
) if mode == 'days':
exp_by_date = now_dt.astimezone(tz) + timedelta(days=self.event.settings.get(f'payment_term_days{sales_channel_suffix}', as_type=int))
exp_by_date = exp_by_date.astimezone(tz).replace(hour=23, minute=59, second=59, microsecond=0)
if self.event.settings.get('payment_term_weekdays'):
if exp_by_date.weekday() == 5:
exp_by_date += timedelta(days=2)
elif exp_by_date.weekday() == 6:
exp_by_date += timedelta(days=1)
elif mode == 'minutes':
exp_by_date = now_dt.astimezone(tz) + timedelta(minutes=self.event.settings.get(f'payment_term_minutes{sales_channel_suffix}', as_type=int))
else:
raise ValueError("'payment_term_mode' has an invalid value '{}'.".format(mode))
self.expires = exp_by_date
term_last = self.event.settings.get('payment_term_last', as_type=RelativeDateWrapper)
if term_last:
if self.event.has_subevents and subevents:
terms = [
term_last.datetime(se).date()
for se in subevents
]
if not terms:
return
term_last = min(terms)
else:
term_last = term_last.datetime(self.event).date()
term_last = make_aware(datetime.combine(
term_last,
time(hour=23, minute=59, second=59)
), tz)
if term_last < self.expires:
self.expires = term_last
@cached_property @cached_property
def tax_total(self): def tax_total(self):
@@ -1349,6 +1382,25 @@ class QuestionAnswer(models.Model):
}) })
return "" return ""
@property
def frontend_file_url(self):
from pretix.multidomain.urlreverse import eventreverse
if self.file:
if self.associated_order:
url = eventreverse(self.associated_order.event, 'presale:event.order.download.answer', kwargs={
'order': self.associated_order.code,
'secret': self.associated_order.secret,
'answer': self.pk,
})
else:
url = eventreverse(self.event, 'presale:event.cart.download.answer', kwargs={
'answer': self.pk,
})
return url
return ""
@property @property
def is_image(self): def is_image(self):
return any(self.file.name.lower().endswith(e) for e in settings.FILE_UPLOAD_EXTENSIONS_QUESTION_IMAGE) return any(self.file.name.lower().endswith(e) for e in settings.FILE_UPLOAD_EXTENSIONS_QUESTION_IMAGE)
+1 -20
View File
@@ -42,7 +42,7 @@ from django.conf import settings
from django.core.mail import get_connection from django.core.mail import get_connection
from django.core.validators import MinLengthValidator, RegexValidator from django.core.validators import MinLengthValidator, RegexValidator
from django.db import models from django.db import models
from django.db.models import Exists, OuterRef, Q from django.db.models import Q
from django.urls import reverse from django.urls import reverse
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.functional import cached_property from django.utils.functional import cached_property
@@ -312,25 +312,6 @@ class Organizer(LoggedModel):
) )
i += 1 i += 1
def get_users_with_permission(self, permission):
"""
Returns a queryset of users who have a specific permission to this organizer.
:return: Iterable of User
"""
from .auth import User
if permission:
qs = Team.objects.with_organizer_permission(permission)
else:
qs = Team.objects.all()
team_with_perm = qs.filter(
members__pk=OuterRef('pk'),
organizer=self,
)
return User.objects.filter(Exists(team_with_perm))
def generate_invite_token(): def generate_invite_token():
return get_random_string(length=32, allowed_chars=string.ascii_lowercase + string.digits) return get_random_string(length=32, allowed_chars=string.ascii_lowercase + string.digits)
+11 -34
View File
@@ -35,13 +35,12 @@
import logging import logging
from collections import OrderedDict, namedtuple from collections import OrderedDict, namedtuple
from itertools import groupby from itertools import groupby
from typing import Optional, Union
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.formats import date_format from django.utils.formats import date_format
from django.utils.translation import gettext_lazy as _, pgettext_lazy from django.utils.translation import gettext_lazy as _, pgettext_lazy
from pretix.base.models import Event, LogEntry, Organizer from pretix.base.models import Event, LogEntry
from pretix.base.signals import register_notification_types from pretix.base.signals import register_notification_types
from pretix.base.templatetags.money import money_filter from pretix.base.templatetags.money import money_filter
from pretix.helpers.urls import mainreverse_absolute from pretix.helpers.urls import mainreverse_absolute
@@ -58,8 +57,7 @@ class Notification:
""" """
Represents a notification that is sent/shown to a user. A notification consists of: Represents a notification that is sent/shown to a user. A notification consists of:
* one ``event`` reference (can be ``Ǹone``) * one ``event`` reference
* one ``organizer`` reference
* one ``title`` text that is shown e.g. in the email subject or in a headline * one ``title`` text that is shown e.g. in the email subject or in a headline
* optionally one ``detail`` text that may or may not be shown depending on the notification method * optionally one ``detail`` text that may or may not be shown depending on the notification method
* optionally one ``url`` that should be absolute and point to the context of an notification (e.g. an order) * optionally one ``url`` that should be absolute and point to the context of an notification (e.g. an order)
@@ -69,12 +67,8 @@ class Notification:
each consisting of a button label and an absolute URL to point to. each consisting of a button label and an absolute URL to point to.
""" """
def __init__(self, event: Optional[Event], title: str, detail: Optional[str]=None, url: Optional[str]=None, organizer: Optional[Organizer]=None): def __init__(self, event: Event, title: str, detail: str=None, url: str=None):
assert event or organizer, "You need to pass either event or organizer"
if event and organizer:
assert event.organizer_id == organizer.id, "Organizer and event mismatch"
self.title = title self.title = title
self.organizer = organizer or event.organizer
self.event = event self.event = event
self.detail = detail self.detail = detail
self.url = url self.url = url
@@ -97,16 +91,8 @@ class Notification:
class NotificationType: class NotificationType:
def __init__(self, event_or_organizer: Union[Event, Organizer] = None): def __init__(self, event: Event = None):
if isinstance(event_or_organizer, Event): self.event = event
self.event = event_or_organizer
self.organizer = event_or_organizer.organizer
elif isinstance(event_or_organizer, Organizer):
self.event = None
self.organizer = event_or_organizer
else:
self.event = None
self.organizer = None
def __repr__(self): def __repr__(self):
return '<NotificationType: {}>'.format(self.action_type) return '<NotificationType: {}>'.format(self.action_type)
@@ -135,39 +121,31 @@ class NotificationType:
""" """
raise NotImplementedError() # NOQA raise NotImplementedError() # NOQA
@property
def is_event_level(self) -> bool:
"""
Return `True` if this notification type can be configured per event (the default).
"""
return True
def build_notification(self, logentry: LogEntry) -> Notification: def build_notification(self, logentry: LogEntry) -> Notification:
""" """
This is the main function that you should override. It is supposed to turn a log entry This is the main function that you should override. It is supposed to turn a log entry
object into a notification object that can then be rendered e.g. into an email. object into a notification object that can then be rendered e.g. into an email.
""" """
return Notification( return Notification(
event=logentry.event, logentry.event,
title=logentry.display(), logentry.display()
organizer=logentry.organizer,
) )
def get_all_notification_types(event_or_organizer=None): def get_all_notification_types(event=None):
global _ALL_TYPES global _ALL_TYPES
if event_or_organizer is None and _ALL_TYPES: if event is None and _ALL_TYPES:
return _ALL_TYPES return _ALL_TYPES
types = OrderedDict() types = OrderedDict()
for recv, ret in register_notification_types.send(event_or_organizer): for recv, ret in register_notification_types.send(event):
if isinstance(ret, (list, tuple)): if isinstance(ret, (list, tuple)):
for r in ret: for r in ret:
types[r.action_type] = r types[r.action_type] = r
else: else:
types[ret.action_type] = ret types[ret.action_type] = ret
if event_or_organizer is None: if event is None:
_ALL_TYPES = types _ALL_TYPES = types
return types return types
@@ -203,7 +181,6 @@ class ParametrizedOrderNotificationType(NotificationType):
n = Notification( n = Notification(
event=logentry.event, event=logentry.event,
organizer=logentry.organizer,
title=self._title.format(order=order, event=logentry.event), title=self._title.format(order=order, event=logentry.event),
url=order_url url=order_url
) )
+31 -37
View File
@@ -1527,37 +1527,42 @@ class GiftCardPayment(BasePaymentProvider):
}) })
def refund_control_render(self, request, refund) -> str: def refund_control_render(self, request, refund) -> str:
from .models import GiftCard
if 'gift_card' in refund.info_data: if 'gift_card' in refund.info_data:
gc = GiftCard.objects.get(pk=refund.info_data.get('gift_card'))
template = get_template('pretixcontrol/giftcards/payment.html')
ctx = {
'request': request,
'event': self.event,
'gc': gc,
}
return template.render(ctx)
def payment_control_render(self, request, payment) -> str:
from .models import GiftCard
if any(key in payment.info_data for key in ('gift_card', 'error')):
template = get_template('pretixcontrol/giftcards/payment.html') template = get_template('pretixcontrol/giftcards/payment.html')
ctx = { ctx = {
'request': request, 'request': request,
'event': self.event, 'event': self.event,
**({'error': payment.info_data[
'error']} if 'error' in payment.info_data else {}),
**({'gift_card_secret': payment.info_data[
'gift_card_secret']} if 'gift_card_secret' in payment.info_data else {})
} }
try: try:
gc = self.event.organizer.accepted_gift_cards.get(pk=refund.info_data.get('gift_card')) gc = GiftCard.objects.get(pk=payment.info_data.get('gift_card'))
ctx['gc'] = gc ctx = {
'gc': gc,
}
except GiftCard.DoesNotExist: except GiftCard.DoesNotExist:
pass pass
return template.render(ctx) finally:
return template.render(ctx)
def payment_control_render(self, request, payment) -> str:
template = get_template('pretixcontrol/giftcards/payment.html')
ctx = {
'request': request,
'event': self.event,
**({'error': payment.info_data[
'error']} if 'error' in payment.info_data else {}),
**({'gift_card_secret': payment.info_data[
'gift_card_secret']} if 'gift_card_secret' in payment.info_data else {})
}
try:
ctx['gc'] = self.event.organizer.accepted_gift_cards.get(pk=payment.info_data.get('gift_card'))
except GiftCard.DoesNotExist:
pass
if any(key in ctx for key in ('gc', 'gift_card_secret', 'error')):
return template.render(ctx)
def payment_control_render_short(self, payment: OrderPayment) -> str: def payment_control_render_short(self, payment: OrderPayment) -> str:
d = payment.info_data d = payment.info_data
@@ -1567,9 +1572,10 @@ class GiftCardPayment(BasePaymentProvider):
d = refund.info_data d = refund.info_data
return d.get('gift_card_secret', d.get('gift_card_code', self.public_name)) return d.get('gift_card_secret', d.get('gift_card_code', self.public_name))
def api_payment_details(self, payment: OrderPayment | OrderRefund): def api_payment_details(self, payment: OrderPayment):
from .models import GiftCard
try: try:
gc = self.event.organizer.accepted_gift_cards.get(pk=payment.info_data.get('gift_card')) gc = GiftCard.objects.get(pk=payment.info_data.get('gift_card'))
except GiftCard.DoesNotExist: except GiftCard.DoesNotExist:
return { return {
**({'error': payment.info_data[ **({'error': payment.info_data[
@@ -1692,19 +1698,7 @@ class GiftCardPayment(BasePaymentProvider):
@transaction.atomic() @transaction.atomic()
def execute_refund(self, refund: OrderRefund): def execute_refund(self, refund: OrderRefund):
from .models import GiftCard from .models import GiftCard
try: gc = GiftCard.objects.get(pk=refund.info_data.get('gift_card') or refund.payment.info_data.get('gift_card'))
gc = self.event.organizer.accepted_gift_cards.get(
pk=refund.info_data.get('gift_card') or refund.payment.info_data.get('gift_card'),
currency=self.event.currency
)
except GiftCard.DoesNotExist:
raise PaymentException(_("Gift card not found."))
if gc.testmode != refund.order.testmode:
raise PaymentException(_("Only test gift card can be used in test mode and vice versa."))
if gc.expires and gc.expires < time_machine_now():
raise PaymentException(_("This gift card is no longer valid."))
trans = gc.transactions.create( trans = gc.transactions.create(
value=refund.amount, value=refund.amount,
order=refund.order, order=refund.order,
+35 -41
View File
@@ -801,18 +801,6 @@ def generate_compressed_addon_list(op, order, event, only_checked_in=False):
return addonlist return addonlist
def get_sizebox(page: pypdf.PageObject):
mediabox = page.mediabox
cropbox = page.cropbox
return pypdf.generic.RectangleObject((
max(mediabox[0], cropbox[0]),
max(mediabox[1], cropbox[1]),
min(mediabox[2], cropbox[2]),
min(mediabox[3], cropbox[3]),
))
class Renderer: class Renderer:
def __init__(self, event, layout, background_file): def __init__(self, event, layout, background_file):
@@ -1091,7 +1079,7 @@ class Renderer:
fontsize = float(o['fontsize']) fontsize = float(o['fontsize'])
height = float(o['height']) * mm height = float(o['height']) * mm
width = float(o['width']) * mm width = float(o['width']) * mm
for _i in range(25): # try adapting the font size at most 25 times while True:
p, ad, lineheight = self._text_paragraph(op, order, o, override_fontsize=fontsize) p, ad, lineheight = self._text_paragraph(op, order, o, override_fontsize=fontsize)
w, h = p.wrapOn(canvas, width, 1000 * mm) w, h = p.wrapOn(canvas, width, 1000 * mm)
widths = p.getActualLineWidths0() widths = p.getActualLineWidths0()
@@ -1165,10 +1153,11 @@ class Renderer:
elif o['type'] == "poweredby": elif o['type'] == "poweredby":
self._draw_poweredby(canvas, op, o) self._draw_poweredby(canvas, op, o)
if self.bg_pdf: if self.bg_pdf:
first_page = self.bg_pdf.pages[0] page_size = (
sizebox = get_sizebox(first_page) self.bg_pdf.pages[0].mediabox[2] - self.bg_pdf.pages[0].mediabox[0],
page_size = (sizebox.width, sizebox.height) self.bg_pdf.pages[0].mediabox[3] - self.bg_pdf.pages[0].mediabox[1]
if first_page.rotation in (90, 270): )
if self.bg_pdf.pages[0].get('/Rotate') in (90, 270):
# swap dimensions due to pdf being rotated # swap dimensions due to pdf being rotated
page_size = page_size[::-1] page_size = page_size[::-1]
canvas.setPageSize(page_size) canvas.setPageSize(page_size)
@@ -1243,7 +1232,9 @@ class Renderer:
for i, page in enumerate(fg_pdf.pages): for i, page in enumerate(fg_pdf.pages):
bg_page = self.bg_pdf.pages[i] bg_page = self.bg_pdf.pages[i]
_merge_with_correct_page_media_box(output, page, bg_page) _correct_page_media_box(bg_page)
page.merge_page(bg_page, over=False)
output.add_page(page)
# pdf_header is a string like "%pdf-X.X" # pdf_header is a string like "%pdf-X.X"
if float(self.bg_pdf.pdf_header[5:]) > float(fg_pdf.pdf_header[5:]): if float(self.bg_pdf.pdf_header[5:]) > float(fg_pdf.pdf_header[5:]):
@@ -1308,36 +1299,39 @@ def merge_background(fg_pdf: PdfWriter, bg_pdf: PdfWriter, out_file, compress):
bg_pdf.write(bg_filename) bg_pdf.write(bg_filename)
subprocess.run(pdftk_cmd, check=True, stdout=out_file) subprocess.run(pdftk_cmd, check=True, stdout=out_file)
else: else:
output = PdfWriter()
for i, page in enumerate(fg_pdf.pages): for i, page in enumerate(fg_pdf.pages):
bg_page = bg_pdf.pages[i] bg_page = bg_pdf.pages[i]
_merge_with_correct_page_media_box(output, page, bg_page) _correct_page_media_box(bg_page)
page.merge_page(bg_page, over=False)
# pdf_header is a string like "%pdf-X.X" # pdf_header is a string like "%pdf-X.X"
output.pdf_header = ( if float(bg_pdf.pdf_header[5:]) > float(fg_pdf.pdf_header[5:]):
bg_pdf.pdf_header fg_pdf.pdf_header = bg_pdf.pdf_header
if float(bg_pdf.pdf_header[5:]) > float(fg_pdf.pdf_header[5:])
else fg_pdf.pdf_header fg_pdf.write(out_file)
)
output.write(out_file)
def _merge_with_correct_page_media_box(output: pypdf.PdfWriter, fg_page: pypdf.PageObject, bg_page: pypdf.PageObject): def _correct_page_media_box(page: pypdf.PageObject):
""" if page.rotation != 0:
Adds fg_page to output, merging bg_page behind it. page.transfer_rotation_to_content()
media_box = page.mediabox
If bg_page has a non-zero mergebox/cropbox or is rotated via /Rotate, a transformation is applied to fix this."""
trsf = pypdf.Transformation() trsf = pypdf.Transformation()
if bg_page.rotation != 0: if media_box.bottom != 0:
trsf = trsf.rotate(-bg_page.rotation) trsf = trsf.translate(0, -media_box.bottom)
if media_box.left != 0:
mb = get_sizebox(bg_page) trsf = trsf.translate(-media_box.left, 0)
pt1 = trsf.apply_on(mb.lower_left) page.add_transformation(trsf, False)
pt2 = trsf.apply_on(mb.upper_right) for b in ["/MediaBox", "/CropBox", "/BleedBox", "/TrimBox", "/ArtBox"]:
trsf = trsf.translate(-min(pt1[0], pt2[0]), -min(pt1[1], pt2[1])) if b in page:
rr = pypdf.generic.RectangleObject(page[b])
fg_page = output.add_page(fg_page) pt1 = trsf.apply_on(rr.lower_left)
fg_page.merge_transformed_page(bg_page, trsf, over=False, expand=False) pt2 = trsf.apply_on(rr.upper_right)
page[pypdf.generic.NameObject(b)] = pypdf.generic.RectangleObject((
min(pt1[0], pt2[0]),
min(pt1[1], pt2[1]),
max(pt1[0], pt2[0]),
max(pt1[1], pt2[1]),
))
@deconstructible @deconstructible
-1
View File
@@ -330,6 +330,5 @@ def register_default_organizer_permissions(sender, **kwargs):
PermissionOption(actions=tuple(), label=pgettext_lazy("permission_level", "No access")), PermissionOption(actions=tuple(), label=pgettext_lazy("permission_level", "No access")),
PermissionOption(actions=("read",), label=pgettext_lazy("permission_level", "View")), PermissionOption(actions=("read",), label=pgettext_lazy("permission_level", "View")),
], ],
help_text=_("View access includes the option to e.g. abort pending emails or retry failed emails."),
), ),
] ]
+1 -1
View File
@@ -22,9 +22,9 @@
import os import os
import sys import sys
from enum import Enum from enum import Enum
from importlib import metadata
from typing import List from typing import List
import importlib_metadata as metadata
from django.apps import AppConfig, apps from django.apps import AppConfig, apps
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
-1
View File
@@ -1605,7 +1605,6 @@ def add_payment_to_cart_session(cart_session, provider, min_value: Decimal=None,
'max_value': str(max_value) if max_value is not None else None, 'max_value': str(max_value) if max_value is not None else None,
'info_data': info_data or {}, 'info_data': info_data or {},
}) })
cart_session['payments_postpone'] = False
def add_payment_to_cart(request, provider, min_value: Decimal=None, max_value: Decimal=None, info_data: dict=None): def add_payment_to_cart(request, provider, min_value: Decimal=None, max_value: Decimal=None, info_data: dict=None):
+3 -6
View File
@@ -54,7 +54,7 @@ from celery.exceptions import MaxRetriesExceededError
from django.conf import settings from django.conf import settings
from django.core.files.storage import default_storage from django.core.files.storage import default_storage
from django.core.mail import EmailMultiAlternatives, SafeMIMEMultipart from django.core.mail import EmailMultiAlternatives, SafeMIMEMultipart
from django.core.mail.message import SafeMIMEText, utf8_charset_qp from django.core.mail.message import SafeMIMEText
from django.db import connection, transaction from django.db import connection, transaction
from django.db.models import Q from django.db.models import Q
from django.dispatch import receiver from django.dispatch import receiver
@@ -316,7 +316,6 @@ def mail(email: Union[str, Sequence[str]], subject: Union[str, FormattedString],
body_html = None body_html = None
m = OutgoingMail.objects.create( m = OutgoingMail.objects.create(
guid=guid,
organizer=organizer, organizer=organizer,
event=event, event=event,
order=order, order=order,
@@ -381,8 +380,6 @@ def mail(email: Union[str, Sequence[str]], subject: Union[str, FormattedString],
class CustomEmail(EmailMultiAlternatives): class CustomEmail(EmailMultiAlternatives):
encoding = utf8_charset_qp
def _create_mime_attachment(self, content, mimetype): def _create_mime_attachment(self, content, mimetype):
""" """
Convert the content, mimetype pair into a MIME attachment object. Convert the content, mimetype pair into a MIME attachment object.
@@ -452,9 +449,9 @@ def mail_send_task(self, **kwargs) -> bool:
# Rewrite all <img> tags from real URLs or data URLs to inline attachments referred to by content ID # Rewrite all <img> tags from real URLs or data URLs to inline attachments referred to by content ID
if outgoing_mail.body_html is not None: if outgoing_mail.body_html is not None:
html_message = SafeMIMEMultipart(_subtype='related') html_message = SafeMIMEMultipart(_subtype='related', encoding=settings.DEFAULT_CHARSET)
html_with_cid, cid_images = replace_images_with_cid_paths(outgoing_mail.body_html) html_with_cid, cid_images = replace_images_with_cid_paths(outgoing_mail.body_html)
html_message.attach(SafeMIMEText(html_with_cid, 'html', utf8_charset_qp)) html_message.attach(SafeMIMEText(html_with_cid, 'html', settings.DEFAULT_CHARSET))
attach_cid_images(html_message, cid_images, verify_ssl=True) attach_cid_images(html_message, cid_images, verify_ssl=True)
email.attach_alternative(html_message, "multipart/related") email.attach_alternative(html_message, "multipart/related")
+18 -37
View File
@@ -34,9 +34,7 @@ from pretix.base.models import (
from pretix.base.notifications import Notification, get_all_notification_types from pretix.base.notifications import Notification, get_all_notification_types
from pretix.base.services.mail import mail_send_task from pretix.base.services.mail import mail_send_task
from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask
from pretix.base.signals import ( from pretix.base.signals import notification
event_notification_sent, organizer_notification_sent,
)
from pretix.celery_app import app from pretix.celery_app import app
from pretix.helpers.celery import get_task_priority from pretix.helpers.celery import get_task_priority
from pretix.helpers.urls import mainreverse_absolute from pretix.helpers.urls import mainreverse_absolute
@@ -49,47 +47,40 @@ def notify(logentry_ids: list):
logentry_ids = [logentry_ids] logentry_ids = [logentry_ids]
qs = LogEntry.all.select_related( qs = LogEntry.all.select_related(
'event', 'event__organizer', 'organizer' 'event', 'event__organizer'
).order_by( ).order_by(
'action_type', 'event_id', 'organizer_id', 'action_type', 'event_id',
).filter(id__in=logentry_ids) ).filter(id__in=logentry_ids)
_event, _organizer, _at, notify_specific, notify_global = None, None, None, None, None _event, _at, notify_specific, notify_global = None, None, None, None
for logentry in qs: for logentry in qs:
if not logentry.event and not logentry.organizer: if not logentry.event:
break # Ignore, we only have event- or organizer-related notifications right now break # Ignore, we only have event-related notifications right now
notification_type = logentry.notification_type notification_type = logentry.notification_type
if not notification_type: if not notification_type:
break # No suitable plugin break # No suitable plugin
if _event != logentry.event or _organizer != logentry.organizer or _at != logentry.action_type or notify_global is None: if _event != logentry.event or _at != logentry.action_type or notify_global is None:
_event = logentry.event _event = logentry.event
_organizer = logentry.organizer
_at = logentry.action_type _at = logentry.action_type
event_or_organizer = logentry.event or logentry.organizer
# All users that have the permission to get the notification # All users that have the permission to get the notification
users = event_or_organizer.get_users_with_permission( users = logentry.event.get_users_with_permission(
notification_type.required_permission notification_type.required_permission
).filter(notifications_send=True, is_active=True) ).filter(notifications_send=True, is_active=True)
if logentry.user: if logentry.user:
users = users.exclude(pk=logentry.user.pk) users = users.exclude(pk=logentry.user.pk)
# Get all notification settings, both specific to this event as well as global # Get all notification settings, both specific to this event as well as global
if logentry.event: notify_specific = {
notify_specific = { (ns.user, ns.method): ns.enabled
(ns.user, ns.method): ns.enabled for ns in NotificationSetting.objects.filter(
for ns in NotificationSetting.objects.filter( event=logentry.event,
event=logentry.event, action_type=notification_type.action_type,
action_type=notification_type.action_type, user__pk__in=users.values_list('pk', flat=True)
user__pk__in=users.values_list('pk', flat=True) )
) }
}
else:
notify_specific = {}
notify_global = { notify_global = {
(ns.user, ns.method): ns.enabled (ns.user, ns.method): ns.enabled
for ns in NotificationSetting.objects.filter( for ns in NotificationSetting.objects.filter(
@@ -115,10 +106,7 @@ def notify(logentry_ids: list):
priority=get_task_priority("notifications", logentry.organizer_id), priority=get_task_priority("notifications", logentry.organizer_id),
) )
if logentry.event: notification.send(logentry.event, logentry_id=logentry.id, notification_type=notification_type.action_type)
event_notification_sent.send(logentry.event, logentry_id=logentry.id, notification_type=notification_type.action_type)
elif logentry.organizer:
organizer_notification_sent.send(logentry.organizer, logentry_id=logentry.id, notification_type=notification_type.action_type)
@app.task(base=ProfiledTask, acks_late=True, max_retries=9, default_retry_delay=900) @app.task(base=ProfiledTask, acks_late=True, max_retries=9, default_retry_delay=900)
@@ -170,20 +158,13 @@ def send_notification_mail(notification: Notification, user: User):
body_plain = tpl_plain.render(ctx) body_plain = tpl_plain.render(ctx)
guid = uuid.uuid4() guid = uuid.uuid4()
settings_holder = notification.event or notification.organizer
prefix = settings_holder.settings.mail_prefix
if not prefix:
if notification.event:
prefix = notification.event.slug.upper()
elif notification.organizer:
prefix = notification.organizer.name
m = OutgoingMail.objects.create( m = OutgoingMail.objects.create(
guid=guid, guid=guid,
user=user, user=user,
to=[user.email], to=[user.email],
subject='[{}] {}: {}'.format( subject='[{}] {}: {}'.format(
settings.PRETIX_INSTANCE_NAME, settings.PRETIX_INSTANCE_NAME,
prefix, notification.event.settings.mail_prefix or notification.event.slug.upper(),
notification.title notification.title
), ),
body_plain=body_plain, body_plain=body_plain,
+15 -58
View File
@@ -359,8 +359,7 @@ def mark_order_refunded(order, user=None, auth=None, api_token=None):
def mark_order_expired(order, user=None, auth=None): def mark_order_expired(order, user=None, auth=None):
""" """
Mark this order as expired. This sets the order status, generates an invoice cancellation Mark this order as expired. This sets the payment status and returns the order object.
and returns the order object.
:param order: The order to change :param order: The order to change
:param user: The user that performed the change :param user: The user that performed the change
""" """
@@ -962,7 +961,7 @@ def _check_positions(event: Event, now_dt: datetime, time_machine_now_dt: dateti
def _apply_rounding_and_fees(positions: List[CartPosition], payment_requests: List[dict], address: InvoiceAddress, def _apply_rounding_and_fees(positions: List[CartPosition], payment_requests: List[dict], address: InvoiceAddress,
meta_info: dict, event: Event, sales_channel: SalesChannel, require_approval=False): meta_info: dict, event: Event, require_approval=False):
fees = [] fees = []
# Pre-rounding, pre-fee total is used for fee calculation # Pre-rounding, pre-fee total is used for fee calculation
total = sum([c.gross_price_before_rounding for c in positions]) total = sum([c.gross_price_before_rounding for c in positions])
@@ -970,7 +969,7 @@ def _apply_rounding_and_fees(positions: List[CartPosition], payment_requests: Li
gift_cards = [] # for backwards compatibility gift_cards = [] # for backwards compatibility
for p in payment_requests: for p in payment_requests:
if p['provider'] == 'giftcard': if p['provider'] == 'giftcard':
gift_cards.extend(event.organizer.accepted_gift_cards.filter(pk=p['info_data']['gift_card'])) gift_cards.append(GiftCard.objects.get(pk=p['info_data']['gift_card']))
for recv, resp in order_fee_calculation.send(sender=event, invoice_address=address, total=total, payment_requests=payment_requests, for recv, resp in order_fee_calculation.send(sender=event, invoice_address=address, total=total, payment_requests=payment_requests,
meta_info=meta_info, positions=positions, gift_cards=gift_cards): meta_info=meta_info, positions=positions, gift_cards=gift_cards):
@@ -1022,14 +1021,7 @@ def _apply_rounding_and_fees(positions: List[CartPosition], payment_requests: Li
payments_assigned += to_pay payments_assigned += to_pay
p['payment_amount'] = to_pay p['payment_amount'] = to_pay
allow_postponed_payment = ( if total != payments_assigned and not require_approval:
require_approval or
(
sales_channel.identifier in event.settings.payment_choice_postpone_allowed_channels and not payment_requests
)
)
if total != payments_assigned and not allow_postponed_payment:
raise OrderError(_("The selected payment methods do not cover the total balance.")) raise OrderError(_("The selected payment methods do not cover the total balance."))
return fees return fees
@@ -1051,15 +1043,7 @@ def _create_order(event: Event, *, email: str, positions: List[CartPosition], no
# Final calculation of fees, also performs final rounding # Final calculation of fees, also performs final rounding
try: try:
fees = _apply_rounding_and_fees( fees = _apply_rounding_and_fees(positions, payment_requests, address, meta_info, event, require_approval=require_approval)
positions,
payment_requests,
address,
meta_info,
event,
sales_channel=sales_channel,
require_approval=require_approval
)
except TaxRule.SaleNotAllowed: except TaxRule.SaleNotAllowed:
raise OrderError(error_messages['country_blocked']) raise OrderError(error_messages['country_blocked'])
@@ -2176,8 +2160,7 @@ class OrderChangeManager:
subevent=a.subevent, subevent=a.subevent,
voucher=None, voucher=None,
base_qs=Item.objects.filter(pk=a.item.pk), base_qs=Item.objects.filter(pk=a.item.pk),
allow_addons=True, allow_addons=True
ignore_hide_sold_out_for_item_ids={a.item.pk}
) )
if (not items) or items[0].current_unavailability_reason: if (not items) or items[0].current_unavailability_reason:
return False return False
@@ -2476,11 +2459,7 @@ class OrderChangeManager:
self.order.log_action('pretix.event.order.changed.feevalue', user=self.user, auth=self.auth, data={ self.order.log_action('pretix.event.order.changed.feevalue', user=self.user, auth=self.auth, data={
'fee': fee.pk, 'fee': fee.pk,
'old_price': fee.value, 'old_price': fee.value,
'new_price': op.value.gross, 'new_price': op.value.gross
'old_tax_rate': fee.tax_rate,
'new_tax_rate': op.value.rate,
'old_tax_value': fee.tax_value,
'new_tax_value': op.value.tax,
}) })
fee.value = op.value.gross fee.value = op.value.gross
fee._calculate_tax() fee._calculate_tax()
@@ -2490,13 +2469,9 @@ class OrderChangeManager:
self.order.log_action('pretix.event.order.changed.price', user=self.user, auth=self.auth, data={ self.order.log_action('pretix.event.order.changed.price', user=self.user, auth=self.auth, data={
'position': position.pk, 'position': position.pk,
'positionid': position.positionid, 'positionid': position.positionid,
'addon_to': position.addon_to_id,
'old_price': position.price, 'old_price': position.price,
'new_price': op.price.gross, 'addon_to': position.addon_to_id,
'old_tax_rate': position.tax_rate, 'new_price': op.price.gross
'new_tax_rate': op.price.rate,
'old_tax_value': position.tax_value,
'new_tax_value': op.price.tax,
}) })
position.price = op.price.gross position.price = op.price.gross
position.price_includes_rounding_correction = Decimal("0.00") position.price_includes_rounding_correction = Decimal("0.00")
@@ -2511,43 +2486,25 @@ class OrderChangeManager:
elif isinstance(op, self.TaxRuleOperation): elif isinstance(op, self.TaxRuleOperation):
if isinstance(op.position, OrderPosition): if isinstance(op.position, OrderPosition):
position = position_cache.setdefault(op.position.pk, op.position) position = position_cache.setdefault(op.position.pk, op.position)
log = { self.order.log_action('pretix.event.order.changed.tax_rule', user=self.user, auth=self.auth, data={
'position': position.pk, 'position': position.pk,
'positionid': position.positionid, 'positionid': position.positionid,
'addon_to': position.addon_to_id, 'addon_to': position.addon_to_id,
'old_taxrule': position.tax_rule.pk if position.tax_rule else None, 'old_taxrule': position.tax_rule.pk if position.tax_rule else None,
'new_taxrule': op.tax_rule.pk, 'new_taxrule': op.tax_rule.pk
'old_price': position.price, })
'old_tax_rate': position.tax_rate,
'old_tax_value': position.tax_value,
}
position._calculate_tax(op.tax_rule) position._calculate_tax(op.tax_rule)
position.save() position.save()
log.update({
'new_price': position.price,
'new_tax_rate': position.tax_rate,
'new_tax_value': position.tax_value,
})
self.order.log_action('pretix.event.order.changed.tax_rule', user=self.user, auth=self.auth, data=log)
elif isinstance(op.position, OrderFee): elif isinstance(op.position, OrderFee):
fee = fee_cache.setdefault(op.position.pk, op.position) fee = fee_cache.setdefault(op.position.pk, op.position)
log = { self.order.log_action('pretix.event.order.changed.tax_rule', user=self.user, auth=self.auth, data={
'fee': fee.pk, 'fee': fee.pk,
'fee_type': fee.fee_type, 'fee_type': fee.fee_type,
'old_taxrule': fee.tax_rule.pk if fee.tax_rule else None, 'old_taxrule': fee.tax_rule.pk if fee.tax_rule else None,
'new_taxrule': op.tax_rule.pk, 'new_taxrule': op.tax_rule.pk
'old_price': fee.value, })
'old_tax_rate': fee.tax_rate,
'old_tax_value': fee.tax_value,
}
fee._calculate_tax(op.tax_rule) fee._calculate_tax(op.tax_rule)
fee.save() fee.save()
log.update({
'new_price': fee.value,
'new_tax_rate': fee.tax_rate,
'new_tax_value': fee.tax_value,
})
self.order.log_action('pretix.event.order.changed.tax_rule', user=self.user, auth=self.auth, data=log)
elif isinstance(op, self.CancelFeeOperation): elif isinstance(op, self.CancelFeeOperation):
fee = fee_cache.setdefault(op.fee.pk, op.fee) fee = fee_cache.setdefault(op.fee.pk, op.fee)
self.order.log_action('pretix.event.order.changed.cancelfee', user=self.user, auth=self.auth, data={ self.order.log_action('pretix.event.order.changed.cancelfee', user=self.user, auth=self.auth, data={
-76
View File
@@ -1,76 +0,0 @@
#
# This file is part of pretix (Community Edition).
#
# Copyright (C) 2014-2020 Raphael Michel and contributors
# Copyright (C) 2020-today pretix 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 datetime import datetime, time, timedelta
from zoneinfo import ZoneInfo
from django.utils.timezone import make_aware, now
from pretix.base.models import Event, SalesChannel
from pretix.base.reldate import RelativeDateWrapper
def compute_payment_deadline(event: Event, sales_channel: SalesChannel, now_dt=None, subevents=None) -> datetime:
now_dt = now_dt or now()
tz = ZoneInfo(event.settings.timezone)
sales_channel_suffix = "_" + sales_channel.identifier.replace(".", "_")
if not (mode := event.settings.get(f'payment_term_mode{sales_channel_suffix}')):
mode = event.settings.get('payment_term_mode')
sales_channel_suffix = ""
if mode == 'days':
exp_by_date = now_dt.astimezone(tz) + timedelta(
days=event.settings.get(f'payment_term_days{sales_channel_suffix}', as_type=int))
exp_by_date = exp_by_date.astimezone(tz).replace(hour=23, minute=59, second=59, microsecond=0)
if event.settings.get('payment_term_weekdays'):
if exp_by_date.weekday() == 5:
exp_by_date += timedelta(days=2)
elif exp_by_date.weekday() == 6:
exp_by_date += timedelta(days=1)
elif mode == 'minutes':
exp_by_date = now_dt.astimezone(tz) + timedelta(
minutes=event.settings.get(f'payment_term_minutes{sales_channel_suffix}', as_type=int))
else:
raise ValueError("'payment_term_mode' has an invalid value '{}'.".format(mode))
expires = exp_by_date
term_last = event.settings.get('payment_term_last', as_type=RelativeDateWrapper)
if term_last:
if event.has_subevents and subevents:
terms = [
term_last.datetime(se).date()
for se in subevents
]
if not terms:
return expires
term_last = min(terms)
else:
term_last = term_last.datetime(event).date()
term_last = make_aware(datetime.combine(
term_last,
time(hour=23, minute=59, second=59)
), tz)
if term_last < expires:
return term_last
return expires
-5
View File
@@ -752,11 +752,6 @@ def base_placeholders(sender, **kwargs):
lambda position_or_address: concatenation_for_salutation(get_best_name(position_or_address, parts=True)), lambda position_or_address: concatenation_for_salutation(get_best_name(position_or_address, parts=True)),
lambda event: concatenation_for_salutation(name_scheme['sample']), lambda event: concatenation_for_salutation(name_scheme['sample']),
)) ))
ph.append(SimpleFunctionalTextPlaceholder(
"attendee_name_for_salutation", ["position"],
lambda position: concatenation_for_salutation(position.attendee_name_parts),
lambda event: concatenation_for_salutation(name_scheme['sample']),
))
for f, l, w in name_scheme['fields']: for f, l, w in name_scheme['fields']:
if f == 'full_name': if f == 'full_name':
+2 -2
View File
@@ -126,10 +126,10 @@ def generate_seats(event, subevent, plan, mapping, blocked_guids=None):
for s in current_seats.values(): for s in current_seats.values():
if s.has_op: if s.has_op:
raise SeatProtected(_('You can not change the plan since seat "%s" is not present in the new plan and is ' raise SeatProtected(_('You can not change the plan since seat "%s" is not present in the new plan and is '
'already sold.'), s.name) 'already sold.', s.name))
if s.has_v: if s.has_v:
raise SeatProtected(_('You can not change the plan since seat "%s" is not present in the new plan and is ' raise SeatProtected(_('You can not change the plan since seat "%s" is not present in the new plan and is '
'already used in a voucher.'), s.name) 'already used in a voucher.', s.name))
Seat.objects.bulk_create(create_seats) Seat.objects.bulk_create(create_seats)
CartPosition.objects.filter(addon_to__seat__in=[s.pk for s in current_seats.values()]).delete() CartPosition.objects.filter(addon_to__seat__in=[s.pk for s in current_seats.values()]).delete()
+2 -68
View File
@@ -343,66 +343,6 @@ def _validate_vat_id_EU(vat_id, country_code):
return vat_id return vat_id
def _validate_vat_id_EU_fallback_germany(vat_id, country_code, requester_id):
# We can skip most static validation checks because _validate_vat_id_EU always runs before
vat_id = normalize_vat_id(vat_id, country_code)
# The VIES service of the European commission is overused and down due to rate limits A LOT. There is another
# API by German BZSt, but it only works if the requester is German and the requested is not.
# https://www.bzst.de/DE/Unternehmen/Identifikationsnummern/Umsatzsteuer-Identifikationsnummer/AuslaendischeUSt-IdNr/auslaendische_ust_idnr_node.html
try:
r = requests.post(
"https://api.evatr.vies.bzst.de/app/v1/abfrage",
json={
"anfragendeUstid": requester_id,
"angefragteUstid": vat_id,
},
timeout=10,
)
d = r.json()
if r.status_code == 200:
if d['status'] in ('evatr-0000', 'evatr-2008'):
# evatr-0000: Die angefragte Ust-IdNr. ist zum Anfragezeitpunkt gültig.
# evatr-2008: Die angefragte Ust-IdNr. ist zum Anfragezeitpunkt gültig.
# Für die qualifizierte Bestätigungsanfrage liegt einer Besonderheit vor.
# Für Rückfragen wenden Sie sich an das BZSt.
return vat_id
# evatr-2002: Die angefragte USt-IdNr. ist zum Anfragezeitpunkt nicht gültig.
# Sie ist erst gültig ab dem Datum im Feld gueltigAb.
# evatr-2006: Die angefragte Ust-IdNr. ist zum Anfragezeitpunkt nicht gültig.
# Sie war gültig im Zeitraum, der durch die Werte in den Feldern gueltigAb und gueltigBis beschrieben ist.
raise VATIDFinalError(error_messages['invalid'])
elif r.status_code == 400:
if d['status'] in ('evatr-0002', 'evatr-0004', 'evatr-0008'):
# evatr-0002: Mindestens eins der Pflichtfelder ist nicht besetzt.
# evatr-0004: Die anfragende DE Ust-IdNr. ist syntaktisch falsch. Sie passt nicht in das deutsche Erzeugungsschema.
# evatr-0008: Die maximale Anzahl von qualifizierten Bestätigungsabfragen für diese Session wurde erreicht.
# Bitte starten Sie erneut mit einer einfachen Bestätigungsabfrage.
raise VATIDTemporaryError(error_messages['unavailable'])
# evatr-0005: Die angegebene angefragte Ust-IdNr. ist syntaktisch falsch.
# evatr-0012: Die angefrage USt-IdNr. ist syntaktisch falsch. Sie passt nicht in das Erzeugungsschema.
# evatr-2003: Das angegebene Länderkennzeichen der angefragten USt-IdNr. ist nicht gültig.
raise VATIDFinalError(error_messages['invalid'])
elif r.status_code == 403:
# evatr-0006: Die anfragende DE USt-IdNr. ist nicht berechtigt eine DE Ust-IdNr. anzufragen.
# evatr-0007: Fehlerhafter Aufruf.
raise VATIDTemporaryError(error_messages['unavailable'])
elif r.status_code == 404:
if d['status'] in ('evatr-2005'):
# evatr-2005: Die angegebene eigene DE Ust-IdNr. ist zum Anfragezeitpunkt nicht gültig.
raise VATIDTemporaryError(error_messages['unavailable'])
# evatr-2001: Die angefragte USt-IdNr. ist zum Anfragezeitpunkt nicht vergeben.
raise VATIDFinalError(error_messages['invalid'])
else: # 500, 503
raise VATIDTemporaryError(error_messages['unavailable'])
except requests.RequestException:
logger.exception('VAT ID checking failed for country {}'.format(country_code))
raise VATIDTemporaryError(error_messages['unavailable'])
except ValueError: # JSON parsing failed
logger.exception('VAT ID checking failed for country {}'.format(country_code))
raise VATIDTemporaryError(error_messages['unavailable'])
def _validate_vat_id_CH(vat_id, country_code): def _validate_vat_id_CH(vat_id, country_code):
if vat_id[:3] != 'CHE': if vat_id[:3] != 'CHE':
raise VATIDFinalError(error_messages['country_mismatch']) raise VATIDFinalError(error_messages['country_mismatch'])
@@ -454,18 +394,12 @@ def _validate_vat_id_CH(vat_id, country_code):
return vat_id return vat_id
def validate_vat_id(vat_id, country_code, requester_id=None): def validate_vat_id(vat_id, country_code):
if not vat_id: if not vat_id:
return vat_id return vat_id
country_code = str(country_code) country_code = str(country_code)
if is_eu_country(country_code): if is_eu_country(country_code):
try: return _validate_vat_id_EU(vat_id, country_code)
return _validate_vat_id_EU(vat_id, country_code)
except VATIDTemporaryError:
if requester_id and requester_id.startswith("DE") and not vat_id.startswith("DE"):
return _validate_vat_id_EU_fallback_germany(vat_id, country_code, requester_id)
else:
raise
elif country_code == 'CH': elif country_code == 'CH':
return _validate_vat_id_CH(vat_id, country_code) return _validate_vat_id_CH(vat_id, country_code)
elif country_code == 'NO': elif country_code == 'NO':
+14 -24
View File
@@ -1159,19 +1159,6 @@ DEFAULTS = {
"configured above."), "configured above."),
) )
}, },
'payment_choice_postpone_allowed_channels': {
'default': [],
'type': list,
'form_class': forms.MultipleChoiceField,
'form_kwargs': dict(
label=_('Allow postponed payment choice for sales channels'),
help_text=_("If postponed payment is allowed on a sales channel, customers can complete their order without "
"selecting a payment method. This is useful whenever orders are not created by the same "
"person who is making the payment."),
widget=forms.CheckboxSelectMultiple,
choices=[],
)
},
'presale_start_show_date': { 'presale_start_show_date': {
'default': 'True', 'default': 'True',
'type': bool, 'type': bool,
@@ -1320,7 +1307,6 @@ DEFAULTS = {
'invoice_generate_only_business': { 'invoice_generate_only_business': {
'default': 'False', 'default': 'False',
'type': bool, 'type': bool,
'write_permission': 'event.settings.invoicing:write',
'form_class': forms.BooleanField, 'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField, 'serializer_class': serializers.BooleanField,
'form_kwargs': dict( 'form_kwargs': dict(
@@ -1944,6 +1930,8 @@ DEFAULTS = {
'serializer_class': serializers.BooleanField, 'serializer_class': serializers.BooleanField,
'form_kwargs': dict( 'form_kwargs': dict(
label=_("Hide all unavailable dates from calendar or list views"), label=_("Hide all unavailable dates from calendar or list views"),
help_text=_("This option currently only affects the calendar of this event series, not the organizer-wide "
"calendar.")
) )
}, },
'event_calendar_future_only': { 'event_calendar_future_only': {
@@ -2315,27 +2303,25 @@ DEFAULTS = {
}, },
'contact_url': { 'contact_url': {
'default': None, 'default': None,
'type': LazyI18nString, 'type': str,
'form_class': I18nURLFormField, 'serializer_class': serializers.URLField,
'form_class': forms.URLField,
'form_kwargs': dict( 'form_kwargs': dict(
label=_("Contact URL"), label=_("Contact URL"),
help_text=_("If you set this, the footer contact link will point here instead of using the email address above. " help_text=_("If you set this, the footer contact link will point here instead of using the email address above. "
"Please note that you still need to add a contact email address that will be shared with all emails you send."), "Please note that you still need to add a contact email address that will be shared with all emails you send.")
widget=I18nTextInput, )
),
'serializer_class': I18nURLField,
}, },
'imprint_url': { 'imprint_url': {
'default': None, 'default': None,
'type': LazyI18nString, 'type': str,
'form_class': I18nURLFormField, 'form_class': forms.URLField,
'form_kwargs': dict( 'form_kwargs': dict(
label=_("Imprint URL"), label=_("Imprint URL"),
help_text=_("This should point e.g. to a part of your website that has your contact details and legal " help_text=_("This should point e.g. to a part of your website that has your contact details and legal "
"information."), "information."),
widget=I18nTextInput,
), ),
'serializer_class': I18nURLField, 'serializer_class': serializers.URLField,
}, },
'privacy_url': { 'privacy_url': {
'default': None, 'default': None,
@@ -3768,6 +3754,10 @@ Your {organizer} team""")) # noqa: W291
'default': "7B227073704964223A2239373943394538343346343131343044463144313834343232393232313734313034353044314339464446394437384337313531303944334643463542433731222C2276657273696F6E223A312C22637265617465644F6E223A313536363233343735303036312C227369676E6174757265223A22333038303036303932613836343838366637306430313037303261303830333038303032303130313331306633303064303630393630383634383031363530333034303230313035303033303830303630393261383634383836663730643031303730313030303061303830333038323033653333303832303338386130303330323031303230323038346333303431343935313964353433363330306130363038326138363438636533643034303330323330376133313265333032633036303335353034303330633235343137303730366336353230343137303730366336393633363137343639366636653230343936653734363536373732363137343639366636653230343334313230326432303437333333313236333032343036303335353034306230633164343137303730366336353230343336353732373436393636363936333631373436393666366532303431373537343638366637323639373437393331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333031653137306433313339333033353331333833303331333333323335333735613137306433323334333033353331333633303331333333323335333735613330356633313235333032333036303335353034303330633163363536333633326437333664373032643632373236663662363537323264373336393637366535663535343333343264353035323466343433313134333031323036303335353034306230633062363934663533323035333739373337343635366437333331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333035393330313330363037326138363438636533643032303130363038326138363438636533643033303130373033343230303034633231353737656465626436633762323231386636386464373039306131323138646337623062643666326332383364383436303935643934616634613534313162383334323065643831316633343037653833333331663163353463336637656233323230643662616435643465666634393238393839336537633066313361333832303231313330383230323064333030633036303335353164313330313031666630343032333030303330316630363033353531643233303431383330313638303134323366323439633434663933653465663237653663346636323836633366613262626664326534623330343530363038326230363031303530353037303130313034333933303337333033353036303832623036303130353035303733303031383632393638373437343730336132663266366636333733373032653631373037303663363532653633366636643266366636333733373033303334326436313730373036633635363136393633363133333330333233303832303131643036303335353164323030343832303131343330383230313130333038323031306330363039326138363438383666373633363430353031333038316665333038316333303630383262303630313035303530373032303233303831623630633831623335323635366336393631366536333635323036663665323037343638363937333230363336353732373436393636363936333631373436353230363237393230363136653739323037303631373237343739323036313733373337353664363537333230363136333633363537303734363136653633363532303666363632303734363836353230373436383635366532303631373037303663363936333631363236633635323037333734363136653634363137323634323037343635373236643733323036313665363432303633366636653634363937343639366636653733323036663636323037353733363532633230363336353732373436393636363936333631373436353230373036663663363936333739323036313665363432303633363537323734363936363639363336313734363936663665323037303732363136333734363936333635323037333734363137343635366436353665373437333265333033363036303832623036303130353035303730323031313632613638373437343730336132663266373737373737326536313730373036633635326536333666366432663633363537323734363936363639363336313734363536313735373436383666373236393734373932663330333430363033353531643166303432643330326233303239613032376130323538363233363837343734373033613266326636333732366332653631373037303663363532653633366636643266363137303730366336353631363936333631333332653633373236633330316430363033353531643065303431363034313439343537646236666435373438313836383938393736326637653537383530376537396235383234333030653036303335353164306630313031666630343034303330323037383033303066303630393261383634383836663736333634303631643034303230353030333030613036303832613836343863653364303430333032303334393030333034363032323130306265303935373166653731653165373335623535653561666163623463373266656234343566333031383532323263373235313030326236316562643666353530323231303064313862333530613564643664643665623137343630333562313165623263653837636661336536616636636264383338303839306463383263646461613633333038323032656533303832303237356130303330323031303230323038343936643266626633613938646139373330306130363038326138363438636533643034303330323330363733313162333031393036303335353034303330633132343137303730366336353230353236663666373432303433343132303264323034373333333132363330323430363033353530343062306331643431373037303663363532303433363537323734363936363639363336313734363936663665323034313735373436383666373236393734373933313133333031313036303335353034306130633061343137303730366336353230343936653633326533313Line truncated 'default': "7B227073704964223A2239373943394538343346343131343044463144313834343232393232313734313034353044314339464446394437384337313531303944334643463542433731222C2276657273696F6E223A312C22637265617465644F6E223A313536363233343735303036312C227369676E6174757265223A22333038303036303932613836343838366637306430313037303261303830333038303032303130313331306633303064303630393630383634383031363530333034303230313035303033303830303630393261383634383836663730643031303730313030303061303830333038323033653333303832303338386130303330323031303230323038346333303431343935313964353433363330306130363038326138363438636533643034303330323330376133313265333032633036303335353034303330633235343137303730366336353230343137303730366336393633363137343639366636653230343936653734363536373732363137343639366636653230343334313230326432303437333333313236333032343036303335353034306230633164343137303730366336353230343336353732373436393636363936333631373436393666366532303431373537343638366637323639373437393331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333031653137306433313339333033353331333833303331333333323335333735613137306433323334333033353331333633303331333333323335333735613330356633313235333032333036303335353034303330633163363536333633326437333664373032643632373236663662363537323264373336393637366535663535343333343264353035323466343433313134333031323036303335353034306230633062363934663533323035333739373337343635366437333331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333035393330313330363037326138363438636533643032303130363038326138363438636533643033303130373033343230303034633231353737656465626436633762323231386636386464373039306131323138646337623062643666326332383364383436303935643934616634613534313162383334323065643831316633343037653833333331663163353463336637656233323230643662616435643465666634393238393839336537633066313361333832303231313330383230323064333030633036303335353164313330313031666630343032333030303330316630363033353531643233303431383330313638303134323366323439633434663933653465663237653663346636323836633366613262626664326534623330343530363038326230363031303530353037303130313034333933303337333033353036303832623036303130353035303733303031383632393638373437343730336132663266366636333733373032653631373037303663363532653633366636643266366636333733373033303334326436313730373036633635363136393633363133333330333233303832303131643036303335353164323030343832303131343330383230313130333038323031306330363039326138363438383666373633363430353031333038316665333038316333303630383262303630313035303530373032303233303831623630633831623335323635366336393631366536333635323036663665323037343638363937333230363336353732373436393636363936333631373436353230363237393230363136653739323037303631373237343739323036313733373337353664363537333230363136333633363537303734363136653633363532303666363632303734363836353230373436383635366532303631373037303663363936333631363236633635323037333734363136653634363137323634323037343635373236643733323036313665363432303633366636653634363937343639366636653733323036663636323037353733363532633230363336353732373436393636363936333631373436353230373036663663363936333739323036313665363432303633363537323734363936363639363336313734363936663665323037303732363136333734363936333635323037333734363137343635366436353665373437333265333033363036303832623036303130353035303730323031313632613638373437343730336132663266373737373737326536313730373036633635326536333666366432663633363537323734363936363639363336313734363536313735373436383666373236393734373932663330333430363033353531643166303432643330326233303239613032376130323538363233363837343734373033613266326636333732366332653631373037303663363532653633366636643266363137303730366336353631363936333631333332653633373236633330316430363033353531643065303431363034313439343537646236666435373438313836383938393736326637653537383530376537396235383234333030653036303335353164306630313031666630343034303330323037383033303066303630393261383634383836663736333634303631643034303230353030333030613036303832613836343863653364303430333032303334393030333034363032323130306265303935373166653731653165373335623535653561666163623463373266656234343566333031383532323263373235313030326236316562643666353530323231303064313862333530613564643664643665623137343630333562313165623263653837636661336536616636636264383338303839306463383263646461613633333038323032656533303832303237356130303330323031303230323038343936643266626633613938646139373330306130363038326138363438636533643034303330323330363733313162333031393036303335353034303330633132343137303730366336353230353236663666373432303433343132303264323034373333333132363330323430363033353530343062306331643431373037303663363532303433363537323734363936363639363336313734363936663665323034313735373436383666373236393734373933313133333031313036303335353034306130633061343137303730366336353230343936653633326533313Line truncated
'type': str, 'type': str,
}, },
'widget_vite_origins': {
'default': '',
'type': str,
},
} }
PERSON_NAME_TITLE_GROUPS = OrderedDict([ PERSON_NAME_TITLE_GROUPS = OrderedDict([
('english_common', (_('Most common English titles'), ( ('english_common', (_('Most common English titles'), (
+10 -22
View File
@@ -50,8 +50,8 @@ from pretix.api.serializers.order import (
from pretix.api.serializers.waitinglist import WaitingListSerializer from pretix.api.serializers.waitinglist import WaitingListSerializer
from pretix.base.i18n import LazyLocaleException from pretix.base.i18n import LazyLocaleException
from pretix.base.models import ( from pretix.base.models import (
CachedCombinedTicket, CachedTicket, Event, Invoice, InvoiceAddress, CachedCombinedTicket, CachedTicket, Event, InvoiceAddress, OrderPayment,
OrderPayment, OrderPosition, OrderRefund, OutgoingMail, QuestionAnswer, OrderPosition, OrderRefund, OutgoingMail, QuestionAnswer,
) )
from pretix.base.services.invoices import invoice_pdf_task from pretix.base.services.invoices import invoice_pdf_task
from pretix.base.signals import register_data_shredders from pretix.base.signals import register_data_shredders
@@ -598,30 +598,18 @@ class InvoiceShredder(BaseDataShredder):
def shred_data(self, progress_callback=None): def shred_data(self, progress_callback=None):
qs_i = self.event.invoices.filter(shredded=False) qs_i = self.event.invoices.filter(shredded=False)
total = qs_i.count() total = qs_i.count()
ignore_fields = (
'prefix', 'invoice_no', 'full_invoice_no', 'invoice_from', 'invoice_from_name', 'invoice_from_zipcode',
'invoice_from_city', 'invoice_from_state', 'invoice_from_country', 'invoice_from_tax_id',
'invoice_from_vat_id', 'locale', 'payment_provider_stamp', 'footer_text', 'foreign_currency_display',
'foreign_currency_source', 'transmission_type', 'transmission_provider', 'transmission_status',
)
for i in _progress_helper(qs_i, progress_callback, 0, total): for i in _progress_helper(qs_i, progress_callback, 0, total):
if i.file: if i.file:
i.file.delete() i.file.delete()
i.shredded = True i.shredded = True
i.introductory_text = "█"
for f in Invoice._meta.fields: i.additional_text = "█"
if f.name in ignore_fields: i.invoice_to = "█"
continue i.payment_provider_text = "█"
val = getattr(i, f.name, None) i.transmission_info = {"_shredded": True}
if val and isinstance(val, str): i.save()
setattr(i, f.name, "█") i.lines.update(description="█")
elif val and isinstance(val, list): # jsonfield
setattr(i, f.name, [])
elif val and isinstance(val, dict): # jsonfield
setattr(i, f.name, {"_shredded": True})
i.save()
i.lines.update(description="█", attendee_name="█")
class CachedTicketShredder(BaseDataShredder): class CachedTicketShredder(BaseDataShredder):
+6 -17
View File
@@ -605,14 +605,15 @@ subclass of pretix.base.ticketoutput.BaseTicketOutput
As with all event-plugin signals, the ``sender`` keyword argument will contain the event. As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
""" """
register_notification_types = GlobalSignal() register_notification_types = EventPluginSignal()
""" """
This signal is sent out to get all known notification types. Receivers should return an This signal is sent out to get all known notification types. Receivers should return an
instance of a subclass of pretix.base.notifications.NotificationType or a list of such instance of a subclass of pretix.base.notifications.NotificationType or a list of such
instances. instances.
When called for actually sending notifications, ``sender`` will be the event or organizer, As with all event-plugin signals, the ``sender`` keyword argument will contain the event,
depending on context. however for this signal, the ``sender`` **may also be None** to allow creating the general
notification settings!
""" """
register_event_permission_groups = GlobalSignal() register_event_permission_groups = GlobalSignal()
@@ -627,7 +628,7 @@ This signal is sent out to get all known permissions. Receivers should return an
instance of pretix.base.permissions.PermissionGroup or a list of such instances. instance of pretix.base.permissions.PermissionGroup or a list of such instances.
""" """
event_notification_sent = EventPluginSignal() notification = EventPluginSignal()
""" """
Arguments: ``logentry_id``, ``notification_type`` Arguments: ``logentry_id``, ``notification_type``
@@ -636,15 +637,6 @@ This signal is sent out when a notification is sent.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event. As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
""" """
organizer_notification_sent = OrganizerPluginSignal()
"""
Arguments: ``logentry_id``, ``notification_type``
This signal is sent out when a notification is sent.
As with all organizer-plugin signals, the ``sender`` keyword argument will contain the organizer.
"""
register_sales_channel_types = GlobalSignal() register_sales_channel_types = GlobalSignal()
""" """
This signal is sent out to get all known sales channels types. Receivers should return an This signal is sent out to get all known sales channels types. Receivers should return an
@@ -1199,14 +1191,11 @@ The ``sender`` keyword argument will contain the organizer.
customer_signed_in = OrganizerPluginSignal(allow_legacy_plugins=True) customer_signed_in = OrganizerPluginSignal(allow_legacy_plugins=True)
""" """
Arguments: ``customer``, ``profile`` Arguments: ``customer``
This signal is sent out every time a customer signs in. The ``customer`` object This signal is sent out every time a customer signs in. The ``customer`` object
is given as the first argument. is given as the first argument.
In case of SSO login, the full claims will be passed in the ``profile`` argument,
e.g. as ``oidc_claims`` for OIDC. Otherwise, ``profile`` will be ``None``.
The ``sender`` keyword argument will contain the organizer. The ``sender`` keyword argument will contain the organizer.
""" """
+23 -52
View File
@@ -20,7 +20,6 @@
# <https://www.gnu.org/licenses/>. # <https://www.gnu.org/licenses/>.
# #
from decimal import ROUND_HALF_UP, Decimal from decimal import ROUND_HALF_UP, Decimal
from typing import Optional
from babel import Locale, UnknownLocaleError from babel import Locale, UnknownLocaleError
from babel.numbers import format_currency from babel.numbers import format_currency
@@ -36,32 +35,32 @@ register = template.Library()
@register.filter("money") @register.filter("money")
def money_filter(value: Optional[Decimal | float | int | str], arg='', hide_currency=False): def money_filter(value: Decimal, arg='', hide_currency=False):
if isinstance(value, (float, int, str)): if isinstance(value, (float, int)):
if value == '':
return value
value = Decimal(value) value = Decimal(value)
if value is None: if value is None:
value = Decimal('0.00') value = Decimal('0.00')
if not isinstance(value, Decimal): if not isinstance(value, Decimal):
if value == '':
return value
raise TypeError("Invalid data type passed to money filter: %r" % type(value)) raise TypeError("Invalid data type passed to money filter: %r" % type(value))
if not arg: if not arg:
raise ValueError("No currency passed.") raise ValueError("No currency passed.")
arg = arg.upper() arg = arg.upper()
if value.normalize().as_tuple().exponent < -9: places = settings.CURRENCY_PLACES.get(arg, 2)
# Heuristic: It's unlikely we'll ever see values of less than 0.000000001 in any currency. Therefore, if we rounded = value.quantize(Decimal('1') / 10 ** places, ROUND_HALF_UP)
# do see them, we very likely deal with a floating point error. This happens mostly in dev mode when computations if places < 2 and rounded != value:
# are made in SQLite, which uses REAL precision, but it can also happen when we naively pass a float from Python # We display decimal places even if we shouldn't for this currency if rounding
# land to this filter (even though it should not happen). # would make the numbers incorrect. If this branch executes, it's likely a bug in
value = value.quantize(Decimal('1e-9'), ROUND_HALF_UP).normalize() # pretix, but we won't show wrong numbers!
if hide_currency:
currency_places = settings.CURRENCY_PLACES.get(arg, 2) return floatformat(value, "2g")
required_places = -value.normalize().as_tuple().exponent else:
render_places = max(currency_places, required_places) return '{} {}'.format(arg, floatformat(value, "2g"))
if hide_currency: if hide_currency:
return floatformat(value, f"{render_places}g") return floatformat(value, f"{places}g")
try: try:
locale = Locale(get_babel_locale()) locale = Locale(get_babel_locale())
@@ -69,29 +68,14 @@ def money_filter(value: Optional[Decimal | float | int | str], arg='', hide_curr
locale = "en" locale = "en"
try: try:
return format_currency( return format_currency(value, arg, locale=locale)
value,
arg,
locale=locale,
# We only allow Babel to restrict the digits to the digits defined by the currency if this does not remove any
# precision in case we have sub-currency precision (which we shouldn't have in most places, but it's still
# better than showing wrong data). Note: Weird precision effects can occur after in-database arithmetic
# on SQLite, since SQLite does not have fixed-decimal computation.
currency_digits=currency_places >= required_places,
decimal_quantization=currency_places >= required_places,
)
except: except:
return '{} {}'.format(arg, floatformat(value, f"{render_places}g")) return '{} {}'.format(arg, floatformat(value, f"{places}g"))
@register.filter("money_without_currency")
def money_filter_without_currency(value: Optional[Decimal | float | int | str], arg=''):
return money_filter(value, arg, hide_currency=True)
@register.filter("money_numberfield") @register.filter("money_numberfield")
def money_numberfield_filter(value: Optional[Decimal | float | int | str], arg=''): def money_numberfield_filter(value: Decimal, arg=''):
if isinstance(value, (float, int, str)): if isinstance(value, (float, int)):
value = Decimal(value) value = Decimal(value)
if not isinstance(value, Decimal): if not isinstance(value, Decimal):
raise TypeError("Invalid data type passed to money filter: %r" % type(value)) raise TypeError("Invalid data type passed to money filter: %r" % type(value))
@@ -103,28 +87,15 @@ def money_numberfield_filter(value: Optional[Decimal | float | int | str], arg='
@register.filter(is_safe=True) @register.filter(is_safe=True)
def tax_rate_format(number: Optional[Decimal | float | int | str]): def tax_rate_format(number):
""" """
Display a Decimal to its significant decimal places, used for tax rates. Display a Decimal to its significant decimal places, used for tax rates.
""" """
if isinstance(number, (float, int, str)): assert isinstance(number, Decimal)
if number == '':
return number
number = Decimal(number)
if number is None:
number = Decimal('0.00')
if not isinstance(number, Decimal):
raise TypeError("Invalid data type passed to tax rate format filter: %r" % type(number))
if number.normalize().as_tuple().exponent < -9:
# Heuristic: It's unlikely we'll ever see values of less than 0.000000001 in any currency. Therefore, if we
# do see them, we very likely deal with a floating point error. This happens mostly in dev mode when computations
# are made in SQLite, which uses REAL precision, but it can also happen when we naively pass a float from Python
# land to this filter (even though it should not happen).
number = number.quantize(Decimal('1e-9'), ROUND_HALF_UP).normalize()
return mark_safe( return mark_safe(
formats.number_format( formats.number_format(
number, number.normalize(),
-number.normalize().as_tuple().exponent, -number.as_tuple().exponent,
use_l10n=True, use_l10n=True,
force_grouping=False, force_grouping=False,
) )
+15 -43
View File
@@ -340,14 +340,7 @@ class LinkifyAndCleanExtension(Extension):
) )
class SnippetExtension(markdown.extensions.Extension): def markdown_compile_email(source, allowed_tags=None, allowed_attributes=ALLOWED_ATTRIBUTES, snippet=False, context=None):
def extendMarkdown(self, md, *args, **kwargs):
md.parser.blockprocessors.deregister('olist')
md.parser.blockprocessors.deregister('ulist')
md.parser.blockprocessors.deregister('quote')
def _get_email_markdown(allowed_tags=None, allowed_attributes=ALLOWED_ATTRIBUTES, snippet=False, context=None):
if allowed_tags is None: if allowed_tags is None:
allowed_tags = ALLOWED_TAGS_SNIPPET if snippet else ALLOWED_TAGS allowed_tags = ALLOWED_TAGS_SNIPPET if snippet else ALLOWED_TAGS
@@ -388,16 +381,20 @@ def _get_email_markdown(allowed_tags=None, allowed_attributes=ALLOWED_ATTRIBUTES
] ]
if snippet: if snippet:
exts.append(SnippetExtension()) exts.append(SnippetExtension())
return markdown.markdown(
return markdown.Markdown(extensions=exts) source,
extensions=exts
)
def markdown_compile_email(source, allowed_tags=None, allowed_attributes=ALLOWED_ATTRIBUTES, snippet=False, context=None): class SnippetExtension(markdown.extensions.Extension):
md = _get_email_markdown(allowed_tags, allowed_attributes, snippet, context) def extendMarkdown(self, md, *args, **kwargs):
return md.convert(source) md.parser.blockprocessors.deregister('olist')
md.parser.blockprocessors.deregister('ulist')
md.parser.blockprocessors.deregister('quote')
def _get_markdown(linker, snippet=False): def markdown_compile(source, linker, snippet=False):
tags = ALLOWED_TAGS_SNIPPET if snippet else ALLOWED_TAGS tags = ALLOWED_TAGS_SNIPPET if snippet else ALLOWED_TAGS
exts = [ exts = [
'markdown.extensions.sane_lists', 'markdown.extensions.sane_lists',
@@ -412,13 +409,10 @@ def _get_markdown(linker, snippet=False):
] ]
if snippet: if snippet:
exts.append(SnippetExtension()) exts.append(SnippetExtension())
return markdown.markdown(
return markdown.Markdown(extensions=exts) source,
extensions=exts
)
def markdown_compile(source, linker, snippet=False):
md = _get_markdown(linker, snippet)
return md.convert(source)
@register.filter @register.filter
@@ -451,25 +445,3 @@ def rich_text_snippet(text: str, **kwargs):
) )
body_md = markdown_compile(text, linker, snippet=True) body_md = markdown_compile(text, linker, snippet=True)
return mark_safe(body_md) return mark_safe(body_md)
def _md_escape(md: markdown.Markdown, plain: str):
escaped_chars = md.ESCAPED_CHARS
translation_map = {ord(x): f"\\{x}" for x in escaped_chars}
return plain.translate(translation_map)
def markdown_escape(plain: str) -> str:
"""
Escape formatting characters in markdown with backslash using the default markdown renderer config.
"""
md = _get_markdown(bleach.Linker())
return _md_escape(md, plain)
def markdown_email_escape(plain: str) -> str:
"""
Escape formatting characters in markdown with backslash using the default email markdown renderer config.
"""
md = _get_email_markdown(None, False)
return _md_escape(md, plain)
-17
View File
@@ -22,7 +22,6 @@
from django import template from django import template
from pretix.helpers.safedownload import get_token from pretix.helpers.safedownload import get_token
from pretix.multidomain.urlreverse import eventreverse
from ..views.redirect import safelink as sl from ..views.redirect import safelink as sl
@@ -37,19 +36,3 @@ def safelink(url):
@register.simple_tag @register.simple_tag
def answer_token(request, answer): def answer_token(request, answer):
return get_token(request, answer) return get_token(request, answer)
@register.simple_tag
def answer_url(request, answer):
if answer.file:
if answer.associated_order:
url = eventreverse(answer.associated_order.event, 'presale:event.download.answer', kwargs={
'answer': answer.pk,
})
else:
url = eventreverse(request.event, 'presale:event.cart.download.answer', kwargs={
'answer': answer.pk,
})
return url + "?token=" + get_token(request, answer)
return ""
+1 -1
View File
@@ -23,10 +23,10 @@ import json
import logging import logging
import pathlib import pathlib
import re import re
from importlib import metadata
from urllib.parse import urljoin from urllib.parse import urljoin
from urllib.request import urlopen from urllib.request import urlopen
import importlib_metadata as metadata
from django import template from django import template
from django.conf import settings from django.conf import settings
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
+2 -2
View File
@@ -21,8 +21,8 @@
# #
import contextvars import contextvars
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime
from dateutil.parser import parse
from django.utils.timezone import now from django.utils.timezone import now
from pretix.base.auth import has_event_access_permission from pretix.base.auth import has_event_access_permission
@@ -34,7 +34,7 @@ timemachine_now_var = contextvars.ContextVar('timemachine_now', default=None)
def time_machine_now_assigned_from_request(request): def time_machine_now_assigned_from_request(request):
if hasattr(request, 'event') and f'timemachine_now_dt:{request.event.pk}' in request.session and \ if hasattr(request, 'event') and f'timemachine_now_dt:{request.event.pk}' in request.session and \
request.event.testmode and has_event_access_permission(request): request.event.testmode and has_event_access_permission(request):
request.now_dt = datetime.fromisoformat(request.session[f'timemachine_now_dt:{request.event.pk}']) request.now_dt = parse(request.session[f'timemachine_now_dt:{request.event.pk}'])
request.now_dt_is_fake = True request.now_dt_is_fake = True
else: else:
request.now_dt = now() request.now_dt = now()
+2 -7
View File
@@ -19,7 +19,6 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see # 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/>. # <https://www.gnu.org/licenses/>.
# #
from django.conf import settings
from django.http import ( from django.http import (
HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError,
) )
@@ -28,6 +27,7 @@ from django.template import TemplateDoesNotExist, loader
from django.template.loader import get_template from django.template.loader import get_template
from django.utils.functional import Promise from django.utils.functional import Promise
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from sentry_sdk import last_event_id
from pretix.base.i18n import language from pretix.base.i18n import language
from pretix.base.middleware import get_language_from_request from pretix.base.middleware import get_language_from_request
@@ -106,14 +106,9 @@ def server_error(request):
template = loader.get_template('500.html') template = loader.get_template('500.html')
except TemplateDoesNotExist: except TemplateDoesNotExist:
return HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html') return HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html')
if settings.SENTRY_ENABLED:
from sentry_sdk import last_event_id
sentry_id = last_event_id()
else:
sentry_id = None
r = HttpResponseServerError(template.render({ r = HttpResponseServerError(template.render({
'request': request, 'request': request,
'sentry_event_id': sentry_id, 'sentry_event_id': last_event_id(),
})) }))
r.xframe_options_exempt = True r.xframe_options_exempt = True
return r return r
+2 -16
View File
@@ -28,6 +28,7 @@ from zoneinfo import ZoneInfo
import celery.exceptions import celery.exceptions
from celery import states from celery import states
from celery.result import AsyncResult
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ( from django.core.exceptions import (
@@ -40,7 +41,6 @@ from django.shortcuts import render
from django.test import RequestFactory from django.test import RequestFactory
from django.utils import timezone, translation from django.utils import timezone, translation
from django.utils.datastructures import MultiValueDict from django.utils.datastructures import MultiValueDict
from django.utils.functional import classproperty
from django.utils.timezone import get_current_timezone, now from django.utils.timezone import get_current_timezone, now
from django.utils.translation import get_language, gettext as _ from django.utils.translation import get_language, gettext as _
from django.views import View from django.views import View
@@ -50,7 +50,6 @@ from redis import ResponseError
from pretix.base.models import CachedFile, User from pretix.base.models import CachedFile, User
from pretix.base.services.tasks import ProfiledEventTask from pretix.base.services.tasks import ProfiledEventTask
from pretix.celery_app import app from pretix.celery_app import app
from pretix.helpers.celery import get_task_result
from pretix.helpers.http import redirect_to_url from pretix.helpers.http import redirect_to_url
logger = logging.getLogger('pretix.base.tasks') logger = logging.getLogger('pretix.base.tasks')
@@ -62,10 +61,6 @@ class AsyncMixin:
error_url = None error_url = None
known_errortypes = [] known_errortypes = []
@classproperty
def task(self):
raise NotImplementedError("Needs to be supplied by child class")
def get_success_url(self, value): def get_success_url(self, value):
return self.success_url return self.success_url
@@ -142,8 +137,7 @@ class AsyncMixin:
raise BadRequest("No async_id given") raise BadRequest("No async_id given")
if not RE_ASYNC_ID.match(request.GET.get('async_id')): if not RE_ASYNC_ID.match(request.GET.get('async_id')):
raise BadRequest("Invalid async_id given") raise BadRequest("Invalid async_id given")
res = AsyncResult(request.GET.get('async_id'))
res = get_task_result(request.GET.get('async_id'), task_name=self.task)
if 'ajax' in self.request.GET: if 'ajax' in self.request.GET:
return JsonResponse(self._return_ajax_result(res, timeout=0.25)) return JsonResponse(self._return_ajax_result(res, timeout=0.25))
else: else:
@@ -323,10 +317,6 @@ class AsyncFormView(AsyncMixin, FormView):
throws=cls.expected_exceptions throws=cls.expected_exceptions
)(async_execute) )(async_execute)
@classproperty
def task(cls): # noqa
return cls.async_execute
def async_form_valid(self, task, form): def async_form_valid(self, task, form):
pass pass
@@ -460,10 +450,6 @@ class AsyncPostView(AsyncMixin, View):
def async_post(self, request, *args, **kwargs): def async_post(self, request, *args, **kwargs):
pass pass
@classproperty
def task(cls): # noqa
return cls.async_execute
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if 'async_id' in request.GET and settings.HAS_CELERY: if 'async_id' in request.GET and settings.HAS_CELERY:
return self.get_result(request) return self.get_result(request)
-16
View File
@@ -20,7 +20,6 @@
# <https://www.gnu.org/licenses/>. # <https://www.gnu.org/licenses/>.
# #
import logging import logging
import multiprocessing
import os import os
from celery import Celery, signals from celery import Celery, signals
@@ -55,21 +54,6 @@ def on_task_received(sender, request, **kwargs):
logger.info(f"Task {request.id} has trace {trace}") logger.info(f"Task {request.id} has trace {trace}")
@receiver(signals.after_setup_task_logger)
def on_after_setup_task_logger(sender, logger, loglevel, logfile, format, colorize, **kwargs):
# This hack seems to be required to get celery to log internal events from eg billiard/pool.py such as
# "worker killed because it used too much memory"
# You can test that it is working by starting a celery worker with a low value like
# --max-memory-per-child 300000
# and then trigger a task. Result should look like this:
# [2026-09-23 10:42:26,234: WARNING/ForkPoolWorker-16]: [???:???] child process exiting after exceeding memory limit (394540KiB / 300000KiB)
# The ???:??? are likely because by copying the handlers, we are also copying the format, but I was unable to find
# a better compatible way.
multi_logger = multiprocessing.get_logger()
multi_logger.setLevel(logging.WARNING)
multi_logger.handlers = logger.handlers
@receiver(signals.task_prerun) @receiver(signals.task_prerun)
def on_task_prerun(sender, task_id, task, **kwargs): def on_task_prerun(sender, task_id, task, **kwargs):
from pretix.helpers.logs import local from pretix.helpers.logs import local
+1 -12
View File
@@ -172,9 +172,7 @@ class CachedFileInput(forms.ClearableFileInput):
from ...base.models import CachedFile from ...base.models import CachedFile
v = super().value_from_datadict(data, files, name) v = super().value_from_datadict(data, files, name)
if v is None and data.get(name + '-cachedfile'): # An explicit "[x] clear" would be False, not None if v is None and data.get(name + '-cachedfile'): # An explicit "[x] clear" would be False, not None
v = CachedFile.objects.filter(id=data[name + '-cachedfile'], web_download=True).first() return CachedFile.objects.filter(id=data[name + '-cachedfile']).first()
if not v.allowed_for_session(self.request):
v = None
return v return v
def get_context(self, name, value, attrs): def get_context(self, name, value, attrs):
@@ -246,11 +244,6 @@ class ExtFileField(ExtValidationMixin, SizeFileField):
class CachedFileField(ExtFileField): class CachedFileField(ExtFileField):
widget = CachedFileInput widget = CachedFileInput
def __init__(self, *args, **kwargs):
self.request = kwargs.pop("request", None)
super().__init__(*args, **kwargs)
self.widget.request = self.request
def to_python(self, data): def to_python(self, data):
from ...base.models import CachedFile from ...base.models import CachedFile
@@ -278,8 +271,6 @@ class CachedFileField(ExtFileField):
filename=data.name, filename=data.name,
type=data.content_type, type=data.content_type,
) )
if self.request:
cf.bind_to_session(self.request) # no salt because we want direct web access
cf.file.save(data.name, data.file) cf.file.save(data.name, data.file)
cf.save() cf.save()
data._uploaded_to = cf data._uploaded_to = cf
@@ -303,8 +294,6 @@ class CachedFileField(ExtFileField):
filename=data.name, filename=data.name,
type=data.content_type, type=data.content_type,
) )
if self.request:
cf.bind_to_session(self.request) # no salt because we want direct web access
cf.file.save(data.name, data.file) cf.file.save(data.name, data.file)
cf.save() cf.save()
data._uploaded_to = cf data._uploaded_to = cf
+10 -23
View File
@@ -400,10 +400,10 @@ class EventMetaValueForm(forms.ModelForm):
if self.disabled: if self.disabled:
self.fields['value'].widget.attrs['readonly'] = 'readonly' self.fields['value'].widget.attrs['readonly'] = 'readonly'
def clean_value(self): def clean_slug(self):
if self.disabled: if self.disabled:
return self.instance.value if self.instance else None return self.instance.value if self.instance else None
return self.cleaned_data['value'] return self.cleaned_data['slug']
class Meta: class Meta:
model = EventMetaValue model = EventMetaValue
@@ -838,10 +838,9 @@ class CancelSettingsForm(SettingsForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if self.obj.settings.giftcard_expiry_years is not None: if self.obj.settings.giftcard_expiry_years is not None:
self.fields['cancel_allow_user_paid_refund_as_giftcard'].help_text = format_html( self.fields['cancel_allow_user_paid_refund_as_giftcard'].help_text = gettext(
gettext('You have configured gift cards to be valid {} years plus the year the gift card is issued in.'), 'You have configured gift cards to be valid {} years plus the year the gift card is issued in.'
self.obj.settings.giftcard_expiry_years ).format(self.obj.settings.giftcard_expiry_years)
)
class PaymentSettingsForm(EventSettingsValidationMixin, SettingsForm): class PaymentSettingsForm(EventSettingsValidationMixin, SettingsForm):
@@ -856,21 +855,14 @@ class PaymentSettingsForm(EventSettingsValidationMixin, SettingsForm):
'payment_term_accept_late', 'payment_term_accept_late',
'payment_pending_hidden', 'payment_pending_hidden',
'payment_explanation', 'payment_explanation',
'payment_choice_postpone_allowed_channels',
'tax_rule_payment', 'tax_rule_payment',
] ]
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
channels = list(self.obj.organizer.sales_channels.all())
self.fields['payment_choice_postpone_allowed_channels'].choices = [
(c.identifier, c.label) for c in channels
if c.type_instance.payment_restrictions_supported
]
self.term_channel_fields = {} self.term_channel_fields = {}
for c in channels: for c in self.obj.organizer.sales_channels.all():
if c.type_instance.payment_restrictions_supported and c.identifier != "web": if c.type_instance.payment_restrictions_supported and c.identifier != "web":
# At the moment, it seems sufficient to allow this for the same channel types as other payment settings # At the moment, it seems sufficient to allow this for the same channel types as other payment settings
# We can always introduce more flags later if needed # We can always introduce more flags later if needed
@@ -1636,15 +1628,10 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
self._set_field_placeholders(k, v, rich=k.startswith('mail_text_') and k not in self.plain_rendering) self._set_field_placeholders(k, v, rich=k.startswith('mail_text_') and k not in self.plain_rendering)
for k, v in list(self.fields.items()): for k, v in list(self.fields.items()):
if k.endswith('_attendee'): if k.endswith('_attendee') and not event.settings.attendee_emails_asked:
if not event.settings.attendee_emails_asked: # If we don't ask for attendee emails, we can't send them anything and we don't need to clutter
# If we don't ask for attendee emails, we can't send them anything and we don't need to clutter # the user interface with it
# the user interface with it del self.fields[k]
del self.fields[k]
elif 'subject' in k and k.replace("subject", "send") in self.fields:
v.widget.attrs["data-display-dependency"] = f'#id_{k.replace("subject", "send")}'
elif 'text' in k and k.replace("text", "send") in self.fields:
v.widget.attrs["data-display-dependency"] = f'#id_{k.replace("text", "send")}'
class TicketSettingsForm(SettingsForm): class TicketSettingsForm(SettingsForm):
@@ -105,6 +105,13 @@ class GlobalSettingsForm(SettingsForm):
domain=settings.SITE_URL domain=settings.SITE_URL
) )
)), )),
('widget_vite_origins', forms.CharField(
widget=forms.Textarea(attrs={'rows': '3'}),
required=False,
# Not translated on purpose, this is a temporary feature and contains too many special case words
label="Vite widget origins",
help_text="One origin per line (e.g. https://example.com). Requests from these origins will be served the new vite-based widget.",
))
]) ])
responses = register_global_settings.send(self) responses = register_global_settings.send(self)
for r, response in sorted(responses, key=lambda r: str(r[0])): for r, response in sorted(responses, key=lambda r: str(r[0])):
-11
View File
@@ -1207,11 +1207,6 @@ class ItemAddOnForm(I18nModelForm):
} }
) )
self.fields['addon_category'].widget.choices = self.fields['addon_category'].choices self.fields['addon_category'].widget.choices = self.fields['addon_category'].choices
self.fields['max_count'] = forms.IntegerField(
min_value=1,
label=self.fields['max_count'].label,
widget=forms.NumberInput(attrs={'placeholder': '1'}),
)
class Meta: class Meta:
model = ItemAddOn model = ItemAddOn
@@ -1324,12 +1319,6 @@ class ItemBundleForm(I18nModelForm):
self.fields['itemvar'].choices = choices self.fields['itemvar'].choices = choices
change_decimal_field(self.fields['designated_price'], self.event.currency) change_decimal_field(self.fields['designated_price'], self.event.currency)
self.fields['count'] = forms.IntegerField(
min_value=1,
label=self.fields['count'].label,
widget=forms.NumberInput(attrs={'placeholder': '1'}),
)
def clean(self): def clean(self):
d = super().clean() d = super().clean()
if not self.cleaned_data.get('designated_price'): if not self.cleaned_data.get('designated_price'):
+2 -2
View File
@@ -22,7 +22,7 @@
from django import forms from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.functional import lazy from django.utils.functional import lazy
from django.utils.html import conditional_escape, format_html from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from pretix.base.modelimport_orders import get_order_import_columns from pretix.base.modelimport_orders import get_order_import_columns
@@ -66,7 +66,7 @@ class ProcessForm(forms.Form):
widget=forms.Select( widget=forms.Select(
attrs={'data-static': 'true'} attrs={'data-static': 'true'}
), ),
help_text=conditional_escape(c.help_text or ""), help_text=c.help_text,
) )
def get_columns(self): def get_columns(self):
+20 -22
View File
@@ -38,6 +38,7 @@ from urllib.parse import urlparse
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models import Q
from django.forms import formset_factory, inlineformset_factory from django.forms import formset_factory, inlineformset_factory
from django.forms.utils import ErrorDict from django.forms.utils import ErrorDict
from django.urls import reverse from django.urls import reverse
@@ -69,9 +70,9 @@ from pretix.base.forms.widgets import (
SplitDateTimePickerWidget, format_placeholders_help_text, SplitDateTimePickerWidget, format_placeholders_help_text,
) )
from pretix.base.models import ( from pretix.base.models import (
Customer, Device, Event, EventMetaProperty, Gate, GiftCard, Membership, Customer, Device, Event, EventMetaProperty, Gate, GiftCard,
MembershipType, OrderPosition, Organizer, ReusableMedium, SalesChannel, GiftCardAcceptance, Membership, MembershipType, OrderPosition, Organizer,
Team, ReusableMedium, SalesChannel, Team,
) )
from pretix.base.models.customers import CustomerSSOClient, CustomerSSOProvider from pretix.base.models.customers import CustomerSSOClient, CustomerSSOProvider
from pretix.base.models.organizer import OrganizerFooterLink, TeamQuerySet from pretix.base.models.organizer import OrganizerFooterLink, TeamQuerySet
@@ -363,7 +364,7 @@ class TeamForm(forms.ModelForm):
for opt in pg.options for opt in pg.options
], ],
label=pg.label, label=pg.label,
help_text=conditional_escape(pg.help_text or ""), help_text=pg.help_text,
initial=initial, initial=initial,
widget=forms.RadioSelect, widget=forms.RadioSelect,
) )
@@ -388,7 +389,7 @@ class TeamForm(forms.ModelForm):
for opt in pg.options for opt in pg.options
], ],
label=pg.label, label=pg.label,
help_text=conditional_escape(pg.help_text or ""), help_text=pg.help_text,
initial=initial, initial=initial,
widget=forms.RadioSelect, widget=forms.RadioSelect,
) )
@@ -893,7 +894,15 @@ class GiftCardCreateForm(forms.ModelForm):
def clean_secret(self): def clean_secret(self):
s = self.cleaned_data['secret'] s = self.cleaned_data['secret']
if self.organizer.accepted_gift_cards.filter(secret__iexact=s).exists(): if GiftCard.objects.filter(
secret__iexact=s
).filter(
Q(issuer=self.organizer) |
Q(issuer__in=GiftCardAcceptance.objects.filter(
acceptor=self.organizer,
active=True,
).values_list('issuer', flat=True))
).exists():
raise ValidationError( raise ValidationError(
_('A gift card with the same secret already exists in your or an affiliated organizer account.') _('A gift card with the same secret already exists in your or an affiliated organizer account.')
) )
@@ -1189,7 +1198,7 @@ OrganizerFooterLinkFormset = inlineformset_factory(
class SSOProviderForm(I18nModelForm): class SSOProviderForm(I18nModelForm):
config_oidc_base_url = forms.URLField( config_oidc_base_url = forms.URLField(
label=pgettext_lazy('sso_oidc', 'Base URL / issuer'), label=pgettext_lazy('sso_oidc', 'Base URL'),
required=False, required=False,
) )
config_oidc_client_id = forms.CharField( config_oidc_client_id = forms.CharField(
@@ -1286,14 +1295,6 @@ class SSOProviderForm(I18nModelForm):
class SSOClientForm(I18nModelForm): class SSOClientForm(I18nModelForm):
disp_base_url = forms.CharField(
label=_('Base URL / issuer'),
disabled=True,
)
disp_client_id = forms.CharField(
label=_('Client ID'),
disabled=True,
)
regenerate_client_secret = forms.BooleanField( regenerate_client_secret = forms.BooleanField(
label=_('Invalidate old client secret and generate a new one'), label=_('Invalidate old client secret and generate a new one'),
required=False, required=False,
@@ -1301,8 +1302,7 @@ class SSOClientForm(I18nModelForm):
class Meta: class Meta:
model = CustomerSSOClient model = CustomerSSOClient
fields = ['is_active', 'name', 'disp_base_url', 'disp_client_id', 'regenerate_client_secret', fields = ['is_active', 'name', 'client_id', 'client_type', 'authorization_grant_type', 'redirect_uris',
'client_type', 'authorization_grant_type', 'redirect_uris',
'allowed_scopes', 'require_pkce'] 'allowed_scopes', 'require_pkce']
widgets = { widgets = {
'authorization_grant_type': forms.RadioSelect, 'authorization_grant_type': forms.RadioSelect,
@@ -1317,15 +1317,13 @@ class SSOClientForm(I18nModelForm):
help_text=self.fields['allowed_scopes'].help_text, help_text=self.fields['allowed_scopes'].help_text,
required=self.fields['allowed_scopes'].required, required=self.fields['allowed_scopes'].required,
initial=self.fields['allowed_scopes'].initial, initial=self.fields['allowed_scopes'].initial,
choices=[(val, format_html('<code>{}</code> &ndash; {}', val, label)) for val, label in CustomerSSOClient.SCOPE_CHOICES], choices=CustomerSSOClient.SCOPE_CHOICES,
widget=forms.CheckboxSelectMultiple widget=forms.CheckboxSelectMultiple
) )
organizer = kwargs['event']
self.initial['disp_base_url'] = eventreverse_absolute(organizer, 'presale:organizer.index', {}).strip('/')
if self.instance and self.instance.pk: if self.instance and self.instance.pk:
self.initial['disp_client_id'] = self.instance.client_id self.fields['client_id'].disabled = True
else: else:
self.initial['disp_client_id'] = _('(will be generated)') del self.fields['client_id']
del self.fields['regenerate_client_secret'] del self.fields['regenerate_client_secret']
-2
View File
@@ -87,7 +87,6 @@ class RRuleForm(forms.Form):
('1', pgettext_lazy('rrule', 'first')), ('1', pgettext_lazy('rrule', 'first')),
('2', pgettext_lazy('rrule', 'second')), ('2', pgettext_lazy('rrule', 'second')),
('3', pgettext_lazy('rrule', 'third')), ('3', pgettext_lazy('rrule', 'third')),
('4', pgettext_lazy('rrule', 'fourth')),
('-1', pgettext_lazy('rrule', 'last')), ('-1', pgettext_lazy('rrule', 'last')),
], ],
required=False required=False
@@ -135,7 +134,6 @@ class RRuleForm(forms.Form):
('1', pgettext_lazy('rrule', 'first')), ('1', pgettext_lazy('rrule', 'first')),
('2', pgettext_lazy('rrule', 'second')), ('2', pgettext_lazy('rrule', 'second')),
('3', pgettext_lazy('rrule', 'third')), ('3', pgettext_lazy('rrule', 'third')),
('4', pgettext_lazy('rrule', 'fourth')),
('-1', pgettext_lazy('rrule', 'last')), ('-1', pgettext_lazy('rrule', 'last')),
], ],
required=False required=False
+3 -23
View File
@@ -153,7 +153,7 @@ class SubEventBulkEditForm(I18nModelForm):
self.fields[k].widget.is_required = False self.fields[k].widget.is_required = False
self.fields[k].required = False self.fields[k].required = False
for k in ('date_from', 'date_to'): for k in ('date_from', 'date_to', 'date_admission', 'presale_start', 'presale_end'):
self.fields[k + '_day'] = forms.DateField( self.fields[k + '_day'] = forms.DateField(
label=self._meta.model._meta.get_field(k).verbose_name, label=self._meta.model._meta.get_field(k).verbose_name,
help_text=self._meta.model._meta.get_field(k).help_text, help_text=self._meta.model._meta.get_field(k).help_text,
@@ -167,14 +167,6 @@ class SubEventBulkEditForm(I18nModelForm):
required=False, required=False,
) )
for k in ('date_admission', 'presale_start', 'presale_end'):
self.fields[k + '_rel'] = RelativeDateTimeField(
label=self._meta.model._meta.get_field(k).verbose_name,
help_text=self._meta.model._meta.get_field(k).help_text,
required=False,
limit_choices=('event__date_from',),
)
class Meta: class Meta:
model = SubEvent model = SubEvent
localized_fields = '__all__' localized_fields = '__all__'
@@ -255,18 +247,6 @@ class SubEventBulkEditForm(I18nModelForm):
) )
setattr(obj, k.replace('_time', ''), newval) setattr(obj, k.replace('_time', ''), newval)
fields.add(k.replace('_time', '')) fields.add(k.replace('_time', ''))
elif k.endswith('_rel'):
target_key = k[:-4]
for obj in objs:
cval = self.cleaned_data[k]
if cval is None:
newval = None
if not self._meta.model._meta.get_field(target_key).null:
continue
else:
newval = cval.datetime(obj)
setattr(obj, target_key, newval)
fields.add(target_key)
else: else:
fields.add(k) fields.add(k)
for obj in objs: for obj in objs:
@@ -455,10 +435,10 @@ class SubEventMetaValueForm(forms.ModelForm):
if self.disabled: if self.disabled:
self.fields['value'].widget.attrs['readonly'] = 'readonly' self.fields['value'].widget.attrs['readonly'] = 'readonly'
def clean_value(self): def clean_slug(self):
if self.disabled: if self.disabled:
return self.instance.value if self.instance else None return self.instance.value if self.instance else None
return self.cleaned_data['value'] return self.cleaned_data['slug']
class Meta: class Meta:
model = SubEventMetaValue model = SubEventMetaValue
+1 -2
View File
@@ -44,7 +44,6 @@ from django.db.models import Count, F, Max
from django.db.models.functions import Upper from django.db.models.functions import Upper
from django.forms.utils import ErrorDict from django.forms.utils import ErrorDict
from django.urls import reverse from django.urls import reverse
from django.utils.html import escape
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _, pgettext_lazy from django.utils.translation import gettext_lazy as _, pgettext_lazy
from django_scopes.forms import SafeModelChoiceField from django_scopes.forms import SafeModelChoiceField
@@ -177,7 +176,7 @@ class VoucherForm(I18nModelForm):
required=False, required=False,
widget=forms.TextInput(attrs={'data-seat-guid-field': '1'}), widget=forms.TextInput(attrs={'data-seat-guid-field': '1'}),
initial=self.instance.seat.seat_guid if self.instance.seat else '', initial=self.instance.seat.seat_guid if self.instance.seat else '',
help_text=escape(str(self.instance.seat) if self.instance.seat else ''), help_text=str(self.instance.seat) if self.instance.seat else '',
) )
def parse_itemvar(self, data): def parse_itemvar(self, data):
+2 -2
View File
@@ -79,8 +79,8 @@ class WaitingListEntryEditForm(I18nModelForm):
self.fields['name_parts'] = NamePartsFormField( self.fields['name_parts'] = NamePartsFormField(
max_length=255, max_length=255,
required=self.event.settings.waiting_list_names_required, required=self.event.settings.waiting_list_names_required,
scheme=self.event.settings.name_scheme, scheme=self.event.organizer.settings.name_scheme,
titles=self.event.settings.name_scheme_titles, titles=self.event.organizer.settings.name_scheme_titles,
label=_('Name'), label=_('Name'),
) )
else: else:
Loaded 100 of 444 files, more files were not shown because too many files have changed in this diff. Show more