Compare commits

..

1 Commits

Author SHA1 Message Date
Raphael Michel
2b07d00d90 Remove eu_reverse_charge rule 2020-10-30 22:24:55 +01:00
237 changed files with 39456 additions and 76260 deletions

View File

@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.6
RUN apt-get update && \
apt-get install -y --no-install-recommends \
@@ -30,8 +30,7 @@ RUN apt-get update && \
mkdir /data && \
useradd -ms /bin/bash -d /pretix -u 15371 pretixuser && \
echo 'pretixuser ALL=(ALL) NOPASSWD:SETENV: /usr/bin/supervisord' >> /etc/sudoers && \
mkdir /static && \
mkdir /etc/supervisord
mkdir /static
ENV LC_ALL=C.UTF-8 \
DJANGO_SETTINGS_MODULE=production_settings
@@ -48,13 +47,12 @@ RUN pip3 install -U \
-r requirements.txt \
-r requirements/memcached.txt \
-r requirements/mysql.txt \
gunicorn django-extensions ipython && \
-r requirements/redis.txt \
gunicorn && \
rm -rf ~/.cache/pip
COPY deployment/docker/pretix.bash /usr/local/bin/pretix
COPY deployment/docker/supervisord /etc/supervisord
COPY deployment/docker/supervisord.all.conf /etc/supervisord.all.conf
COPY deployment/docker/supervisord.web.conf /etc/supervisord.web.conf
COPY deployment/docker/supervisord.conf /etc/supervisord.conf
COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf
COPY deployment/docker/production_settings.py /pretix/src/production_settings.py
COPY src /pretix/src

View File

@@ -24,8 +24,8 @@ http {
default_type application/octet-stream;
add_header X-Content-Type-Options nosniff;
access_log /dev/stdout private;
error_log /dev/stderr;
access_log /var/log/nginx/access.log private;
error_log /var/log/nginx/error.log;
add_header Referrer-Policy same-origin;
gzip on;

View File

@@ -5,8 +5,6 @@ export DATA_DIR=/data/
export HOME=/pretix
export NUM_WORKERS=$((2 * $(nproc --all)))
AUTOMIGRATE=${AUTOMIGRATE:-yes}
if [ ! -d /data/logs ]; then
mkdir /data/logs;
fi
@@ -18,16 +16,10 @@ if [ "$1" == "cron" ]; then
exec python3 -m pretix runperiodic
fi
if [ "$AUTOMIGRATE" != "skip" ]; then
python3 -m pretix migrate --noinput
fi
python3 -m pretix migrate --noinput
if [ "$1" == "all" ]; then
exec sudo -E /usr/bin/supervisord -n -c /etc/supervisord.all.conf
fi
if [ "$1" == "web" ]; then
exec sudo -E /usr/bin/supervisord -n -c /etc/supervisord.web.conf
exec sudo -E /usr/bin/supervisord -n -c /etc/supervisord.conf
fi
if [ "$1" == "webworker" ]; then
@@ -45,6 +37,10 @@ if [ "$1" == "taskworker" ]; then
exec celery -A pretix.celery_app worker -l info "$@"
fi
if [ "$1" == "shell" ]; then
exec python3 -m pretix shell
fi
if [ "$1" == "upgrade" ]; then
exec python3 -m pretix updatestyles
fi

View File

@@ -1,2 +0,0 @@
[include]
files = /etc/supervisord/*.conf

View File

@@ -0,0 +1,44 @@
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:pretixweb]
command=/usr/local/bin/pretix webworker
autostart=true
autorestart=true
priority=5
user=pretixuser
environment=HOME=/pretix
[program:pretixtask]
command=/usr/local/bin/pretix taskworker
autostart=true
autorestart=true
priority=5
user=pretixuser
[program:nginx]
command=/usr/sbin/nginx
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
[include]
files = /etc/supervisord-*.conf

View File

@@ -1,2 +0,0 @@
[include]
files = /etc/supervisord/base.conf /etc/supervisord/nginx.conf /etc/supervisord/pretixweb.conf

View File

@@ -1,18 +0,0 @@
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
logfile=/dev/stderr
logfile_maxbytes=0
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

View File

@@ -1,11 +0,0 @@
[program:nginx]
command=/usr/sbin/nginx
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View File

@@ -1,10 +0,0 @@
[program:pretixtask]
command=/usr/local/bin/pretix taskworker
autostart=true
autorestart=true
priority=5
user=pretixuser
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View File

@@ -1,11 +0,0 @@
[program:pretixweb]
command=/usr/local/bin/pretix webworker
autostart=true
autorestart=true
priority=5
user=pretixuser
environment=HOME=/pretix
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View File

@@ -23,14 +23,6 @@ The config file may contain the following sections (all settings are optional an
default values). We suggest that you start from the examples given in one of the
installation tutorials.
.. note::
The configuration file is the recommended way to configure pretix. However, you can
also set them through environment variables. In this case, the syntax is
``PRETIX_SECTION_CONFIG``. For example, to configure the setting ``password_reset``
from the ``[pretix]`` section, set ``PRETIX_PRETIX_PASSWORD_RESET=off`` in your
environment.
pretix settings
---------------

View File

@@ -284,24 +284,6 @@ Then, go to that directory and build the image::
You can now use that image ``mypretix`` instead of ``pretix/standalone`` in your service file (see above). Be sure
to re-build your custom image after you pulled ``pretix/standalone`` if you want to perform an update.
Scaling up
----------
If you need to scale to multiple machines, please first read our :ref:`scaling guide <scaling>`.
If you run the official docker container on multiple machines, it is recommended to set the environment
variable ``AUTOMIGRATE=skip`` on all containers and run ``docker exec -it pretix.service pretix migrate``
on one machine after each upgrade manually, otherwise multiple containers might try to upgrade the
database schema at the same time.
To run only the ``pretix-web`` component of pretix as well as a nginx server serving static files, you
can invoke the container with ``docker run … pretix/standalone:stable web`` (instead of ``all``).
To run only ``pretix-worker``, you can run ``docker run … pretix/standalone:stable taskworker``. You can
also pass arguments to limit the worker to specific queues or to change the number of concurrent task
workers, e.g. ``docker run … taskworker -Q notifications --concurrency 32``.
.. _Docker: https://docs.docker.com/engine/installation/linux/debian/
.. _Postfix: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-16-04
.. _nginx: https://botleg.com/stories/https-with-lets-encrypt-and-nginx/

View File

@@ -47,8 +47,6 @@ item_meta_properties object Item-specific m
valid_keys object Cryptographic keys for non-default signature schemes.
For performance reason, value is omitted in lists and
only contained in detail views. Value can be cached.
sales_channels list A list of sales channels this event is available for
sale on.
===================================== ========================== =======================================================
@@ -93,11 +91,6 @@ sales_channels list A list of sales
The attribute ``valid_keys`` has been added.
.. versionchanged:: 3.14
The attribute ``sales_channels`` has been added.
Endpoints
---------
@@ -154,16 +147,11 @@ Endpoints
"timezone": "Europe/Berlin",
"item_meta_properties": {},
"plugins": [
"pretix.plugins.banktransfer",
"pretix.plugins.stripe",
"pretix.plugins.paypal",
"pretix.plugins.banktransfer"
"pretix.plugins.stripe"
"pretix.plugins.paypal"
"pretix.plugins.ticketoutputpdf"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
]
}
@@ -182,7 +170,6 @@ Endpoints
only contain the events matching the set criteria. Providing ``?attr[Format]=Seminar`` would return only those
events having set their ``Format`` meta data to ``Seminar``, ``?attr[Format]=`` only those, that have no value
set. Please note that this filter will respect default values set on organizer level.
:query sales_channel: If set to a sales channel identifier, only events allowed to be sold on the specified sales channel are returned.
:param organizer: The ``slug`` field of a valid organizer
:statuscode 200: no error
:statuscode 401: Authentication failure
@@ -232,21 +219,16 @@ Endpoints
"timezone": "Europe/Berlin",
"item_meta_properties": {},
"plugins": [
"pretix.plugins.banktransfer",
"pretix.plugins.stripe",
"pretix.plugins.paypal",
"pretix.plugins.banktransfer"
"pretix.plugins.stripe"
"pretix.plugins.paypal"
"pretix.plugins.ticketoutputpdf"
],
"valid_keys": {
"pretix_sig1": [
"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUNvd0JRWURLMlZ3QXlFQTdBRDcvdkZBMzNFc1k0ejJQSHI3aVpQc1o4bjVkaDBhalA4Z3l6Tm1tSXM9Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo="
]
},
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
}
:param organizer: The ``slug`` field of the organizer to fetch
@@ -297,11 +279,6 @@ Endpoints
"plugins": [
"pretix.plugins.stripe",
"pretix.plugins.paypal"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
@@ -337,11 +314,6 @@ Endpoints
"plugins": [
"pretix.plugins.stripe",
"pretix.plugins.paypal"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
@@ -397,11 +369,6 @@ Endpoints
"plugins": [
"pretix.plugins.stripe",
"pretix.plugins.paypal"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
@@ -437,11 +404,6 @@ Endpoints
"plugins": [
"pretix.plugins.stripe",
"pretix.plugins.paypal"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}
@@ -511,11 +473,6 @@ Endpoints
"pretix.plugins.stripe",
"pretix.plugins.paypal",
"pretix.plugins.pretixdroid"
],
"sales_channels": [
"web",
"pretixpos",
"resellers"
]
}

View File

@@ -1,215 +0,0 @@
.. spelling:: checkin
Data exporters
==============
pretix and it's plugins include a number of data exporters that allow you to bulk download various data from pretix in
different formats. This page shows you how to use these exporters through the API.
.. versionchanged:: 3.13
This feature has been added to the API.
.. warning::
While we consider the methods listed on this page to be a stable API, the availability and specific input field
requirements of individual exporters is **not considered a stable API**. Specific exporters and their input parameters
may change at any time without warning.
Listing available exporters
---------------------------
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/exporters/
Returns a list of all exporters available for a given event. You will receive a list of export methods as well as their
supported input fields. Note that the exact type and validation requirements of the input fields are not given in the
response, and you might need to look into the pretix web interface to figure out the exact input required.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/events/sampleconf/exporters/ 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": [
{
"identifier": "orderlist",
"verbose_name": "Order data",
"input_parameters": [
{
"name": "_format",
"required": true,
"choices": [
"xlsx",
"orders:default",
"orders:excel",
"orders:semicolon",
"positions:default",
"positions:excel",
"positions:semicolon",
"fees:default",
"fees:excel",
"fees:semicolon"
]
},
{
"name": "paid_only",
"required": false
}
]
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
: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)/exporters/
Returns a list of all cross-event exporters available for a given organizer. You will receive a list of export methods as well as their
supported input fields. Note that the exact type and validation requirements of the input fields are not given in the
response, and you might need to look into the pretix web interface to figure out the exact input required.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/exporters/ 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": [
{
"identifier": "orderlist",
"verbose_name": "Order data",
"input_parameters": [
{
"name": "events",
"required": true
},
{
"name": "_format",
"required": true,
"choices": [
"xlsx",
"orders:default",
"orders:excel",
"orders:semicolon",
"positions:default",
"positions:excel",
"positions:semicolon",
"fees:default",
"fees:excel",
"fees:semicolon"
]
},
{
"name": "paid_only",
"required": false
}
]
}
]
}
:query integer page: The page number in case of a multi-page result set, default is 1
:param organizer: The ``slug`` field of the organizer 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.
Running an export
-----------------
Since exports often include large data sets, they might take longer than the duration of an HTTP request. Therefore,
creating an export is a two-step process. First you need to start an export task with one of the following to API
endpoints:
.. http:post:: /api/v1/organizers/(organizer)/events/(event)/exporters/(identifier)/run/
Starts an export task. If your input parameters validate correctly, a ``202 Accepted`` status code is returned.
The body points you to the download URL of the result.
**Example request**:
.. sourcecode:: http
POST /api/v1/organizers/bigevents/events/sampleconf/exporters/orderlist/run/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"_format": "xlsx"
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"download": "https://pretix.eu/api/v1/organizers/bigevents/events/sampleconf/orderlist/download/29891ede-196f-4942-9e26-d055a36e98b8/3f279f13-c198-4137-b49b-9b360ce9fcce/"
}
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:param identifier: The ``identifier`` field of the exporter to run
:statuscode 202: no error
:statuscode 400: Invalid input options
: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)/exporters/(identifier)/run/
The endpoint for organizer-level exports works just like event-level exports (see above).
Downloading the result
----------------------
When starting an export, you receive a ``url`` for downloading the result. Running a ``GET`` request on that result will
yield one of the following status codes:
* ``200 OK`` The export succeeded. The body will be your resulting file. Might be large!
* ``409 Conflict`` Your export is still running. The body will be JSON with the structure ``{"status": "running", "percentage": 40}``. ``percentage`` can be ``null`` if it is not known and ``status`` can be ``waiting`` before the task is actually being processed. Please retry, but wait at least one second before you do.
* ``410 Gone`` Running the export has failed permanently. The body will be JSON with the structure ``{"status": "failed", "message": "Error message"}``
* ``404 Not Found`` The export does not exist / is expired.
.. warning::
Running exports puts a lot of stress on the system, we kindly ask you not to run more than two exports at the same time.

View File

@@ -22,28 +22,9 @@ expires datetime Expiry date (or
conditions string Special terms and conditions for this card (or ``null``)
===================================== ========================== =======================================================
The gift card transaction resource contains the following public fields:
.. rst-class:: rest-resource-table
===================================== ========================== =======================================================
Field Type Description
===================================== ========================== =======================================================
id integer Internal ID of the gift card transaction
datetime datetime Creation date of the transaction
value money (string) Transaction amount
event string Event slug, if the gift card was used in the web shop (or ``null``)
order string Order code, if the gift card was used in the web shop (or ``null``)
text string Custom text of the transaction (or ``null``)
===================================== ========================== =======================================================
Endpoints
---------
.. versionadded:: 3.14
The transaction list endpoint was added.
.. http:get:: /api/v1/organizers/(organizer)/giftcards/
Returns a list of all gift cards issued by a given organizer.
@@ -269,45 +250,3 @@ Endpoints
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to change this resource.
:statuscode 409: There is not sufficient credit on the gift card.
.. http:get:: /api/v1/organizers/(organizer)/giftcards/(id)/transactions/
List all transactions of a gift card.
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/giftcards/1/transactions/ 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": 82,
"datetime": "2020-06-22T15:41:42.800534Z",
"value": "50.00",
"event": "democon",
"order": "FXQYW",
"text": null
}
]
}
:param organizer: The ``slug`` field of the organizer to view
:param id: The ``id`` field of the gift card to view
: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.

View File

@@ -27,6 +27,5 @@ Resources and endpoints
devices
webhooks
seatingplans
exporters
billing_invoices
billing_var

View File

@@ -163,10 +163,6 @@ last_modified datetime Last modificati
The ``exclude`` and ``subevent_after`` query parameter has been added.
.. versionchanged:: 3.13
The ``subevent_before`` query parameter has been added.
.. _order-position-resource:
@@ -494,8 +490,7 @@ List of all orders
recommend using this in combination with ``testmode=false``, since test mode orders can vanish at any time and
you will not notice it using this method.
:query datetime created_since: Only return orders that have been created since the given date.
:query datetime subevent_after: Only return orders that contain a ticket for a subevent taking place after the given date. This is an exclusive after, and it considers the **end** of the subevent (or its start, if the end is not set).
:query datetime subevent_before: Only return orders that contain a ticket for a subevent taking place after the given date. This is an exclusive before, and it considers the **start** of the subevent.
:query datetime subevent_after: Only return orders that contain a ticket for a subevent taking place after the given date.
:query string exclude: Exclude a field from the output, e.g. ``fees`` or ``positions.downloads``. Can be used as a performance optimization. Can be passed multiple times.
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
@@ -940,9 +935,9 @@ Creating orders
during order generation and is not respected automatically when the order changes later.)
* ``force`` (optional). If set to ``true``, quotas will be ignored.
* ``send_email`` (optional). If set to ``true``, the same emails will be sent as for a regular order, regardless of
* ``send_mail`` (optional). If set to ``true``, the same emails will be sent as for a regular order, regardless of
whether these emails are enabled for certain sales channels. Defaults to
``false``. Used to be ``send_mail`` before pretix 3.14.
``false``.
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
@@ -1976,7 +1971,6 @@ Order payment endpoints
"amount": "23.00",
"payment_date": "2017-12-04T12:13:12Z",
"info": {},
"send_email": false,
"provider": "banktransfer"
}

View File

@@ -90,120 +90,3 @@ Endpoints
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to view it.
Organizer settings
------------------
pretix organizers and events have lots and lots of parameters of different types that are stored in a key-value store on our system.
Since many of these settings depend on each other in complex ways, we can not give direct access to all of these
settings through the API. However, we do expose many of the simple and useful flags through the API.
Please note that the available settings flags change between pretix versions, and we do not give a guarantee on backwards-compatibility like with other parts of the API.
Therefore, we're also not including a list of the options here, but instead recommend to look at the endpoint output
to see available options. The ``explain=true`` flag enables a verbose mode that provides you with human-readable
information about the properties.
.. note:: Please note that this is not a complete representation of all organizer settings. You will find more settings
in the web interface.
.. warning:: This API is intended for advanced users. Even though we take care to validate your input, you will be
able to break your shops using this API by creating situations of conflicting settings. Please take care.
.. versionchanged:: 3.14
Initial support for settings has been added to the API.
.. http:get:: /api/v1/organizers/(organizer)/settings/
Get current values of organizer settings.
Permission required: "Can change organizer settings"
**Example request**:
.. sourcecode:: http
GET /api/v1/organizers/bigevents/settings/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
**Example standard response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"event_list_type": "calendar",
}
**Example verbose response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"event_list_type":
{
"value": "calendar",
"label": "Default overview style",
"help_text": "If your event series has more than 50 dates in the future, only the month or week calendar can be used."
}
},
}
:param organizer: The ``slug`` field of the organizer to access
:query explain: Set to ``true`` to enable verbose response mode
: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:patch:: /api/v1/organizers/(organizer)/settings/
Updates organizer settings. Note that ``PUT`` is not allowed here, only ``PATCH``.
.. warning::
Settings can be stored at different levels in pretix. If a value is not set on organizer level, a default setting
from a higher level (global) will be returned. If you explicitly set a setting on organizer level, it
will no longer be inherited from the higher levels. Therefore, we recommend you to send only settings that you
explicitly want to set on organizer level. To unset a settings, pass ``null``.
**Example request**:
.. sourcecode:: http
PATCH /api/v1/organizers/bigevents/settings/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"event_list_type": "calendar"
}
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"event_list_type": "calendar",
}
:param organizer: The ``slug`` field of the organizer to update
:statuscode 200: no error
:statuscode 400: The organizer could not be updated 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.

View File

@@ -1,7 +1,4 @@
.. spelling::
checkin
datetime
.. spelling:: checkin
.. _rest-questions:
@@ -56,12 +53,6 @@ options list of objects In case of ques
├ 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 questions (optional)
valid_number_max string Maximum value for number questions (optional)
valid_date_min date Minimum value for date questions (optional)
valid_date_max date Maximum value for date questions (optional)
valid_datetime_min datetime Minimum value for date and time questions (optional)
valid_datetime_max datetime Maximum value for date and time questions (optional)
dependency_question integer Internal ID of a different question. The current
question will only be shown if the question given in
this attribute is set to the value given in
@@ -101,10 +92,6 @@ dependency_value string An old version
The attribute ``help_text`` has been added.
.. versionchanged:: 3.14
The attributes ``valid_*`` have been added.
Endpoints
---------
@@ -150,12 +137,6 @@ Endpoints
"ask_during_checkin": false,
"hidden": false,
"print_on_invoice": false,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"dependency_question": null,
"dependency_value": null,
"dependency_values": [],
@@ -227,12 +208,6 @@ Endpoints
"ask_during_checkin": false,
"hidden": false,
"print_on_invoice": false,
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"dependency_question": null,
"dependency_value": null,
"dependency_values": [],
@@ -327,12 +302,6 @@ Endpoints
"dependency_question": null,
"dependency_value": null,
"dependency_values": [],
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"options": [
{
"id": 1,
@@ -408,12 +377,6 @@ Endpoints
"dependency_question": null,
"dependency_value": null,
"dependency_values": [],
"valid_number_min": null,
"valid_number_max": null,
"valid_date_min": null,
"valid_date_max": null,
"valid_datetime_min": null,
"valid_datetime_max": null,
"options": [
{
"id": 1,

View File

@@ -31,10 +31,8 @@ action_types list of strings A list of actio
The following values for ``action_types`` are valid with pretix core:
* ``pretix.event.order.placed``
* ``pretix.event.order.placed.require_approval``
* ``pretix.event.order.paid``
* ``pretix.event.order.canceled``
* ``pretix.event.order.reactivated``
* ``pretix.event.order.expired``
* ``pretix.event.order.modified``
* ``pretix.event.order.contact.changed``
@@ -44,12 +42,6 @@ The following values for ``action_types`` are valid with pretix core:
* ``pretix.event.order.denied``
* ``pretix.event.checkin``
* ``pretix.event.checkin.reverted``
* ``pretix.event.added``
* ``pretix.event.changed``
* ``pretix.event.deleted``
* ``pretix.subevent.added``
* ``pretix.subevent.changed``
* ``pretix.subevent.deleted``
Installed plugins might register more valid values.

View File

@@ -58,7 +58,7 @@ Backend
.. automodule:: pretix.control.signals
:members: nav_event, html_head, html_page_start, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings,
order_info, event_settings_widget, oauth_application_registered, order_position_buttons, subevent_forms,
item_formsets, order_search_filter_q, order_search_forms
item_formsets, order_search_filter_q
.. automodule:: pretix.base.signals
:members: logentry_display, logentry_object_link, requiredaction_display, timeline_events

View File

@@ -7,7 +7,7 @@ localecompile:
localegen:
./manage.py makemessages --keep-pot --ignore "pretix/helpers/*" $(LNGS)
./manage.py makemessages --keep-pot -d djangojs --ignore "pretix/helpers/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static.dist/*" --ignore "data/*" --ignore "pretix/static/rrule/*" --ignore "build/*" $(LNGS)
./manage.py makemessages --keep-pot -d djangojs --ignore "pretix/helpers/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static.dist/*" --ignore "data/*" --ignore "build/*" $(LNGS)
staticfiles: jsi18n
./manage.py collectstatic --noinput

View File

@@ -1 +1 @@
__version__ = "3.14.0.dev0"
__version__ = "3.13.0.dev0"

View File

@@ -102,17 +102,12 @@ class PretixPosSecurityProfile(AllowListSecurityProfile):
('DELETE', 'api-v1:cartposition-detail'),
('GET', 'api-v1:giftcard-list'),
('POST', 'api-v1:giftcard-transact'),
('GET', 'plugins:pretix_posbackend:posclosing-list'),
('POST', 'plugins:pretix_posbackend:posreceipt-list'),
('POST', 'plugins:pretix_posbackend:posclosing-list'),
('POST', 'plugins:pretix_posbackend:posdebugdump-list'),
('POST', 'plugins:pretix_posbackend:stripeterminal.token'),
('GET', 'api-v1:revokedsecrets-list'),
('GET', 'api-v1:event.settings'),
('GET', 'plugins:pretix_seating:event.event'),
('GET', 'plugins:pretix_seating:event.event.subevent'),
('GET', 'plugins:pretix_seating:event.plan'),
('GET', 'plugins:pretix_seating:selection.simple'),
)

View File

@@ -87,10 +87,7 @@ class CartPositionCreateSerializer(I18nAwareModelSerializer):
raise ValidationError('The specified seat ID is not unique.')
else:
validated_data['seat'] = seat
if not seat.is_available(
sales_channel=validated_data.get('sales_channel', 'web'),
distance_ignore_cart_id=validated_data['cart_id'],
):
if not seat.is_available(sales_channel=validated_data.get('sales_channel', 'web')):
raise ValidationError(gettext_lazy('The selected seat "{seat}" is not available.').format(seat=seat.name))
elif seated:
raise ValidationError('The specified product requires to choose a seat.')
@@ -107,7 +104,6 @@ class CartPositionCreateSerializer(I18nAwareModelSerializer):
def validate_cart_id(self, cid):
if cid and not cid.endswith('@api'):
raise ValidationError('Cart ID should end in @api or be empty.')
return cid
def validate_item(self, item):
if item.event != self.context['event']:

View File

@@ -17,7 +17,7 @@ from pretix.base.models.items import SubEventItem, SubEventItemVariation
from pretix.base.services.seating import (
SeatProtected, generate_seats, validate_plan_change,
)
from pretix.base.settings import DEFAULTS, validate_event_settings
from pretix.base.settings import DEFAULTS, validate_settings
from pretix.base.signals import api_event_settings_fields
@@ -124,8 +124,7 @@ class EventSerializer(I18nAwareModelSerializer):
fields = ('name', 'slug', 'live', 'testmode', 'currency', 'date_from',
'date_to', 'date_admission', 'is_public', 'presale_start',
'presale_end', 'location', 'geo_lat', 'geo_lon', 'has_subevents', 'meta_data', 'seating_plan',
'plugins', 'seat_category_mapping', 'timezone', 'item_meta_properties', 'valid_keys',
'sales_channels')
'plugins', 'seat_category_mapping', 'timezone', 'item_meta_properties', 'valid_keys')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -555,7 +554,7 @@ class SubEventSerializer(I18nAwareModelSerializer):
class TaxRuleSerializer(CountryFieldMixin, I18nAwareModelSerializer):
class Meta:
model = TaxRule
fields = ('id', 'name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country')
fields = ('id', 'name', 'rate', 'price_includes_tax')
class EventSettingsSerializer(serializers.Serializer):
@@ -597,7 +596,6 @@ class EventSettingsSerializer(serializers.Serializer):
'attendee_addresses_required',
'attendee_company_asked',
'attendee_company_required',
'attendee_data_explanation_text',
'confirm_texts',
'order_email_asked_twice',
'payment_term_mode',
@@ -608,7 +606,6 @@ class EventSettingsSerializer(serializers.Serializer):
'payment_term_expire_automatically',
'payment_term_accept_late',
'payment_explanation',
'payment_pending_hidden',
'ticket_download',
'ticket_download_date',
'ticket_download_addons',
@@ -664,17 +661,10 @@ class EventSettingsSerializer(serializers.Serializer):
'change_allow_user_variation',
'change_allow_user_until',
'change_allow_user_price',
'primary_color',
'theme_color_success',
'theme_color_danger',
'theme_color_background',
'theme_round_borders',
'primary_font',
]
def __init__(self, *args, **kwargs):
self.event = kwargs.pop('event')
self.changed_data = []
super().__init__(*args, **kwargs)
for fname in self.default_fields:
kwargs = DEFAULTS[fname].get('serializer_kwargs', {})
@@ -703,17 +693,15 @@ class EventSettingsSerializer(serializers.Serializer):
for attr, value in validated_data.items():
if value is None:
instance.delete(attr)
self.changed_data.append(attr)
elif instance.get(attr, as_type=type(value)) != value:
instance.set(attr, value)
self.changed_data.append(attr)
return instance
def validate(self, data):
data = super().validate(data)
settings_dict = self.instance.freeze()
settings_dict.update(data)
validate_event_settings(self.event, settings_dict)
validate_settings(self.event, settings_dict)
return data

View File

@@ -1,127 +0,0 @@
from django import forms
from django.http import QueryDict
from rest_framework import serializers
class FormFieldWrapperField(serializers.Field):
def __init__(self, *args, **kwargs):
self.form_field = kwargs.pop('form_field')
super().__init__(*args, **kwargs)
def to_representation(self, value):
return self.form_field.widget.format_value(value)
def to_internal_value(self, data):
d = self.form_field.widget.value_from_datadict({'name': data}, {}, 'name')
d = self.form_field.clean(d)
return d
simple_mappings = (
(forms.DateField, serializers.DateField, tuple()),
(forms.TimeField, serializers.TimeField, tuple()),
(forms.SplitDateTimeField, serializers.DateTimeField, tuple()),
(forms.DateTimeField, serializers.DateTimeField, tuple()),
(forms.DecimalField, serializers.DecimalField, ('max_digits', 'decimal_places', 'min_value', 'max_value')),
(forms.FloatField, serializers.FloatField, tuple()),
(forms.IntegerField, serializers.IntegerField, tuple()),
(forms.EmailField, serializers.EmailField, tuple()),
(forms.UUIDField, serializers.UUIDField, tuple()),
(forms.URLField, serializers.URLField, tuple()),
(forms.NullBooleanField, serializers.NullBooleanField, tuple()),
(forms.BooleanField, serializers.BooleanField, tuple()),
)
class SerializerDescriptionField(serializers.Field):
def to_representation(self, value):
fields = []
for k, v in value.fields.items():
d = {
'name': k,
'required': v.required,
}
if isinstance(v, serializers.ChoiceField):
d['choices'] = list(v.choices.keys())
fields.append(d)
return fields
class ExporterSerializer(serializers.Serializer):
identifier = serializers.CharField()
verbose_name = serializers.CharField()
input_parameters = SerializerDescriptionField(source='_serializer')
class PrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):
def to_representation(self, value):
if isinstance(value, int):
return value
return super().to_representation(value)
class JobRunSerializer(serializers.Serializer):
def __init__(self, *args, **kwargs):
ex = kwargs.pop('exporter')
events = kwargs.pop('events', None)
super().__init__(*args, **kwargs)
if events is not None:
self.fields["events"] = serializers.SlugRelatedField(
queryset=events,
required=True,
allow_empty=False,
slug_field='slug',
many=True
)
for k, v in ex.export_form_fields.items():
for m_from, m_to, m_kwargs in simple_mappings:
if isinstance(v, m_from):
self.fields[k] = m_to(
required=v.required,
allow_null=not v.required,
validators=v.validators,
**{kwarg: getattr(v, kwargs, None) for kwarg in m_kwargs}
)
break
if isinstance(v, forms.ModelMultipleChoiceField):
self.fields[k] = PrimaryKeyRelatedField(
queryset=v.queryset,
required=v.required,
allow_empty=not v.required,
validators=v.validators,
many=True
)
elif isinstance(v, forms.ModelChoiceField):
self.fields[k] = PrimaryKeyRelatedField(
queryset=v.queryset,
required=v.required,
allow_null=not v.required,
validators=v.validators,
)
elif isinstance(v, forms.MultipleChoiceField):
self.fields[k] = serializers.MultipleChoiceField(
choices=v.choices,
required=v.required,
allow_empty=not v.required,
validators=v.validators,
)
elif isinstance(v, forms.ChoiceField):
self.fields[k] = serializers.ChoiceField(
choices=v.choices,
required=v.required,
allow_null=not v.required,
validators=v.validators,
)
else:
self.fields[k] = FormFieldWrapperField(form_field=v, required=v.required, allow_null=not v.required)
def to_internal_value(self, data):
if isinstance(data, QueryDict):
data = data.copy()
for k, v in self.fields.items():
if isinstance(v, serializers.ManyRelatedField) and k not in data:
data[k] = []
data = super().to_internal_value(data)
return data

View File

@@ -277,9 +277,7 @@ class QuestionSerializer(I18nAwareModelSerializer):
model = Question
fields = ('id', 'question', 'type', 'required', 'items', 'options', 'position',
'ask_during_checkin', 'identifier', 'dependency_question', 'dependency_values',
'hidden', 'dependency_value', 'print_on_invoice', 'help_text', 'valid_number_min',
'valid_number_max', 'valid_date_min', 'valid_date_max', 'valid_datetime_min', 'valid_datetime_max'
)
'hidden', 'dependency_value', 'print_on_invoice', 'help_text')
def validate_identifier(self, value):
Question._clean_identifier(self.context['event'], value, self.instance)

View File

@@ -682,7 +682,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
consume_carts = serializers.ListField(child=serializers.CharField(), required=False)
force = serializers.BooleanField(default=False, required=False)
payment_date = serializers.DateTimeField(required=False, allow_null=True)
send_email = serializers.BooleanField(default=False, required=False)
send_mail = serializers.BooleanField(default=False, required=False)
simulate = serializers.BooleanField(default=False, required=False)
def __init__(self, *args, **kwargs):
@@ -693,7 +693,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
model = Order
fields = ('code', 'status', 'testmode', 'email', 'locale', 'payment_provider', 'fees', 'comment', 'sales_channel',
'invoice_address', 'positions', 'checkin_attention', 'payment_info', 'payment_date', 'consume_carts',
'force', 'send_email', 'simulate')
'force', 'send_mail', 'simulate')
def validate_payment_provider(self, pp):
if pp is None:
@@ -786,7 +786,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
payment_date = validated_data.pop('payment_date', now())
force = validated_data.pop('force', False)
simulate = validated_data.pop('simulate', False)
self._send_mail = validated_data.pop('send_email', False)
self._send_mail = validated_data.pop('send_mail', False)
if 'invoice_address' in validated_data:
iadata = validated_data.pop('invoice_address')

View File

@@ -2,7 +2,6 @@ from decimal import Decimal
from django.db.models import Q
from django.utils.translation import get_language, gettext_lazy as _
from hierarkey.proxy import HierarkeyProxy
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
@@ -10,12 +9,11 @@ from pretix.api.serializers.i18n import I18nAwareModelSerializer
from pretix.api.serializers.order import CompatibleJSONField
from pretix.base.auth import get_auth_backends
from pretix.base.models import (
Device, GiftCard, GiftCardTransaction, Organizer, SeatingPlan, Team,
TeamAPIToken, TeamInvite, User,
Device, GiftCard, Organizer, SeatingPlan, Team, TeamAPIToken, TeamInvite,
User,
)
from pretix.base.models.seating import SeatingPlanLayoutValidator
from pretix.base.services.mail import SendMailException, mail
from pretix.base.settings import DEFAULTS, validate_organizer_settings
from pretix.helpers.urls import build_absolute_uri
@@ -61,21 +59,6 @@ class GiftCardSerializer(I18nAwareModelSerializer):
fields = ('id', 'secret', 'issuance', 'value', 'currency', 'testmode', 'expires', 'conditions')
class OrderEventSlugField(serializers.RelatedField):
def to_representation(self, obj):
return obj.event.slug
class GiftCardTransactionSerializer(I18nAwareModelSerializer):
order = serializers.SlugRelatedField(slug_field='code', read_only=True)
event = OrderEventSlugField(source='order', read_only=True)
class Meta:
model = GiftCardTransaction
fields = ('id', 'datetime', 'value', 'event', 'order', 'text')
class EventSlugField(serializers.SlugRelatedField):
def get_queryset(self):
return self.context['organizer'].events.all()
@@ -204,63 +187,3 @@ class TeamMemberSerializer(serializers.ModelSerializer):
fields = (
'id', 'email', 'fullname', 'require_2fa'
)
class OrganizerSettingsSerializer(serializers.Serializer):
default_fields = [
'organizer_info_text',
'event_list_type',
'event_list_availability',
'organizer_homepage_text',
'organizer_link_back',
'organizer_logo_image_large',
'giftcard_length',
'giftcard_expiry_years',
'locales',
'event_team_provisioning',
'primary_color',
'theme_color_success',
'theme_color_danger',
'theme_color_background',
'theme_round_borders',
'primary_font'
]
def __init__(self, *args, **kwargs):
self.organizer = kwargs.pop('organizer')
self.changed_data = []
super().__init__(*args, **kwargs)
for fname in self.default_fields:
kwargs = DEFAULTS[fname].get('serializer_kwargs', {})
if callable(kwargs):
kwargs = kwargs()
kwargs.setdefault('required', False)
kwargs.setdefault('allow_null', True)
form_kwargs = DEFAULTS[fname].get('form_kwargs', {})
if callable(form_kwargs):
form_kwargs = form_kwargs()
if 'serializer_class' not in DEFAULTS[fname]:
raise ValidationError('{} has no serializer class'.format(fname))
f = DEFAULTS[fname]['serializer_class'](
**kwargs
)
f._label = form_kwargs.get('label', fname)
f._help_text = form_kwargs.get('help_text')
self.fields[fname] = f
def update(self, instance: HierarkeyProxy, validated_data):
for attr, value in validated_data.items():
if value is None:
instance.delete(attr)
self.changed_data.append(attr)
elif instance.get(attr, as_type=type(value)) != value:
instance.set(attr, value)
self.changed_data.append(attr)
return instance
def validate(self, data):
data = super().validate(data)
settings_dict = self.instance.freeze()
settings_dict.update(data)
validate_organizer_settings(self.organizer, settings_dict)
return data

View File

@@ -7,8 +7,8 @@ from rest_framework import routers
from pretix.api.views import cart
from .views import (
checkin, device, event, exporters, item, oauth, order, organizer, user,
version, voucher, waitinglist, webhooks,
checkin, device, event, item, oauth, order, organizer, user, version,
voucher, waitinglist, webhooks,
)
router = routers.DefaultRouter()
@@ -22,7 +22,6 @@ orga_router.register(r'seatingplans', organizer.SeatingPlanViewSet)
orga_router.register(r'giftcards', organizer.GiftCardViewSet)
orga_router.register(r'teams', organizer.TeamViewSet)
orga_router.register(r'devices', organizer.DeviceViewSet)
orga_router.register(r'exporters', exporters.OrganizerExportersViewSet, basename='exporters')
team_router = routers.DefaultRouter()
team_router.register(r'members', organizer.TeamMemberViewSet)
@@ -45,7 +44,6 @@ event_router.register(r'taxrules', event.TaxRuleViewSet)
event_router.register(r'waitinglistentries', waitinglist.WaitingListViewSet)
event_router.register(r'checkinlists', checkin.CheckinListViewSet)
event_router.register(r'cartpositions', cart.CartPositionViewSet)
event_router.register(r'exporters', exporters.EventExportersViewSet, basename='exporters')
checkinlist_router = routers.DefaultRouter()
checkinlist_router.register(r'positions', checkin.CheckinListPositionViewSet, basename='checkinlistpos')
@@ -62,9 +60,6 @@ order_router = routers.DefaultRouter()
order_router.register(r'payments', order.PaymentViewSet)
order_router.register(r'refunds', order.RefundViewSet)
giftcard_router = routers.DefaultRouter()
giftcard_router.register(r'transactions', organizer.GiftCardTransactionViewSet)
# Force import of all plugins to give them a chance to register URLs with the router
for app in apps.get_app_configs():
if hasattr(app, 'PretixPluginMeta'):
@@ -74,9 +69,6 @@ for app in apps.get_app_configs():
urlpatterns = [
url(r'^', include(router.urls)),
url(r'^organizers/(?P<organizer>[^/]+)/', include(orga_router.urls)),
url(r'^organizers/(?P<organizer>[^/]+)/settings/$', organizer.OrganizerSettingsView.as_view(),
name="organizer.settings"),
url(r'^organizers/(?P<organizer>[^/]+)/giftcards/(?P<giftcard>[^/]+)/', include(giftcard_router.urls)),
url(r'^organizers/(?P<organizer>[^/]+)/events/(?P<event>[^/]+)/settings/$', event.EventSettingsView.as_view(),
name="event.settings"),
url(r'^organizers/(?P<organizer>[^/]+)/events/(?P<event>[^/]+)/', include(event_router.urls)),

View File

@@ -131,7 +131,7 @@ class EventSelectionView(APIView):
@property
def base_event_qs(self):
qs = self.request.auth.get_events_with_any_permission().annotate(
qs = self.request.auth.organizer.events.annotate(
first_date=Coalesce('date_admission', 'date_from'),
last_date=Coalesce('date_to', 'date_from'),
).filter(
@@ -154,7 +154,6 @@ class EventSelectionView(APIView):
).filter(
event__organizer=self.request.auth.organizer,
event__live=True,
event__in=self.request.auth.get_events_with_any_permission(),
active=True,
).select_related('event').order_by('first_date')
if self.request.auth.gate:

View File

@@ -18,9 +18,7 @@ from pretix.base.models import (
CartPosition, Device, Event, TaxRule, TeamAPIToken,
)
from pretix.base.models.event import SubEvent
from pretix.base.settings import SETTINGS_AFFECTING_CSS
from pretix.helpers.dicts import merge_dicts
from pretix.presale.style import regenerate_css
from pretix.presale.views.organizer import filter_qs_by_attr
with scopes_disabled():
@@ -28,7 +26,6 @@ with scopes_disabled():
is_past = django_filters.rest_framework.BooleanFilter(method='is_past_qs')
is_future = django_filters.rest_framework.BooleanFilter(method='is_future_qs')
ends_after = django_filters.rest_framework.IsoDateTimeFilter(method='ends_after_qs')
sales_channel = django_filters.rest_framework.CharFilter(method='sales_channel_qs')
class Meta:
model = Event
@@ -70,9 +67,6 @@ with scopes_disabled():
else:
return queryset.exclude(expr)
def sales_channel_qs(self, queryset, name, value):
return queryset.filter(sales_channels__contains=value)
class EventViewSet(viewsets.ModelViewSet):
serializer_class = EventSerializer
@@ -391,7 +385,5 @@ class EventSettingsView(views.APIView):
k: v for k, v in s.validated_data.items()
}
)
if any(p in s.changed_data for p in SETTINGS_AFFECTING_CSS):
regenerate_css.apply_async(args=(request.organizer.pk,))
s = EventSettingsSerializer(instance=request.event.settings, event=request.event)
return Response(s.data)

View File

@@ -1,154 +0,0 @@
from datetime import timedelta
from celery.result import AsyncResult
from django.conf import settings
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils.functional import cached_property
from django.utils.timezone import now
from rest_framework import status, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.reverse import reverse
from pretix.api.serializers.exporters import (
ExporterSerializer, JobRunSerializer,
)
from pretix.base.models import CachedFile, Device, TeamAPIToken
from pretix.base.services.export import export, multiexport
from pretix.base.signals import (
register_data_exporters, register_multievent_data_exporters,
)
from pretix.helpers.http import ChunkBasedFileResponse
class ExportersMixin:
def list(self, request, *args, **kwargs):
res = ExporterSerializer(self.exporters, many=True)
return Response({
"count": len(self.exporters),
"next": None,
"previous": None,
"results": res.data
})
def get_object(self):
instances = [e for e in self.exporters if e.identifier == self.kwargs.get('pk')]
if not instances:
raise Http404()
return instances[0]
def retrieve(self, request, *args, **kwargs):
instance = self.get_object()
serializer = ExporterSerializer(instance)
return Response(serializer.data)
@action(detail=True, methods=['GET'], url_name='download', url_path='download/(?P<asyncid>[^/]+)/(?P<cfid>[^/]+)')
def download(self, *args, **kwargs):
cf = get_object_or_404(CachedFile, id=kwargs['cfid'])
if cf.file:
resp = ChunkBasedFileResponse(cf.file.file, content_type=cf.type)
resp['Content-Disposition'] = 'attachment; filename="{}"'.format(cf.filename)
return resp
elif not settings.HAS_CELERY:
return Response(
{'status': 'failed', 'message': 'Unknown file ID or export failed'},
status=status.HTTP_410_GONE
)
res = AsyncResult(kwargs['asyncid'])
if res.failed():
if isinstance(res.info, dict) and res.info['exc_type'] == 'ExportError':
msg = res.info['exc_message']
else:
msg = 'Internal error'
return Response(
{'status': 'failed', 'message': msg},
status=status.HTTP_410_GONE
)
return Response(
{
'status': 'running' if res.state in ('PROGRESS', 'STARTED', 'SUCCESS') else 'waiting',
'percentage': res.result.get('value', None) if res.result else None,
},
status=status.HTTP_409_CONFLICT
)
@action(detail=True, methods=['POST'])
def run(self, *args, **kwargs):
instance = self.get_object()
serializer = JobRunSerializer(exporter=instance, data=self.request.data, **self.get_serializer_kwargs())
serializer.is_valid(raise_exception=True)
cf = CachedFile()
cf.date = now()
cf.expires = now() + timedelta(days=3)
cf.save()
d = serializer.data
for k, v in d.items():
if isinstance(v, set):
d[k] = list(v)
async_result = self.do_export(cf, instance, d)
url_kwargs = {
'asyncid': str(async_result.id),
'cfid': str(cf.id),
}
url_kwargs.update(self.kwargs)
return Response({
'download': reverse('api-v1:exporters-download', kwargs=url_kwargs, request=self.request)
}, status=status.HTTP_202_ACCEPTED)
class EventExportersViewSet(ExportersMixin, viewsets.ViewSet):
permission = 'can_view_orders'
def get_serializer_kwargs(self):
return {}
@cached_property
def exporters(self):
exporters = []
responses = register_data_exporters.send(self.request.event)
for ex in sorted([response(self.request.event) for r, response in responses], key=lambda ex: str(ex.verbose_name)):
ex._serializer = JobRunSerializer(exporter=ex)
exporters.append(ex)
return exporters
def do_export(self, cf, instance, data):
return export.apply_async(args=(self.request.event.id, str(cf.id), instance.identifier, data))
class OrganizerExportersViewSet(ExportersMixin, viewsets.ViewSet):
permission = None
@cached_property
def exporters(self):
exporters = []
events = (self.request.auth or self.request.user).get_events_with_permission('can_view_orders', request=self.request).filter(
organizer=self.request.organizer
)
responses = register_multievent_data_exporters.send(self.request.organizer)
for ex in sorted([response(events) for r, response in responses if response], key=lambda ex: str(ex.verbose_name)):
ex._serializer = JobRunSerializer(exporter=ex, events=events)
exporters.append(ex)
return exporters
def get_serializer_kwargs(self):
return {
'events': self.request.auth.get_events_with_permission('can_view_orders', request=self.request).filter(
organizer=self.request.organizer
)
}
def do_export(self, cf, instance, data):
return multiexport.apply_async(kwargs={
'organizer': self.request.organizer.id,
'user': self.request.user.id if self.request.user.is_authenticated else None,
'token': self.request.auth.pk if isinstance(self.request.auth, TeamAPIToken) else None,
'device': self.request.auth.pk if isinstance(self.request.auth, Device) else None,
'fileid': str(cf.id),
'provider': instance.identifier,
'form_data': data
})

View File

@@ -33,7 +33,7 @@ from pretix.base.i18n import language
from pretix.base.models import (
CachedCombinedTicket, CachedTicket, Device, Event, Invoice, InvoiceAddress,
Order, OrderFee, OrderPayment, OrderPosition, OrderRefund, Quota, SubEvent,
TaxRule, TeamAPIToken, generate_secret,
TeamAPIToken, generate_secret,
)
from pretix.base.models.orders import RevokedTicketSecret
from pretix.base.payment import PaymentException
@@ -65,7 +65,6 @@ with scopes_disabled():
modified_since = django_filters.IsoDateTimeFilter(field_name='last_modified', lookup_expr='gte')
created_since = django_filters.IsoDateTimeFilter(field_name='datetime', lookup_expr='gte')
subevent_after = django_filters.IsoDateTimeFilter(method='subevent_after_qs')
subevent_before = django_filters.IsoDateTimeFilter(method='subevent_before_qs')
search = django_filters.CharFilter(method='search_qs')
class Meta:
@@ -85,19 +84,6 @@ with scopes_disabled():
).filter(has_se_after=True)
return qs
def subevent_before_qs(self, qs, name, value):
qs = qs.annotate(
has_se_before=Exists(
OrderPosition.all.filter(
subevent_id__in=SubEvent.objects.filter(
Q(date_from__lt=value), event=OuterRef(OuterRef('event_id'))
).values_list('id'),
order_id=OuterRef('pk'),
)
)
).filter(has_se_before=True)
return qs
def search_qs(self, qs, name, value):
u = value
if "-" in value:
@@ -558,15 +544,10 @@ class OrderViewSet(viewsets.ModelViewSet):
)
def create(self, request, *args, **kwargs):
if 'send_mail' in request.data and 'send_email' not in request.data:
request.data['send_email'] = request.data['send_mail']
serializer = OrderCreateSerializer(data=request.data, context=self.get_serializer_context())
serializer.is_valid(raise_exception=True)
with transaction.atomic():
try:
self.perform_create(serializer)
except TaxRule.SaleNotAllowed:
raise ValidationError(_('One of the selected products is not available in the selected country.'))
self.perform_create(serializer)
send_mail = serializer._send_mail
order = serializer.instance
if not order.pk:
@@ -951,7 +932,6 @@ class PaymentViewSet(CreateModelMixin, viewsets.ReadOnlyModelViewSet):
def get_serializer_context(self):
ctx = super().get_serializer_context()
ctx['order'] = get_object_or_404(Order, code=self.kwargs['order'], event=self.request.event)
ctx['event'] = self.request.event
return ctx
def get_queryset(self):
@@ -959,7 +939,6 @@ class PaymentViewSet(CreateModelMixin, viewsets.ReadOnlyModelViewSet):
return order.payments.all()
def create(self, request, *args, **kwargs):
send_mail = request.data.get('send_email', True)
serializer = OrderPaymentCreateSerializer(data=request.data, context=self.get_serializer_context())
serializer.is_valid(raise_exception=True)
with transaction.atomic():
@@ -975,8 +954,7 @@ class PaymentViewSet(CreateModelMixin, viewsets.ReadOnlyModelViewSet):
user=self.request.user if self.request.user.is_authenticated else None,
auth=self.request.auth,
count_waitinglist=False,
force=request.data.get('force', False),
send_mail=send_mail,
force=request.data.get('force', False)
)
except Quota.QuotaExceededException:
pass

View File

@@ -6,9 +6,7 @@ from django.shortcuts import get_object_or_404
from django.utils.functional import cached_property
from django_filters.rest_framework import DjangoFilterBackend, FilterSet
from django_scopes import scopes_disabled
from rest_framework import (
filters, mixins, serializers, status, views, viewsets,
)
from rest_framework import filters, mixins, serializers, status, viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import MethodNotAllowed, PermissionDenied
from rest_framework.mixins import CreateModelMixin, DestroyModelMixin
@@ -17,18 +15,15 @@ from rest_framework.viewsets import GenericViewSet
from pretix.api.models import OAuthAccessToken
from pretix.api.serializers.organizer import (
DeviceSerializer, GiftCardSerializer, GiftCardTransactionSerializer,
OrganizerSerializer, OrganizerSettingsSerializer, SeatingPlanSerializer,
TeamAPITokenSerializer, TeamInviteSerializer, TeamMemberSerializer,
TeamSerializer,
DeviceSerializer, GiftCardSerializer, OrganizerSerializer,
SeatingPlanSerializer, TeamAPITokenSerializer, TeamInviteSerializer,
TeamMemberSerializer, TeamSerializer,
)
from pretix.base.models import (
Device, GiftCard, GiftCardTransaction, Organizer, SeatingPlan, Team,
TeamAPIToken, TeamInvite, User,
Device, GiftCard, Organizer, SeatingPlan, Team, TeamAPIToken, TeamInvite,
User,
)
from pretix.base.settings import SETTINGS_AFFECTING_CSS
from pretix.helpers.dicts import merge_dicts
from pretix.presale.style import regenerate_organizer_css
class OrganizerViewSet(viewsets.ReadOnlyModelViewSet):
@@ -196,24 +191,6 @@ class GiftCardViewSet(viewsets.ModelViewSet):
raise MethodNotAllowed("Gift cards cannot be deleted.")
class GiftCardTransactionViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = GiftCardTransactionSerializer
queryset = GiftCardTransaction.objects.none()
permission = 'can_manage_gift_cards'
write_permission = 'can_manage_gift_cards'
@cached_property
def giftcard(self):
if self.request.GET.get('include_accepted') == 'true':
qs = self.request.organizer.accepted_gift_cards
else:
qs = self.request.organizer.issued_gift_cards.all()
return get_object_or_404(qs, pk=self.kwargs.get('giftcard'))
def get_queryset(self):
return self.giftcard.transactions.select_related('order', 'order__event')
class TeamViewSet(viewsets.ModelViewSet):
serializer_class = TeamSerializer
queryset = Team.objects.none()
@@ -419,37 +396,3 @@ class DeviceViewSet(mixins.CreateModelMixin,
data=self.request.data
)
return inst
class OrganizerSettingsView(views.APIView):
permission = 'can_change_organizer_settings'
def get(self, request, *args, **kwargs):
s = OrganizerSettingsSerializer(instance=request.organizer.settings, organizer=request.organizer)
if 'explain' in request.GET:
return Response({
fname: {
'value': s.data[fname],
'label': getattr(field, '_label', fname),
'help_text': getattr(field, '_help_text', None)
} for fname, field in s.fields.items()
})
return Response(s.data)
def patch(self, request, *wargs, **kwargs):
s = OrganizerSettingsSerializer(
instance=request.organizer.settings, data=request.data, partial=True,
organizer=request.organizer
)
s.is_valid(raise_exception=True)
with transaction.atomic():
s.save()
self.request.organizer.log_action(
'pretix.organizer.settings', user=self.request.user, auth=self.request.auth, data={
k: v for k, v in s.validated_data.items()
}
)
if any(p in s.changed_data for p in SETTINGS_AFFECTING_CSS):
regenerate_organizer_css.apply_async(args=(request.organizer.pk,))
s = OrganizerSettingsSerializer(instance=request.organizer.settings, organizer=request.organizer)
return Response(s.data)

View File

@@ -7,7 +7,7 @@ import requests
from celery.exceptions import MaxRetriesExceededError
from django.db.models import Exists, OuterRef, Q
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _, pgettext_lazy
from django.utils.translation import gettext_lazy as _
from django_scopes import scope, scopes_disabled
from requests import RequestException
@@ -97,67 +97,6 @@ class ParametrizedOrderWebhookEvent(WebhookEvent):
}
class ParametrizedEventWebhookEvent(WebhookEvent):
def __init__(self, action_type, verbose_name):
self._action_type = action_type
self._verbose_name = verbose_name
super().__init__()
@property
def action_type(self):
return self._action_type
@property
def verbose_name(self):
return self._verbose_name
def build_payload(self, logentry: LogEntry):
if logentry.action_type == 'pretix.event.deleted':
organizer = logentry.content_object
return {
'notification_id': logentry.pk,
'organizer': organizer.slug,
'event': logentry.parsed_data.get('slug'),
'action': logentry.action_type,
}
event = logentry.content_object
if not event:
return None
return {
'notification_id': logentry.pk,
'organizer': event.organizer.slug,
'event': event.slug,
'action': logentry.action_type,
}
class ParametrizedSubEventWebhookEvent(WebhookEvent):
def __init__(self, action_type, verbose_name):
self._action_type = action_type
self._verbose_name = verbose_name
super().__init__()
@property
def action_type(self):
return self._action_type
@property
def verbose_name(self):
return self._verbose_name
def build_payload(self, logentry: LogEntry):
# do not use content_object, this is also called in deletion
return {
'notification_id': logentry.pk,
'organizer': logentry.event.organizer.slug,
'event': logentry.event.slug,
'subevent': logentry.object_id,
'action': logentry.action_type,
}
class ParametrizedOrderPositionWebhookEvent(ParametrizedOrderWebhookEvent):
def build_payload(self, logentry: LogEntry):
@@ -230,69 +169,44 @@ def register_default_webhook_events(sender, **kwargs):
'pretix.event.checkin.reverted',
_('Ticket check-in reverted'),
),
ParametrizedEventWebhookEvent(
'pretix.event.added',
_('Event created'),
),
ParametrizedEventWebhookEvent(
'pretix.event.changed',
_('Event details changed'),
),
ParametrizedEventWebhookEvent(
'pretix.event.deleted',
_('Event details changed'),
),
ParametrizedSubEventWebhookEvent(
'pretix.subevent.added',
pgettext_lazy('subevent', 'Event series date added'),
),
ParametrizedSubEventWebhookEvent(
'pretix.subevent.changed',
pgettext_lazy('subevent', 'Event series date changed'),
),
ParametrizedSubEventWebhookEvent(
'pretix.subevent.deleted',
pgettext_lazy('subevent', 'Event series date deleted'),
),
)
@app.task(base=TransactionAwareTask, acks_late=True)
def notify_webhooks(logentry_ids: list):
if not isinstance(logentry_ids, list):
logentry_ids = [logentry_ids]
qs = LogEntry.all.select_related('event', 'event__organizer').filter(id__in=logentry_ids)
_org, _at, webhooks = None, None, None
for logentry in qs:
if not logentry.organizer:
break # We need to know the organizer
def notify_webhooks(logentry_id: int):
logentry = LogEntry.all.select_related('event', 'event__organizer').get(id=logentry_id)
notification_type = logentry.webhook_type
if not logentry.organizer:
return # We need to know the organizer
if not notification_type:
break # Ignore, no webhooks for this event type
types = get_all_webhook_events()
notification_type = None
typepath = logentry.action_type
while not notification_type and '.' in typepath:
notification_type = types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
if _org != logentry.organizer or _at != logentry.action_type or webhooks is None:
_org = logentry.organizer
_at = logentry.action_type
if not notification_type:
return # Ignore, no webhooks for this event type
# All webhooks that registered for this notification
event_listener = WebHookEventListener.objects.filter(
webhook=OuterRef('pk'),
action_type=notification_type.action_type
)
webhooks = WebHook.objects.annotate(has_el=Exists(event_listener)).filter(
organizer=logentry.organizer,
has_el=True,
enabled=True
)
if logentry.event_id:
webhooks = webhooks.filter(
Q(all_events=True) | Q(limit_events__pk=logentry.event_id)
)
# All webhooks that registered for this notification
event_listener = WebHookEventListener.objects.filter(
webhook=OuterRef('pk'),
action_type=notification_type.action_type
)
for wh in webhooks:
send_webhook.apply_async(args=(logentry.id, notification_type.action_type, wh.pk))
webhooks = WebHook.objects.annotate(has_el=Exists(event_listener)).filter(
organizer=logentry.organizer,
has_el=True,
enabled=True
)
if logentry.event_id:
webhooks = webhooks.filter(
Q(all_events=True) | Q(limit_events__pk=logentry.event_id)
)
for wh in webhooks:
send_webhook.apply_async(args=(logentry_id, notification_type.action_type, wh.pk))
@app.task(base=ProfiledTask, bind=True, max_retries=9, acks_late=True)

View File

@@ -73,8 +73,8 @@ banlist = [
"wtf"
]
banlist_regex = re.compile('(' + '|'.join(banlist) + ')')
blacklist_regex = re.compile('(' + '|'.join(banlist) + ')')
def banned(string):
return bool(banlist_regex.search(string.lower()))
return bool(blacklist_regex.search(string.lower()))

View File

@@ -4,4 +4,3 @@ from .invoices import * # noqa
from .json import * # noqa
from .mail import * # noqa
from .orderlist import * # noqa
from .waitinglist import * # noqa

View File

@@ -41,7 +41,7 @@ class MailExporter(BaseExporter):
initial=[Order.STATUS_PENDING, Order.STATUS_PAID],
choices=Order.STATUS_CHOICE,
widget=forms.CheckboxSelectMultiple,
required=True
required=False
)),
]
)

View File

@@ -53,23 +53,9 @@ class OrderListExporter(MultiSheetListExporter):
initial=True,
required=False
)),
('include_payment_amounts',
forms.BooleanField(
label=_('Include payment amounts'),
initial=False,
required=False
)),
]
)
def _get_all_payment_methods(self, qs):
pps = dict(get_all_payment_providers())
return sorted([(pp, pps[pp]) for pp in set(
OrderPayment.objects.exclude(provider='free').filter(order__event__in=self.events).values_list(
'provider', flat=True
).distinct()
)], key=lambda pp: pp[0])
def _get_all_tax_rates(self, qs):
tax_rates = set(
a for a
@@ -147,8 +133,8 @@ class OrderListExporter(MultiSheetListExporter):
for k, label, w in name_scheme['fields']:
headers.append(label)
headers += [
_('Address'), _('ZIP code'), _('City'), _('Country'), pgettext('address', 'State'),
_('Custom address field'), _('VAT ID'), _('Date of last payment'), _('Fees'), _('Order locale')
_('Address'), _('ZIP code'), _('City'), _('Country'), pgettext('address', 'State'), _('VAT ID'),
_('Date of last payment'), _('Fees'), _('Order locale')
]
for tr in tax_rates:
@@ -164,10 +150,6 @@ class OrderListExporter(MultiSheetListExporter):
headers.append(_('Comment'))
headers.append(_('Positions'))
headers.append(_('Payment providers'))
if form_data.get('include_payment_amounts'):
payment_methods = self._get_all_payment_methods(qs)
for id, vn in payment_methods:
headers.append(_('Paid by {method}').format(method=vn))
yield headers
@@ -181,23 +163,6 @@ class OrderListExporter(MultiSheetListExporter):
taxsum=Sum('tax_value'), grosssum=Sum('value')
)
}
if form_data.get('include_payment_amounts'):
payment_sum_cache = {
(o['order__id'], o['provider']): o['grosssum'] for o in
OrderPayment.objects.values('provider', 'order__id').order_by().filter(
state__in=[OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED]
).annotate(
grosssum=Sum('amount')
)
}
refund_sum_cache = {
(o['order__id'], o['provider']): o['grosssum'] for o in
OrderRefund.objects.values('provider', 'order__id').order_by().filter(
state__in=[OrderRefund.REFUND_STATE_DONE, OrderRefund.REFUND_STATE_TRANSIT]
).annotate(
grosssum=Sum('amount')
)
}
sum_cache = {
(o['order__id'], o['tax_rate']): o for o in
OrderPosition.objects.values('tax_rate', 'order__id').order_by().annotate(
@@ -235,11 +200,10 @@ class OrderListExporter(MultiSheetListExporter):
order.invoice_address.country if order.invoice_address.country else
order.invoice_address.country_old,
order.invoice_address.state,
order.invoice_address.custom_field,
order.invoice_address.vat_id,
]
except InvoiceAddress.DoesNotExist:
row += [''] * (9 + (len(name_scheme['fields']) if name_scheme and len(name_scheme['fields']) > 1 else 0))
row += [''] * (8 + (len(name_scheme['fields']) if name_scheme and len(name_scheme['fields']) > 1 else 0))
row += [
order.payment_date.astimezone(tz).strftime('%Y-%m-%d') if order.payment_date else '',
@@ -270,14 +234,6 @@ class OrderListExporter(MultiSheetListExporter):
str(self.providers.get(p, p)) for p in sorted(set((order.payment_providers or '').split(',')))
if p and p != 'free'
]))
if form_data.get('include_payment_amounts'):
payment_methods = self._get_all_payment_methods(qs)
for id, vn in payment_methods:
row.append(
payment_sum_cache.get((order.id, id), Decimal('0.00')) -
refund_sum_cache.get((order.id, id), Decimal('0.00'))
)
yield row
def iterate_fees(self, form_data: dict):

View File

@@ -1,165 +0,0 @@
from collections import OrderedDict
import pytz
from django import forms
from django.db.models import F, Q
from django.dispatch import receiver
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _, pgettext_lazy
from pretix.base.models.waitinglist import WaitingListEntry
from ..exporter import ListExporter
from ..signals import (
register_data_exporters, register_multievent_data_exporters,
)
class WaitingListExporter(ListExporter):
identifier = 'waitinglist'
verbose_name = _('Waiting list')
# map selected status to label and queryset-filter
status_filters = [
(
'',
_('All entries'),
lambda qs: qs
),
(
'awaiting-voucher',
_('Waiting for a voucher'),
lambda qs: qs.filter(voucher__isnull=True)
),
(
'voucher-assigned',
_('Voucher assigned'),
lambda qs: qs.filter(voucher__isnull=False)
),
(
'awaiting-redemption',
_('Waiting for redemption'),
lambda qs: qs.filter(
voucher__isnull=False,
voucher__redeemed__lt=F('voucher__max_usages'),
).filter(Q(voucher__valid_until__isnull=True) | Q(voucher__valid_until__gt=now()))
),
(
'voucher-redeemed',
_('Voucher redeemed'),
lambda qs: qs.filter(
voucher__isnull=False,
voucher__redeemed__gte=F('voucher__max_usages'),
)
),
(
'voucher-expired',
_('Voucher expired'),
lambda qs: qs.filter(
voucher__isnull=False,
voucher__redeemed__lt=F('voucher__max_usages'),
voucher__valid_until__isnull=False,
voucher__valid_until__lte=now()
)
),
]
def iterate_list(self, form_data):
# create dicts for easier access by key, which is passed by form_data[status]
status_labels = {k: v for k, v, c in self.status_filters}
queryset_mutators = {k: c for k, v, c in self.status_filters}
entries = WaitingListEntry.objects.filter(
event__in=self.events,
).select_related(
'item', 'variation', 'voucher', 'subevent'
).order_by('created')
# apply filter to queryset/entries according to status
# if unknown status-filter is given, django will handle the error
status_filter = form_data.get("status", "")
entries = queryset_mutators[status_filter](entries)
headers = [
_('Date'),
_('Email'),
_('Product name'),
_('Variation'),
_('Event slug'),
_('Event name'),
pgettext_lazy('subevents', 'Date'), # Name of subevent
_('Start date'), # Start date of subevent or event
_('End date'), # End date of subevent or event
_('Language'),
_('Priority'),
_('Status'),
_('Voucher code'),
]
yield headers
yield self.ProgressSetTotal(total=len(entries))
for entry in entries:
if entry.voucher:
if entry.voucher.redeemed >= entry.voucher.max_usages:
status_label = status_labels['voucher-redeemed']
elif not entry.voucher.is_active():
status_label = status_labels['voucher-expired']
else:
status_label = status_labels['voucher-assigned']
else:
status_label = status_labels['awaiting-voucher']
# which event should be used to output dates in columns "Start date" and "End date"
event_for_date_columns = entry.subevent if entry.subevent else entry.event
tz = pytz.timezone(entry.event.settings.timezone)
datetime_format = '%Y-%m-%d %H:%M:%S'
row = [
entry.created.astimezone(tz).strftime(datetime_format), # alternative: .isoformat(),
entry.email,
str(entry.item) if entry.item else "",
str(entry.variation) if entry.variation else "",
entry.event.slug,
entry.event.name,
entry.subevent.name if entry.subevent else "",
event_for_date_columns.date_from.astimezone(tz).strftime(datetime_format),
event_for_date_columns.date_to.astimezone(tz).strftime(datetime_format) if event_for_date_columns.date_to else "",
entry.locale,
str(entry.priority),
status_label,
entry.voucher.code if entry.voucher else '',
]
yield row
@property
def additional_form_fields(self):
return OrderedDict(
[
('status',
forms.ChoiceField(
label=_('Status'),
initial=['awaiting-voucher'],
required=False,
choices=[(k, v) for (k, v, c) in self.status_filters]
)),
]
)
def get_filename(self):
if self.is_multievent:
event = self.events.first()
slug = event.organizer.slug if len(self.events) > 1 else event.slug
else:
slug = self.event.slug
return '{}_waitinglist'.format(slug)
@receiver(register_data_exporters, dispatch_uid="exporter_waitinglist")
def register_waitinglist_exporter(sender, **kwargs):
return WaitingListExporter
@receiver(register_multievent_data_exporters, dispatch_uid="multiexporter_waitinglist")
def register_multievent_i_waitinglist_exporter(sender, **kwargs):
return WaitingListExporter

View File

@@ -13,13 +13,10 @@ from babel import localedata
from django import forms
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db.models import QuerySet
from django.forms import Select
from django.utils.formats import date_format
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.timezone import get_current_timezone
from django.utils.translation import (
get_language, gettext_lazy as _, pgettext_lazy,
)
@@ -37,9 +34,7 @@ from pretix.base.forms.widgets import (
)
from pretix.base.i18n import language
from pretix.base.models import InvoiceAddress, Question, QuestionOption
from pretix.base.models.tax import (
EU_COUNTRIES, cc_to_vat_prefix, is_eu_country,
)
from pretix.base.models.tax import EU_COUNTRIES, cc_to_vat_prefix
from pretix.base.settings import (
COUNTRIES_WITH_STATE_IN_ADDRESS, PERSON_NAME_SALUTATIONS,
PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS,
@@ -237,43 +232,6 @@ class QuestionCheckboxSelectMultiple(forms.CheckboxSelectMultiple):
option_template_name = 'pretixbase/forms/widgets/checkbox_option_with_links.html'
class MinDateValidator(MinValueValidator):
def __call__(self, value):
try:
return super().__call__(value)
except ValidationError as e:
e.params['limit_value'] = date_format(e.params['limit_value'], 'SHORT_DATE_FORMAT')
raise e
class MinDateTimeValidator(MinValueValidator):
def __call__(self, value):
try:
return super().__call__(value)
except ValidationError as e:
e.params['limit_value'] = date_format(e.params['limit_value'].astimezone(get_current_timezone()), 'SHORT_DATETIME_FORMAT')
raise e
class MaxDateValidator(MaxValueValidator):
def __call__(self, value):
try:
return super().__call__(value)
except ValidationError as e:
e.params['limit_value'] = date_format(e.params['limit_value'], 'SHORT_DATE_FORMAT')
raise e
class MaxDateTimeValidator(MaxValueValidator):
def __call__(self, value):
try:
return super().__call__(value)
except ValidationError as e:
e.params['limit_value'] = date_format(e.params['limit_value'].astimezone(get_current_timezone()), 'SHORT_DATETIME_FORMAT')
raise e
class BaseQuestionsForm(forms.Form):
"""
This form class is responsible for asking order-related questions. This includes
@@ -432,10 +390,9 @@ class BaseQuestionsForm(forms.Form):
elif q.type == Question.TYPE_NUMBER:
field = forms.DecimalField(
label=label, required=required,
min_value=q.valid_number_min or Decimal('0.00'),
max_value=q.valid_number_max,
help_text=q.help_text,
initial=initial.answer if initial else None,
min_value=Decimal('0.00'),
)
elif q.type == Question.TYPE_STRING:
field = forms.CharField(
@@ -494,21 +451,12 @@ class BaseQuestionsForm(forms.Form):
max_size=10 * 1024 * 1024,
)
elif q.type == Question.TYPE_DATE:
attrs = {}
if q.valid_date_min:
attrs['data-min'] = q.valid_date_min.isoformat()
if q.valid_date_max:
attrs['data-max'] = q.valid_date_max.isoformat()
field = forms.DateField(
label=label, required=required,
help_text=help_text,
initial=dateutil.parser.parse(initial.answer).date() if initial and initial.answer else None,
widget=DatePickerWidget(attrs),
widget=DatePickerWidget(),
)
if q.valid_date_min:
field.validators.append(MinDateValidator(q.valid_date_min))
if q.valid_date_max:
field.validators.append(MaxDateValidator(q.valid_date_max))
elif q.type == Question.TYPE_TIME:
field = forms.TimeField(
label=label, required=required,
@@ -521,16 +469,8 @@ class BaseQuestionsForm(forms.Form):
label=label, required=required,
help_text=help_text,
initial=dateutil.parser.parse(initial.answer).astimezone(tz) if initial and initial.answer else None,
widget=SplitDateTimePickerWidget(
time_format=get_format_without_seconds('TIME_INPUT_FORMATS'),
min_date=q.valid_datetime_min,
max_date=q.valid_datetime_max
),
widget=SplitDateTimePickerWidget(time_format=get_format_without_seconds('TIME_INPUT_FORMATS')),
)
if q.valid_datetime_min:
field.validators.append(MinDateTimeValidator(q.valid_datetime_min))
if q.valid_datetime_max:
field.validators.append(MaxDateTimeValidator(q.valid_datetime_max))
elif q.type == Question.TYPE_PHONENUMBER:
babel_locale = 'en'
# Babel, and therefore django-phonenumberfield, do not support our custom locales such das de_Informal
@@ -708,7 +648,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
self.fields['state'].widget.is_required = True
# Without JavaScript the VAT ID field is not hidden, so we empty the field if a country outside the EU is selected.
if cc and not is_eu_country(cc) and fprefix + 'vat_id' in self.data:
if cc and cc not in EU_COUNTRIES and fprefix + 'vat_id' in self.data:
self.data = self.data.copy()
del self.data[fprefix + 'vat_id']
@@ -758,7 +698,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
if not data.get('is_business'):
data['company'] = ''
data['vat_id'] = ''
if data.get('is_business') and not is_eu_country(data.get('country')):
if data.get('is_business') and not data.get('country') in EU_COUNTRIES:
data['vat_id'] = ''
if self.event.settings.invoice_address_required:
if data.get('is_business') and not data.get('company'):
@@ -782,7 +722,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
self.cleaned_data['country'] = ''
if self.validate_vat_id and self.instance.vat_id_validated and 'vat_id' not in self.changed_data:
pass
elif self.validate_vat_id and data.get('is_business') and is_eu_country(data.get('country')) and data.get('vat_id'):
elif self.validate_vat_id and data.get('is_business') and data.get('country') in EU_COUNTRIES and data.get('vat_id'):
if data.get('vat_id')[:2] != cc_to_vat_prefix(str(data.get('country'))):
raise ValidationError(_('Your VAT ID does not match the selected country.'))
try:

View File

@@ -1,10 +1,9 @@
import os
from datetime import date
from django import forms
from django.utils.formats import get_format
from django.utils.functional import lazy
from django.utils.timezone import get_current_timezone, now
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
@@ -93,7 +92,7 @@ class UploadedFileWidget(forms.ClearableFileInput):
class SplitDateTimePickerWidget(forms.SplitDateTimeWidget):
template_name = 'pretixbase/forms/widgets/splitdatetime.html'
def __init__(self, attrs=None, date_format=None, time_format=None, min_date=None, max_date=None):
def __init__(self, attrs=None, date_format=None, time_format=None):
attrs = attrs or {}
if 'placeholder' in attrs:
del attrs['placeholder']
@@ -107,14 +106,6 @@ class SplitDateTimePickerWidget(forms.SplitDateTimeWidget):
time_attrs['class'] += ' timepickerfield'
date_attrs['autocomplete'] = 'date-picker-do-not-autofill'
time_attrs['autocomplete'] = 'time-picker-do-not-autofill'
if min_date:
date_attrs['data-min'] = (
min_date if isinstance(min_date, date) else min_date.astimezone(get_current_timezone()).date()
).isoformat()
if max_date:
date_attrs['data-max'] = (
max_date if isinstance(max_date, date) else max_date.astimezone(get_current_timezone()).date()
).isoformat()
def date_placeholder():
df = date_format or get_format('DATE_INPUT_FORMATS')[0]

View File

@@ -3,7 +3,7 @@ from urllib.parse import urlsplit
import pytz
from django.conf import settings
from django.http import Http404, HttpRequest, HttpResponse
from django.http import HttpRequest, HttpResponse, Http404
from django.middleware.common import CommonMiddleware
from django.urls import get_script_prefix
from django.utils import timezone, translation

View File

@@ -0,0 +1,49 @@
# Generated by Django 3.0.10 on 2020-10-30 21:09
import json
from django.db import migrations
def migrate_tax_rules(apps, schema_editor):
TaxRule = apps.get_model('pretixbase', 'TaxRule')
for tr in TaxRule.objects.filter(eu_reverse_charge=True):
if tr.custom_rules and tr.custom_rules != '[]':
# Custom rules take precedence
continue
r = [{
'country': str(tr.home_country),
'address_type': '',
'action': 'vat'
}, {
'country': 'EU',
'address_type': 'business_vat_id',
'action': 'reverse'
}, {
'country': 'EU',
'address_type': '',
'action': 'vat'
}, {
'country': 'ZZ',
'address_type': '',
'action': 'no'
}]
tr.custom_rules = json.dumps(r)
tr.save()
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0169_checkinlist_gates'),
]
operations = [
migrations.RunPython(migrate_tax_rules, migrations.RunPython.noop),
migrations.RemoveField(
model_name='taxrule',
name='eu_reverse_charge',
),
migrations.RemoveField(
model_name='taxrule',
name='home_country',
),
]

View File

@@ -1,20 +0,0 @@
# Generated by Django 3.0.9 on 2020-11-23 15:51
from django.db import migrations
def remove_old_settings(app, schema_editor):
EventSettingsStore = app.get_model('pretixbase', 'Event_SettingsStore')
EventSettingsStore.objects.filter(key__startswith='payment_', key__endswith='__hidden_url').delete()
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0169_checkinlist_gates'),
]
operations = [
migrations.RunPython(remove_old_settings, migrations.RunPython.noop)
]

View File

@@ -1,49 +0,0 @@
# Generated by Django 3.0.11 on 2020-11-26 16:35
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0170_remove_hidden_urls'),
]
operations = [
migrations.AddField(
model_name='question',
name='valid_date_max',
field=models.DateField(blank=True, null=True),
),
migrations.AddField(
model_name='question',
name='valid_date_min',
field=models.DateField(blank=True, null=True),
),
migrations.AddField(
model_name='question',
name='valid_datetime_max',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='question',
name='valid_datetime_min',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='question',
name='valid_number_max',
field=models.DecimalField(decimal_places=6, max_digits=16, null=True),
),
migrations.AddField(
model_name='question',
name='valid_number_min',
field=models.DecimalField(decimal_places=6, max_digits=16, null=True),
),
migrations.AlterField(
model_name='seat',
name='product',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='seats', to='pretixbase.Item'),
),
]

View File

@@ -1,20 +0,0 @@
# Generated by Django 3.0.9 on 2020-12-02 12:37
from django.db import migrations
import pretix.base.models.fields
from pretix.base.channels import get_all_sales_channels
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0171_auto_20201126_1635'),
]
operations = [
migrations.AddField(
model_name='event',
name='sales_channels',
field=pretix.base.models.fields.MultiStringField(default=list(get_all_sales_channels().keys())),
),
]

View File

@@ -49,8 +49,9 @@ class LoggingMixin:
:param user: The user performing the action (optional)
"""
from pretix.api.models import OAuthAccessToken, OAuthApplication
from pretix.api.webhooks import notify_webhooks
from pretix.api.webhooks import get_all_webhook_events, notify_webhooks
from ..notifications import get_all_notification_types
from ..services.notifications import notify
from .devices import Device
from .event import Event
@@ -92,11 +93,21 @@ class LoggingMixin:
if save:
logentry.save()
if logentry.notification_type:
notify.apply_async(args=(logentry.pk,))
if logentry.webhook_type:
notify_webhooks.apply_async(args=(logentry.pk,))
no_types = get_all_notification_types()
wh_types = get_all_webhook_events()
no_type = None
wh_type = None
typepath = logentry.action_type
while (not no_type or not wh_types) and '.' in typepath:
wh_type = wh_type or wh_types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
no_type = no_type or no_types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
if no_type:
notify.apply_async(args=(logentry.pk,))
if wh_type:
notify_webhooks.apply_async(args=(logentry.pk,))
return logentry

View File

@@ -20,7 +20,7 @@ class CheckinList(LoggedModel):
include_pending = models.BooleanField(verbose_name=pgettext_lazy('checkin', 'Include pending orders'),
default=False,
help_text=_('With this option, people will be able to check in even if the '
'order has not been paid.'))
'order have not been paid.'))
gates = models.ManyToManyField(
'Gate', verbose_name=_("Gates"), blank=True,
help_text=_("Does not have any effect for the validation of tickets, only for the automatic configuration of "

View File

@@ -222,15 +222,3 @@ class Device(LoggedModel):
return self.organizer.events.all()
else:
return self.limit_events.all()
def get_events_with_permission(self, permission, request=None):
"""
Returns a queryset of events the device has a specific permissions to.
:param request: Ignored, for compatibility with User model
:return: Iterable of Events
"""
if permission in self.permission_set():
return self.get_events_with_any_permission()
else:
return self.organizer.events.none()

View File

@@ -23,7 +23,6 @@ from django_scopes import ScopedManager, scopes_disabled
from i18nfield.fields import I18nCharField, I18nTextField
from pretix.base.models.base import LoggedModel
from pretix.base.models.fields import MultiStringField
from pretix.base.reldate import RelativeDateWrapper
from pretix.base.validators import EventSlugBanlistValidator
from pretix.helpers.database import GroupConcat
@@ -119,49 +118,25 @@ class EventMixin:
def timezone(self):
return pytz.timezone(self.settings.timezone)
@property
def effective_presale_end(self):
"""
Returns the effective presale end date, taking for subevents into consideration if the presale end
date might have been further limited by the event-level presale end date
"""
if isinstance(self, SubEvent):
presale_ends = [self.presale_end, self.event.presale_end]
return min(filter(lambda x: x is not None, presale_ends)) if any(presale_ends) else None
else:
return self.presale_end
@property
def presale_has_ended(self):
"""
Is true, when ``presale_end`` is set and in the past.
"""
if self.effective_presale_end:
return now() > self.effective_presale_end
if self.presale_end:
return now() > self.presale_end
elif self.date_to:
return now() > self.date_to
else:
return now().astimezone(self.timezone).date() > self.date_from.astimezone(self.timezone).date()
@property
def effective_presale_start(self):
"""
Returns the effective presale start date, taking for subevents into consideration if the presale start
date might have been further limited by the event-level presale start date
"""
if isinstance(self, SubEvent):
presale_starts = [self.presale_start, self.event.presale_start]
return max(filter(lambda x: x is not None, presale_starts)) if any(presale_starts) else None
else:
return self.presale_start
@property
def presale_is_running(self):
"""
Is true, when ``presale_end`` is not set or in the future and ``presale_start`` is not
set or in the past.
"""
if self.effective_presale_start and now() < self.effective_presale_start:
if self.presale_start and now() < self.presale_start:
return False
return not self.presale_has_ended
@@ -269,34 +244,6 @@ class EventMixin:
return Quota.AVAILABILITY_RESERVED
return Quota.AVAILABILITY_GONE
def free_seats(self, ignore_voucher=None, sales_channel='web', include_blocked=False):
qs_annotated = self._seats(ignore_voucher=ignore_voucher)
qs = qs_annotated.filter(has_order=False, has_cart=False, has_voucher=False)
if self.settings.seating_minimal_distance > 0:
qs = qs.filter(has_closeby_taken=False)
if not (sales_channel in self.settings.seating_allow_blocked_seats_for_channel or include_blocked):
qs = qs.filter(blocked=False)
return qs
def total_seats(self, ignore_voucher=None):
return self._seats(ignore_voucher=ignore_voucher)
def taken_seats(self, ignore_voucher=None):
return self._seats(ignore_voucher=ignore_voucher).filter(has_order=True)
def blocked_seats(self, ignore_voucher=None):
qs = self._seats(ignore_voucher=ignore_voucher)
q = (
Q(has_cart=True)
| Q(has_voucher=True)
| Q(blocked=True)
)
if self.settings.seating_minimal_distance > 0:
q |= Q(has_closeby_taken=True, has_order=False)
return qs.filter(q)
@settings_hierarkey.add(parent_field='organizer', cache_namespace='event')
class Event(EventMixin, LoggedModel):
@@ -332,8 +279,6 @@ class Event(EventMixin, LoggedModel):
:type plugins: str
:param has_subevents: Enable event series functionality
:type has_subevents: bool
:param sales_channels: A list of sales channel identifiers, that this event is available for sale on
:type sales_channels: list
"""
settings_namespace = 'event'
@@ -412,11 +357,7 @@ class Event(EventMixin, LoggedModel):
)
seating_plan = models.ForeignKey('SeatingPlan', on_delete=models.PROTECT, null=True, blank=True,
related_name='events')
sales_channels = MultiStringField(
verbose_name=_('Restrict to specific sales channels'),
help_text=_('Only sell tickets for this event on the following sales channels.'),
default=['web'],
)
objects = ScopedManager(organizer='organizer')
class Meta:
@@ -453,7 +394,7 @@ class Event(EventMixin, LoggedModel):
if img:
return urljoin(build_absolute_uri(self, 'presale:event.index'), img)
def _seats(self, ignore_voucher=None):
def free_seats(self, ignore_voucher=None, sales_channel='web', include_blocked=False):
from .seating import Seat
qs_annotated = Seat.annotated(self.seats, self.pk, None,
@@ -461,7 +402,13 @@ class Event(EventMixin, LoggedModel):
minimal_distance=self.settings.seating_minimal_distance,
distance_only_within_row=self.settings.seating_distance_within_row)
return qs_annotated
qs = qs_annotated.filter(has_order=False, has_cart=False, has_voucher=False)
if self.settings.seating_minimal_distance > 0:
qs = qs.filter(has_closeby_taken=False)
if not (sales_channel in self.settings.seating_allow_blocked_seats_for_channel or include_blocked):
qs = qs.filter(blocked=False)
return qs
@property
def presale_has_ended(self):
@@ -560,14 +507,11 @@ class Event(EventMixin, LoggedModel):
def copy_data_from(self, other):
from ..signals import event_copy_data
from . import (
Item, ItemAddOn, ItemBundle, ItemCategory, ItemMetaValue, Question,
Quota,
Item, ItemAddOn, ItemCategory, ItemMetaValue, Question, Quota,
)
self.plugins = other.plugins
self.is_public = other.is_public
if other.date_admission:
self.date_admission = self.date_from + (other.date_admission - other.date_from)
self.testmode = other.testmode
self.save()
self.log_action('pretix.object.cloned', data={'source': other.slug, 'source_id': other.pk})
@@ -629,14 +573,6 @@ class Event(EventMixin, LoggedModel):
ia.addon_category = category_map[ia.addon_category.pk]
ia.save()
for ia in ItemBundle.objects.filter(base_item__event=other).prefetch_related('base_item', 'bundled_item', 'bundled_variation'):
ia.pk = None
ia.base_item = item_map[ia.base_item.pk]
ia.bundled_item = item_map[ia.bundled_item.pk]
if ia.bundled_variation:
ia.bundled_variation = variation_map[ia.bundled_variation.pk]
ia.save()
for q in Quota.objects.filter(event=other, subevent__isnull=True).prefetch_related('items', 'variations'):
items = list(q.items.all())
vars = list(q.variations.all())
@@ -1153,13 +1089,19 @@ class SubEvent(EventMixin, LoggedModel):
date_format(self.date_from.astimezone(self.timezone), "TIME_FORMAT") if self.settings.show_times else ""
).strip()
def _seats(self, ignore_voucher=None):
def free_seats(self, ignore_voucher=None, sales_channel='web', include_blocked=False):
from .seating import Seat
qs_annotated = Seat.annotated(self.seats, self.event_id, self,
ignore_voucher_id=ignore_voucher.pk if ignore_voucher else None,
minimal_distance=self.settings.seating_minimal_distance,
distance_only_within_row=self.settings.seating_distance_within_row)
return qs_annotated
qs = qs_annotated.filter(has_order=False, has_cart=False, has_voucher=False)
if self.settings.seating_minimal_distance > 0:
qs = qs.filter(has_closeby_taken=False)
if not (sales_channel in self.settings.seating_allow_blocked_seats_for_channel or include_blocked):
qs = qs.filter(blocked=False)
return qs
@cached_property
def settings(self):

View File

@@ -314,7 +314,7 @@ class Item(LoggedModel):
)
allow_waitinglist = models.BooleanField(
verbose_name=_("Show a waiting list for this ticket"),
help_text=_("This will only work if waiting lists are enabled for this event."),
help_text=_("This will only work of waiting lists are enabled for this event."),
default=True
)
show_quota_left = models.NullBooleanField(
@@ -1084,18 +1084,6 @@ class Question(LoggedModel):
'Question', null=True, blank=True, on_delete=models.SET_NULL, related_name='dependent_questions'
)
dependency_values = MultiStringField(default=[])
valid_number_min = models.DecimalField(decimal_places=6, max_digits=16, null=True, blank=True,
verbose_name=_('Minimum value'), help_text=_('Currently not supported in our apps'))
valid_number_max = models.DecimalField(decimal_places=6, max_digits=16, null=True, blank=True,
verbose_name=_('Maximum value'), help_text=_('Currently not supported in our apps'))
valid_date_min = models.DateField(null=True, blank=True,
verbose_name=_('Minimum value'), help_text=_('Currently not supported in our apps'))
valid_date_max = models.DateField(null=True, blank=True,
verbose_name=_('Maximum value'), help_text=_('Currently not supported in our apps'))
valid_datetime_min = models.DateTimeField(null=True, blank=True,
verbose_name=_('Minimum value'), help_text=_('Currently not supported in our apps'))
valid_datetime_max = models.DateTimeField(null=True, blank=True,
verbose_name=_('Maximum value'), help_text=_('Currently not supported in our apps'))
objects = ScopedManager(organizer='event__organizer')
@@ -1185,24 +1173,14 @@ class Question(LoggedModel):
answer = formats.sanitize_separators(answer)
answer = str(answer).strip()
try:
v = Decimal(answer)
if self.valid_number_min is not None and v < self.valid_number_min:
raise ValidationError(_('The number is to low.'))
if self.valid_number_max is not None and v > self.valid_number_max:
raise ValidationError(_('The number is to high.'))
return v
return Decimal(answer)
except DecimalException:
raise ValidationError(_('Invalid number input.'))
elif self.type == Question.TYPE_DATE:
if isinstance(answer, date):
return answer
try:
dt = dateutil.parser.parse(answer).date()
if self.valid_date_min is not None and dt < self.valid_date_min:
raise ValidationError(_('Please choose a later date.'))
if self.valid_date_max is not None and dt > self.valid_date_max:
raise ValidationError(_('Please choose an earlier date.'))
return dt
return dateutil.parser.parse(answer).date()
except:
raise ValidationError(_('Invalid date input.'))
elif self.type == Question.TYPE_TIME:
@@ -1219,14 +1197,9 @@ class Question(LoggedModel):
dt = dateutil.parser.parse(answer)
if is_naive(dt):
dt = make_aware(dt, pytz.timezone(self.event.settings.timezone))
return dt
except:
raise ValidationError(_('Invalid datetime input.'))
else:
if self.valid_datetime_min is not None and dt < self.valid_datetime_min:
raise ValidationError(_('Please choose a later date.'))
if self.valid_datetime_max is not None and dt > self.valid_datetime_max:
raise ValidationError(_('Please choose an earlier date.'))
return dt
elif self.type == Question.TYPE_COUNTRYCODE and answer:
c = Country(answer.upper())
if c.name:

View File

@@ -63,42 +63,14 @@ class LogEntry(models.Model):
return response
return self.action_type
@property
def webhook_type(self):
from pretix.api.webhooks import get_all_webhook_events
wh_types = get_all_webhook_events()
wh_type = None
typepath = self.action_type
while not wh_type and '.' in typepath:
wh_type = wh_type or wh_types.get(typepath + ('.*' if typepath != self.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
return wh_type
@property
def notification_type(self):
from pretix.base.notifications import get_all_notification_types
no_type = None
no_types = get_all_notification_types()
typepath = self.action_type
while not no_type and '.' in typepath:
no_type = no_type or no_types.get(typepath + ('.*' if typepath != self.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
return no_type
@cached_property
def organizer(self):
from .organizer import Organizer
if self.event:
return self.event.organizer
elif hasattr(self.content_object, 'event'):
return self.content_object.event.organizer
elif hasattr(self.content_object, 'organizer'):
return self.content_object.organizer
elif isinstance(self.content_object, Organizer):
return self.content_object
return None
@cached_property
@@ -216,16 +188,3 @@ class LogEntry(models.Model):
def delete(self, using=None, keep_parents=False):
raise TypeError("Logs cannot be deleted.")
@classmethod
def bulk_postprocess(cls, objects):
from pretix.api.webhooks import notify_webhooks
from ..services.notifications import notify
to_notify = [o.id for o in objects if o.notification_type]
if to_notify:
notify.apply_async(args=(to_notify,))
to_wh = [o.id for o in objects if o.webhook_type]
if to_wh:
notify_webhooks.apply_async(args=(to_wh,))

View File

@@ -639,7 +639,7 @@ class Order(LockModel, LoggedModel):
return
if iteration > 20:
# Safeguard: If we don't find an unused and non-banlisted code within 20 iterations, we increase
# Safeguard: If we don't find an unused and non-blacklisted code within 20 iterations, we increase
# the length.
length += 1
iteration = 0
@@ -1600,10 +1600,6 @@ class OrderPayment(models.Model):
'local_id': r.local_id,
'provider': r.provider,
})
if self.order.pending_sum + r.amount == Decimal('0.00'):
self.refund.done()
return r
@@ -1874,7 +1870,7 @@ class OrderFee(models.Model):
self.tax_rule = self.order.event.settings.tax_rate_default
if self.tax_rule:
tax = self.tax_rule.tax(self.value, base_price_is='gross', invoice_address=ia, force_fixed_gross_price=True)
tax = self.tax_rule.tax(self.value, base_price_is='gross', invoice_address=ia)
self.tax_rate = tax.rate
self.tax_value = tax.tax
else:
@@ -2026,11 +2022,9 @@ class OrderPosition(AbstractPosition):
except InvoiceAddress.DoesNotExist:
ia = None
if self.tax_rule:
tax = self.tax_rule.tax(self.price, invoice_address=ia, base_price_is='gross', force_fixed_gross_price=True)
tax = self.tax_rule.tax(self.price, invoice_address=ia, base_price_is='gross')
self.tax_rate = tax.rate
self.tax_value = tax.tax
if tax.gross != self.price:
raise ValueError('Invalid tax calculation')
else:
self.tax_value = Decimal('0.00')
self.tax_rate = Decimal('0.00')
@@ -2040,7 +2034,6 @@ class OrderPosition(AbstractPosition):
if self.tax_rate is None:
self._calculate_tax()
self.order.touch()
if not self.pk:
while not self.secret or OrderPosition.all.filter(

View File

@@ -357,15 +357,3 @@ class TeamAPIToken(models.Model):
return self.team.organizer.events.all()
else:
return self.team.limit_events.all()
def get_events_with_permission(self, permission, request=None):
"""
Returns a queryset of events the token has a specific permissions to.
:param request: Ignored, for compatibility with User model
:return: Iterable of Events
"""
if getattr(self.team, permission, False):
return self.get_events_with_any_permission()
else:
return self.team.organizer.events.none()

View File

@@ -130,7 +130,7 @@ class Seat(models.Model):
seat_number = models.CharField(max_length=190, blank=True, default="")
seat_label = models.CharField(max_length=190, null=True)
seat_guid = models.CharField(max_length=190, db_index=True)
product = models.ForeignKey('Item', null=True, blank=True, related_name='seats', on_delete=models.SET_NULL)
product = models.ForeignKey('Item', null=True, blank=True, related_name='seats', on_delete=models.CASCADE)
blocked = models.BooleanField(default=False)
sorting_rank = models.BigIntegerField(default=0)
x = models.FloatField(null=True)

View File

@@ -1,18 +1,14 @@
import json
from decimal import Decimal
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.formats import localize
from django.utils.timezone import get_current_timezone, now
from django.utils.translation import gettext_lazy as _, pgettext
from django.utils.translation import gettext_lazy as _
from i18nfield.fields import I18nCharField
from i18nfield.strings import LazyI18nString
from pretix.base.decimal import round_decimal
from pretix.base.models.base import LoggedModel
from pretix.base.templatetags.money import money_filter
from pretix.helpers.countries import FastCountryField
class TaxedPrice:
@@ -87,14 +83,6 @@ EU_CURRENCIES = {
}
def is_eu_country(cc):
cc = str(cc)
if cc == 'GB':
return now().astimezone(get_current_timezone()).year <= 2020
else:
return cc in EU_COUNTRIES
def cc_to_vat_prefix(country_code):
if country_code == 'GR':
return 'EL'
@@ -117,29 +105,11 @@ class TaxRule(LoggedModel):
verbose_name=_("The configured product prices include the tax amount"),
default=True,
)
eu_reverse_charge = models.BooleanField(
verbose_name=_("Use EU reverse charge taxation rules"),
default=False,
help_text=_("Not recommended. Most events will NOT be qualified for reverse charge since the place of "
"taxation is the location of the event. This option disables charging VAT for all customers "
"outside the EU and for business customers in different EU countries who entered a valid EU VAT "
"ID. Only enable this option after consulting a tax counsel. No warranty given for correct tax "
"calculation. USE AT YOUR OWN RISK.")
)
home_country = FastCountryField(
verbose_name=_('Merchant country'),
blank=True,
help_text=_('Your country of residence. This is the country the EU reverse charge rule will not apply in, '
'if configured above.'),
)
custom_rules = models.TextField(blank=True, null=True)
class Meta:
ordering = ('event', 'rate', 'id')
class SaleNotAllowed(Exception):
pass
def allow_delete(self):
from pretix.base.models.orders import OrderFee, OrderPosition
@@ -160,17 +130,13 @@ class TaxRule(LoggedModel):
eu_reverse_charge=False
)
def clean(self):
if self.eu_reverse_charge and not self.home_country:
raise ValidationError(_('You need to set your home country to use the reverse charge feature.'))
def __str__(self):
if self.price_includes_tax:
s = _('incl. {rate}% {name}').format(rate=self.rate, name=self.name)
else:
s = _('plus {rate}% {name}').format(rate=self.rate, name=self.name)
if self.eu_reverse_charge:
s += ' ({})'.format(_('reverse charge enabled'))
if self.has_custom_rules:
s += ' ({})'.format(_('with custom rules'))
return str(s)
@property
@@ -182,14 +148,12 @@ class TaxRule(LoggedModel):
return Decimal('0.00')
if self.has_custom_rules:
rule = self.get_matching_rule(invoice_address)
if rule.get('action', 'vat') == 'block':
raise self.SaleNotAllowed()
if rule.get('action', 'vat') == 'vat' and rule.get('rate') is not None:
return Decimal(rule.get('rate'))
return Decimal(self.rate)
def tax(self, base_price, base_price_is='auto', currency=None, override_tax_rate=None, invoice_address=None,
subtract_from_gross=Decimal('0.00'), gross_price_is_tax_rate: Decimal = None, force_fixed_gross_price=False):
subtract_from_gross=Decimal('0.00'), gross_price_is_tax_rate: Decimal = None):
from .event import Event
try:
currency = currency or self.event.currency
@@ -201,7 +165,7 @@ class TaxRule(LoggedModel):
rate = override_tax_rate
elif invoice_address:
adjust_rate = self.tax_rate_for(invoice_address)
if (adjust_rate == gross_price_is_tax_rate or force_fixed_gross_price) and base_price_is == 'gross':
if adjust_rate == gross_price_is_tax_rate and base_price_is == 'gross':
rate = adjust_rate
elif adjust_rate != rate:
normal_price = self.tax(base_price, base_price_is, currency, subtract_from_gross=subtract_from_gross)
@@ -256,7 +220,7 @@ class TaxRule(LoggedModel):
rules = self._custom_rules
if invoice_address:
for r in rules:
if r['country'] == 'EU' and not is_eu_country(invoice_address.country):
if r['country'] == 'EU' and str(invoice_address.country) not in EU_COUNTRIES:
continue
if r['country'] not in ('ZZ', 'EU') and r['country'] != str(invoice_address.country):
continue
@@ -269,75 +233,16 @@ class TaxRule(LoggedModel):
return r
return {'action': 'vat'}
def invoice_text(self, invoice_address):
if self._custom_rules:
rule = self.get_matching_rule(invoice_address)
t = rule.get('invoice_text', {})
if t and any(l for l in t.values()):
return str(LazyI18nString(t))
if self.is_reverse_charge(invoice_address):
if is_eu_country(invoice_address.country):
return pgettext(
"invoice",
"Reverse Charge: According to Article 194, 196 of Council Directive 2006/112/EEC, VAT liability "
"rests with the service recipient."
)
else:
return pgettext(
"invoice",
"VAT liability rests with the service recipient."
)
def is_reverse_charge(self, invoice_address):
if self._custom_rules:
rule = self.get_matching_rule(invoice_address)
return rule['action'] == 'reverse'
if not self.eu_reverse_charge:
return False
if not invoice_address or not invoice_address.country:
return False
if not is_eu_country(invoice_address.country):
return False
if invoice_address.country == self.home_country:
return False
if invoice_address.is_business and invoice_address.vat_id and invoice_address.vat_id_validated:
return True
return False
def _tax_applicable(self, invoice_address):
if self._custom_rules:
rule = self.get_matching_rule(invoice_address)
if rule.get('action', 'vat') == 'block':
raise self.SaleNotAllowed()
return rule.get('action', 'vat') == 'vat'
if not self.eu_reverse_charge:
# No reverse charge rules? Always apply VAT!
return True
if not invoice_address or not invoice_address.country:
# No country specified? Always apply VAT!
return True
if not is_eu_country(invoice_address.country):
# Non-EU country? Never apply VAT!
return False
if invoice_address.country == self.home_country:
# Within same EU country? Always apply VAT!
return True
if invoice_address.is_business and invoice_address.vat_id and invoice_address.vat_id_validated:
# Reverse charge case
return False
# Consumer in different EU country / invalid VAT
return True
def delete(self, *args, **kwargs):

View File

@@ -513,7 +513,7 @@ class BasePaymentProvider:
return timing and pricing
def payment_form_render(self, request: HttpRequest, total: Decimal, order: Order=None) -> str:
def payment_form_render(self, request: HttpRequest, total: Decimal) -> str:
"""
When the user selects this provider as their preferred payment method,
they will be shown the HTML you return from this method.
@@ -522,15 +522,13 @@ class BasePaymentProvider:
and render the returned form. If your payment method doesn't require
the user to fill out form fields, you should just return a paragraph
of explanatory text.
:param order: Only set when this is a change to a new payment method for an existing order.
"""
form = self.payment_form(request)
template = get_template('pretixpresale/event/checkout_payment_form_default.html')
ctx = {'request': request, 'form': form}
return template.render(ctx)
def checkout_confirm_render(self, request, order: Order=None) -> str:
def checkout_confirm_render(self, request) -> str:
"""
If the user has successfully filled in their payment data, they will be redirected
to a confirmation page which lists all details of their order for a final review.
@@ -539,8 +537,6 @@ class BasePaymentProvider:
In most cases, this should include a short summary of the user's input and
a short explanation on how the payment process will continue.
:param order: Only set when this is a change to a new payment method for an existing order.
"""
raise NotImplementedError() # NOQA

View File

@@ -121,26 +121,6 @@ DEFAULT_VARIABLES = OrderedDict((
'editor_sample': _('John Doe\nSample company\nSesame Street 42\n12345 Any City\nAtlantis'),
'evaluate': lambda op, order, event: op.address_format()
}),
("attendee_street", {
"label": _("Attendee street"),
"editor_sample": 'Sesame Street 42',
"evaluate": lambda op, order, ev: op.street or (op.addon_to.street if op.addon_to else '')
}),
("attendee_zipcode", {
"label": _("Attendee ZIP code"),
"editor_sample": '12345',
"evaluate": lambda op, order, ev: op.zipcode or (op.addon_to.zipcode if op.addon_to else '')
}),
("attendee_city", {
"label": _("Attendee city"),
"editor_sample": 'Any City',
"evaluate": lambda op, order, ev: op.city or (op.addon_to.city if op.addon_to else '')
}),
("attendee_state", {
"label": _("Attendee state"),
"editor_sample": 'Sample State',
"evaluate": lambda op, order, ev: op.state or (op.addon_to.state if op.addon_to else '')
}),
("attendee_country", {
"label": _("Attendee country"),
"editor_sample": 'Atlantis',
@@ -239,31 +219,11 @@ DEFAULT_VARIABLES = OrderedDict((
"editor_sample": _("Sample company"),
"evaluate": lambda op, order, ev: order.invoice_address.company if getattr(order, 'invoice_address', None) else ''
}),
("invoice_street", {
"label": _("Invoice address street"),
"editor_sample": _("Sesame Street 42"),
"evaluate": lambda op, order, ev: order.invoice_address.street if getattr(order, 'invoice_address', None) else ''
}),
("invoice_zipcode", {
"label": _("Invoice address ZIP code"),
"editor_sample": _("12345"),
"evaluate": lambda op, order, ev: order.invoice_address.zipcode if getattr(order, 'invoice_address', None) else ''
}),
("invoice_city", {
"label": _("Invoice address city"),
"editor_sample": _("Sample city"),
"evaluate": lambda op, order, ev: order.invoice_address.city if getattr(order, 'invoice_address', None) else ''
}),
("invoice_state", {
"label": _("Invoice address state"),
"editor_sample": _("Sample State"),
"evaluate": lambda op, order, ev: order.invoice_address.state if getattr(order, 'invoice_address', None) else ''
}),
("invoice_country", {
"label": _("Invoice address country"),
"editor_sample": _("Atlantis"),
"evaluate": lambda op, order, ev: str(getattr(order.invoice_address.country, 'name', '')) if getattr(order, 'invoice_address', None) else ''
}),
("addons", {
"label": _("List of Add-Ons"),
"editor_sample": _("Add-on 1\nAdd-on 2"),

View File

@@ -1,5 +1,4 @@
import base64
import inspect
import struct
from cryptography.hazmat.backends.openssl.backend import Backend
@@ -53,10 +52,10 @@ class BaseTicketSecretGenerator:
return False
def generate_secret(self, item: Item, variation: ItemVariation = None, subevent: SubEvent = None,
attendee_name: str = None, current_secret: str = None, force_invalidate=False) -> str:
current_secret: str = None, force_invalidate=False) -> str:
"""
Generate a new secret for a ticket with product ``item``, variation ``variation``, subevent ``subevent``,
attendee name ``attendee_name`` (can be ``None``) and the current secret ``current_secret`` (if any).
and the current secret ``current_secret`` (if any).
The result must be a string that should only contain the characters ``A-Za-z0-9+/=``.
@@ -71,11 +70,6 @@ class BaseTicketSecretGenerator:
If ``force_invalidate`` is set to ``False`` and ``item``, ``variation`` and ``subevent`` have a different value
as when ``current_secret`` was generated, then this method MAY OR MAY NOT return ``current_secret`` unchanged,
depending on the semantics of the method.
.. note:: While it is guaranteed that ``generate_secret`` and the revocation list process are called every
time the ``item``, ``variation``, or ``subevent`` parameters change, it is currently **NOT**
guaranteed that this process is triggered if the ``attendee_name`` parameter changes. You should
therefore not rely on this value for more than informational or debugging purposes.
"""
raise NotImplementedError()
@@ -86,7 +80,7 @@ class RandomTicketSecretGenerator(BaseTicketSecretGenerator):
use_revocation_list = False
def generate_secret(self, item: Item, variation: ItemVariation = None, subevent: SubEvent = None,
attendee_name: str = None, current_secret: str = None, force_invalidate=False):
current_secret: str = None, force_invalidate=False):
if current_secret and not force_invalidate:
return current_secret
return get_random_string(
@@ -193,17 +187,12 @@ def assign_ticket_secret(event, position, force_invalidate_if_revokation_list_us
gen = event.ticket_secret_generator
if gen.use_revocation_list and force_invalidate_if_revokation_list_used:
force_invalidate = True
kwargs = {}
if 'attendee_name' in inspect.signature(gen.generate_secret).parameters:
kwargs['attendee_name'] = position.attendee_name
secret = gen.generate_secret(
item=position.item,
variation=position.variation,
subevent=position.subevent,
current_secret=position.secret,
force_invalidate=force_invalidate,
**kwargs
force_invalidate=force_invalidate
)
changed = position.secret != secret
if position.secret and changed and gen.use_revocation_list:

View File

@@ -106,7 +106,6 @@ error_messages = {
'seat_unavailable': _('The seat you selected has already been taken. Please select a different seat.'),
'seat_multiple': _('You can not select the same seat multiple times.'),
'gift_card': _("You entered a gift card instead of a voucher. Gift cards can be entered later on when you're asked for your payment details."),
'country_blocked': _('One of the selected products is not available in the selected country.'),
}
@@ -325,8 +324,6 @@ class CartManager:
custom_price_is_net=cp_is_net if cp_is_net is not None else self.event.settings.display_net_prices,
invoice_address=self.invoice_address, force_custom_price=force_custom_price, bundled_sum=bundled_sum
)
except TaxRule.SaleNotAllowed:
raise CartError(error_messages['country_blocked'])
except ValueError as e:
if str(e) == 'price_too_high':
raise CartError(error_messages['price_too_high'])
@@ -1066,7 +1063,6 @@ def update_tax_rates(event: Event, cart_id: str, invoice_address: InvoiceAddress
if pos.tax_rate != rate:
current_net = pos.price - pos.tax_value
new_gross = pos.item.tax(current_net, base_price_is='net', invoice_address=invoice_address).gross
totaldiff += new_gross - pos.price
pos.price = new_gross
pos.includes_tax = rate != Decimal('0.00')
pos.override_tax_rate = rate

View File

@@ -1,13 +1,12 @@
from typing import Any, Dict
from django.conf import settings
from django.core.files.base import ContentFile
from django.utils.timezone import override
from django.utils.translation import gettext
from pretix.base.i18n import LazyLocaleException, language
from pretix.base.models import (
CachedFile, Device, Event, Organizer, TeamAPIToken, User, cachedfile_name,
CachedFile, Event, Organizer, User, cachedfile_name,
)
from pretix.base.services.tasks import (
ProfiledEventTask, ProfiledOrganizerUserTask,
@@ -49,13 +48,7 @@ def export(self, event: Event, fileid: str, provider: str, form_data: Dict[str,
@app.task(base=ProfiledOrganizerUserTask, throws=(ExportError,), bind=True)
def multiexport(self, organizer: Organizer, user: User, device: int, token: int, fileid: str, provider: str, form_data: Dict[str, Any]) -> None:
if device:
device = Device.objects.get(pk=device)
if token:
device = TeamAPIToken.objects.get(pk=token)
allowed_events = (device or token or user).get_events_with_permission('can_view_orders')
def multiexport(self, organizer: Organizer, user: User, fileid: str, provider: str, form_data: Dict[str, Any]) -> None:
def set_progress(val):
if not self.request.called_directly:
self.update_state(
@@ -64,22 +57,10 @@ def multiexport(self, organizer: Organizer, user: User, device: int, token: int,
)
file = CachedFile.objects.get(id=fileid)
if user:
locale = user.locale
timezone = user.timezone
else:
e = allowed_events.first()
if e:
locale = e.settings.locale
timezone = e.settings.timezone
else:
locale = settings.LANGUAGE_CODE
timezone = settings.TIME_ZONE
with language(locale), override(timezone):
if isinstance(form_data['events'][0], str):
events = allowed_events.filter(slug__in=form_data.get('events'), organizer=organizer)
else:
events = allowed_events.filter(pk__in=form_data.get('events'))
with language(user.locale), override(user.timezone):
allowed_events = user.get_events_with_permission('can_view_orders')
events = allowed_events.filter(pk__in=form_data.get('events'))
responses = register_multievent_data_exporters.send(organizer)
for receiver, response in responses:

View File

@@ -24,7 +24,7 @@ from pretix.base.i18n import language
from pretix.base.models import (
Invoice, InvoiceAddress, InvoiceLine, Order, OrderFee,
)
from pretix.base.models.tax import EU_CURRENCIES
from pretix.base.models.tax import EU_COUNTRIES, EU_CURRENCIES
from pretix.base.services.tasks import TransactionAwareTask
from pretix.base.settings import GlobalSettingsObject
from pretix.base.signals import invoice_line_text, periodic_task
@@ -142,8 +142,6 @@ def build_invoice(invoice: Invoice) -> Invoice:
reverse_charge = False
positions.sort(key=lambda p: p.sort_key)
tax_texts = []
for i, p in enumerate(positions):
if not invoice.event.settings.invoice_include_free and p.price == Decimal('0.00') and not p.addon_c:
continue
@@ -180,10 +178,22 @@ def build_invoice(invoice: Invoice) -> Invoice:
if p.tax_rule and p.tax_rule.is_reverse_charge(ia) and p.price and not p.tax_value:
reverse_charge = True
if p.tax_rule:
tax_text = p.tax_rule.invoice_text(ia)
if tax_text and tax_text not in tax_texts:
tax_texts.append(tax_text)
if reverse_charge:
if invoice.additional_text:
invoice.additional_text += "<br /><br />"
if str(invoice.invoice_to_country) in EU_COUNTRIES:
invoice.additional_text += pgettext(
"invoice",
"Reverse Charge: According to Article 194, 196 of Council Directive 2006/112/EEC, VAT liability "
"rests with the service recipient."
)
else:
invoice.additional_text += pgettext(
"invoice",
"VAT liability rests with the service recipient."
)
invoice.reverse_charge = True
invoice.save()
offset = len(positions)
for i, fee in enumerate(invoice.order.fees.all()):
@@ -203,20 +213,6 @@ def build_invoice(invoice: Invoice) -> Invoice:
tax_name=fee.tax_rule.name if fee.tax_rule else ''
)
if fee.tax_rule and fee.tax_rule.is_reverse_charge(ia) and fee.value and not fee.tax_value:
reverse_charge = True
if fee.tax_rule:
tax_text = fee.tax_rule.invoice_text(ia)
if tax_text and tax_text not in tax_texts:
tax_texts.append(tax_text)
if tax_texts:
invoice.additional_text += "<br /><br />"
invoice.additional_text += "<br />".join(tax_texts)
invoice.reverse_charge = reverse_charge
invoice.save()
return invoice

View File

@@ -15,59 +15,55 @@ from pretix.helpers.urls import build_absolute_uri
@app.task(base=TransactionAwareTask, acks_late=True)
@scopes_disabled()
def notify(logentry_ids: list):
if not isinstance(logentry_ids, list):
logentry_ids = [logentry_ids]
def notify(logentry_id: int):
logentry = LogEntry.all.select_related('event', 'event__organizer').get(id=logentry_id)
if not logentry.event:
return # Ignore, we only have event-related notifications right now
types = get_all_notification_types(logentry.event)
qs = LogEntry.all.select_related('event', 'event__organizer').filter(id__in=logentry_ids)
notification_type = None
typepath = logentry.action_type
while not notification_type and '.' in typepath:
notification_type = types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
_event, _at, notify_specific, notify_global = None, None, None, None
for logentry in qs:
if not logentry.event:
break # Ignore, we only have event-related notifications right now
if not notification_type:
return # No suitable plugin
notification_type = logentry.notification_type
# All users that have the permission to get the notification
users = logentry.event.get_users_with_permission(
notification_type.required_permission
).filter(notifications_send=True, is_active=True)
if logentry.user:
users = users.exclude(pk=logentry.user.pk)
if not notification_type:
break # No suitable plugin
# Get all notification settings, both specific to this event as well as global
notify_specific = {
(ns.user, ns.method): ns.enabled
for ns in NotificationSetting.objects.filter(
event=logentry.event,
action_type=notification_type.action_type,
user__pk__in=users.values_list('pk', flat=True)
)
}
notify_global = {
(ns.user, ns.method): ns.enabled
for ns in NotificationSetting.objects.filter(
event__isnull=True,
action_type=notification_type.action_type,
user__pk__in=users.values_list('pk', flat=True)
)
}
if _event != logentry.event or _at != logentry.action_type or notify_global is None:
_event = logentry.event
_at = logentry.action_type
# All users that have the permission to get the notification
users = logentry.event.get_users_with_permission(
notification_type.required_permission
).filter(notifications_send=True, is_active=True)
if logentry.user:
users = users.exclude(pk=logentry.user.pk)
for um, enabled in notify_specific.items():
user, method = um
if enabled:
send_notification.apply_async(args=(logentry_id, notification_type.action_type, user.pk, method))
# Get all notification settings, both specific to this event as well as global
notify_specific = {
(ns.user, ns.method): ns.enabled
for ns in NotificationSetting.objects.filter(
event=logentry.event,
action_type=notification_type.action_type,
user__pk__in=users.values_list('pk', flat=True)
)
}
notify_global = {
(ns.user, ns.method): ns.enabled
for ns in NotificationSetting.objects.filter(
event__isnull=True,
action_type=notification_type.action_type,
user__pk__in=users.values_list('pk', flat=True)
)
}
for um, enabled in notify_specific.items():
user, method = um
if enabled:
send_notification.apply_async(args=(logentry.id, notification_type.action_type, user.pk, method))
for um, enabled in notify_global.items():
user, method = um
if enabled and um not in notify_specific:
send_notification.apply_async(args=(logentry.id, notification_type.action_type, user.pk, method))
for um, enabled in notify_global.items():
user, method = um
if enabled and um not in notify_specific:
send_notification.apply_async(args=(logentry_id, notification_type.action_type, user.pk, method))
@app.task(base=ProfiledTask, acks_late=True)

View File

@@ -89,7 +89,6 @@ error_messages = {
'positions have been removed from your cart.'),
'seat_invalid': _('One of the seats in your order was invalid, we removed the position from your cart.'),
'seat_unavailable': _('One of the seats in your order has been taken in the meantime, we removed the position from your cart.'),
'country_blocked': _('One of the selected products is not available in the selected country.'),
}
logger = logging.getLogger(__name__)
@@ -616,39 +615,34 @@ def _check_positions(event: Event, now_dt: datetime, positions: List[CartPositio
current_discount = cp.price_before_voucher - cp.price
max_discount = max(v_budget[cp.voucher] + current_discount, 0)
try:
if cp.is_bundled:
try:
bundle = cp.addon_to.item.bundles.get(bundled_item=cp.item, bundled_variation=cp.variation)
bprice = bundle.designated_price or 0
except ItemBundle.DoesNotExist:
bprice = cp.price
except ItemBundle.MultipleObjectsReturned:
raise OrderError("Invalid product configuration (duplicate bundle)")
price = get_price(cp.item, cp.variation, cp.voucher, bprice, cp.subevent, custom_price_is_net=False,
custom_price_is_tax_rate=cp.override_tax_rate,
invoice_address=address, force_custom_price=True, max_discount=max_discount)
pbv = get_price(cp.item, cp.variation, None, bprice, cp.subevent, custom_price_is_net=False,
custom_price_is_tax_rate=cp.override_tax_rate,
invoice_address=address, force_custom_price=True, max_discount=max_discount)
changed_prices[cp.pk] = bprice
else:
bundled_sum = 0
if not cp.addon_to_id:
for bundledp in cp.addons.all():
if bundledp.is_bundled:
bundled_sum += changed_prices.get(bundledp.pk, bundledp.price)
if cp.is_bundled:
try:
bundle = cp.addon_to.item.bundles.get(bundled_item=cp.item, bundled_variation=cp.variation)
bprice = bundle.designated_price or 0
except ItemBundle.DoesNotExist:
bprice = cp.price
except ItemBundle.MultipleObjectsReturned:
raise OrderError("Invalid product configuration (duplicate bundle)")
price = get_price(cp.item, cp.variation, cp.voucher, bprice, cp.subevent, custom_price_is_net=False,
custom_price_is_tax_rate=cp.override_tax_rate,
invoice_address=address, force_custom_price=True, max_discount=max_discount)
pbv = get_price(cp.item, cp.variation, None, bprice, cp.subevent, custom_price_is_net=False,
custom_price_is_tax_rate=cp.override_tax_rate,
invoice_address=address, force_custom_price=True, max_discount=max_discount)
changed_prices[cp.pk] = bprice
else:
bundled_sum = 0
if not cp.addon_to_id:
for bundledp in cp.addons.all():
if bundledp.is_bundled:
bundled_sum += changed_prices.get(bundledp.pk, bundledp.price)
price = get_price(cp.item, cp.variation, cp.voucher, cp.price, cp.subevent, custom_price_is_net=False,
addon_to=cp.addon_to, invoice_address=address, bundled_sum=bundled_sum,
max_discount=max_discount, custom_price_is_tax_rate=cp.override_tax_rate)
pbv = get_price(cp.item, cp.variation, None, cp.price, cp.subevent, custom_price_is_net=False,
addon_to=cp.addon_to, invoice_address=address, bundled_sum=bundled_sum,
max_discount=max_discount, custom_price_is_tax_rate=cp.override_tax_rate)
except TaxRule.SaleNotAllowed:
err = err or error_messages['country_blocked']
cp.delete()
continue
price = get_price(cp.item, cp.variation, cp.voucher, cp.price, cp.subevent, custom_price_is_net=False,
addon_to=cp.addon_to, invoice_address=address, bundled_sum=bundled_sum,
max_discount=max_discount, custom_price_is_tax_rate=cp.override_tax_rate)
pbv = get_price(cp.item, cp.variation, None, cp.price, cp.subevent, custom_price_is_net=False,
addon_to=cp.addon_to, invoice_address=address, bundled_sum=bundled_sum,
max_discount=max_discount, custom_price_is_tax_rate=cp.override_tax_rate)
if max_discount is not None:
v_budget[cp.voucher] = v_budget[cp.voucher] + current_discount - (pbv.gross - price.gross)
@@ -1180,7 +1174,6 @@ class OrderChangeManager:
'seat_subevent_mismatch': _('You selected seat "{seat}" for a date that does not match the selected ticket date. Please choose a seat again.'),
'seat_required': _('The selected product requires you to select a seat.'),
'seat_forbidden': _('The selected product does not allow to select a seat.'),
'tax_rule_country_blocked': _('The selected country is blocked by your tax rule.'),
'gift_card_change': _('You cannot change the price of a position that has been used to issue a gift card.'),
}
ItemOperation = namedtuple('ItemOperation', ('position', 'item', 'variation'))
@@ -1248,11 +1241,8 @@ class OrderChangeManager:
self._operations.append(self.SeatOperation(position, seat))
def change_subevent(self, position: OrderPosition, subevent: SubEvent):
try:
price = get_price(position.item, position.variation, voucher=position.voucher, subevent=subevent,
invoice_address=self._invoice_address)
except TaxRule.SaleNotAllowed:
raise OrderError(self.error_messages['tax_rule_country_blocked'])
price = get_price(position.item, position.variation, voucher=position.voucher, subevent=subevent,
invoice_address=self._invoice_address)
if price is None: # NOQA
raise OrderError(self.error_messages['product_invalid'])
@@ -1272,11 +1262,8 @@ class OrderChangeManager:
if (not variation and item.has_variations) or (variation and variation.item_id != item.pk):
raise OrderError(self.error_messages['product_without_variation'])
try:
price = get_price(item, variation, voucher=position.voucher, subevent=subevent,
invoice_address=self._invoice_address)
except TaxRule.SaleNotAllowed:
raise OrderError(self.error_messages['tax_rule_country_blocked'])
price = get_price(item, variation, voucher=position.voucher, subevent=subevent,
invoice_address=self._invoice_address)
if price is None: # NOQA
raise OrderError(self.error_messages['product_invalid'])
@@ -1334,10 +1321,7 @@ class OrderChangeManager:
if not pos.price:
continue
try:
new_rate = tax_rule.tax_rate_for(ia)
except TaxRule.SaleNotAllowed:
raise OrderError(error_messages['tax_rule_country_blocked'])
new_rate = tax_rule.tax_rate_for(ia)
# We use override_tax_rate to make sure .tax() doesn't get clever and re-adjusts the pricing itself
if new_rate != pos.tax_rate:
if keep == 'net':
@@ -1390,13 +1374,10 @@ class OrderChangeManager:
except Seat.DoesNotExist:
raise OrderError(error_messages['seat_invalid'])
try:
if price is None:
price = get_price(item, variation, subevent=subevent, invoice_address=self._invoice_address)
else:
price = item.tax(price, base_price_is='gross', invoice_address=self._invoice_address)
except TaxRule.SaleNotAllowed:
raise OrderError(self.error_messages['tax_rule_country_blocked'])
if price is None:
price = get_price(item, variation, subevent=subevent, invoice_address=self._invoice_address)
else:
price = item.tax(price, base_price_is='gross', invoice_address=self._invoice_address)
if price is None:
raise OrderError(self.error_messages['product_invalid'])
@@ -1971,10 +1952,7 @@ class OrderChangeManager:
self._check_quotas()
self._check_seats()
self._check_complete_cancel()
try:
self._perform_operations()
except TaxRule.SaleNotAllowed:
raise OrderError(self.error_messages['tax_rule_country_blocked'])
self._perform_operations()
self._recalculate_total_and_payment_fee()
self._reissue_invoice()
self._clear_tickets_cache()

View File

@@ -127,7 +127,6 @@ def order_overview(
order__event=event
).annotate(
status=Case(
When(order__status='n', order__require_approval=True, then=Value('unapproved')),
When(canceled=True, then=Value('c')),
default=F('order__status')
)
@@ -136,7 +135,6 @@ def order_overview(
).annotate(cnt=Count('id'), price=Sum('price'), tax_value=Sum('tax_value')).order_by()
states = {
'unapproved': 'unapproved',
'canceled': Order.STATUS_CANCELED,
'paid': Order.STATUS_PAID,
'pending': Order.STATUS_PENDING,
@@ -200,7 +198,6 @@ def order_overview(
order__event=event
).annotate(
status=Case(
When(order__status='n', order__require_approval=True, then=Value('unapproved')),
When(canceled=True, then=Value('c')),
default=F('order__status')
)

View File

@@ -96,9 +96,8 @@ class OrganizerUserTask(app.Task):
kwargs['organizer'] = organizer
user_id = kwargs['user']
if user_id is not None:
user = User.objects.get(pk=user_id)
kwargs['user'] = user
user = User.objects.get(pk=user_id)
kwargs['user'] = user
with scope(organizer=organizer):
ret = super().__call__(*args, **kwargs)

View File

@@ -9,9 +9,7 @@ from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files import File
from django.core.validators import (
MaxValueValidator, MinValueValidator, RegexValidator,
)
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db.models import Model
from django.utils.translation import (
gettext_lazy as _, gettext_noop, pgettext, pgettext_lazy,
@@ -28,9 +26,7 @@ from pretix.base.reldate import (
RelativeDateField, RelativeDateTimeField, RelativeDateWrapper,
SerializerRelativeDateField, SerializerRelativeDateTimeField,
)
from pretix.control.forms import (
FontSelect, MultipleLanguagesWidget, SingleLanguageWidget,
)
from pretix.control.forms import MultipleLanguagesWidget, SingleLanguageWidget
from pretix.helpers.countries import CachedCountries
@@ -42,18 +38,6 @@ def country_choice_kwargs():
}
def primary_font_kwargs():
from pretix.presale.style import get_fonts
choices = [('Open Sans', 'Open Sans')]
choices += [
(a, {"title": a, "data": v}) for a, v in get_fonts().items()
]
return {
'choices': choices,
}
class LazyI18nStringList(UserList):
def __init__(self, init_list=None):
super().__init__()
@@ -268,6 +252,7 @@ DEFAULTS = {
'form_kwargs': dict(
label=_("Ask for beneficiary"),
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
required=False
)
},
'invoice_address_custom_field': {
@@ -436,6 +421,7 @@ DEFAULTS = {
widget_kwargs={'attrs': {
'rows': 3,
}},
required=False,
label=_("Guidance text"),
help_text=_("This text will be shown above the payment options. You can explain the choices to the user here, "
"if you want.")
@@ -455,6 +441,7 @@ DEFAULTS = {
'form_kwargs': dict(
label=_("Set payment term"),
widget=forms.RadioSelect,
required=True,
choices=(
('days', _("in days")),
('minutes', _("in minutes"))
@@ -501,6 +488,7 @@ DEFAULTS = {
widget=forms.CheckboxInput(
attrs={
'data-display-dependency': '#id_payment_term_mode_0',
'data-required-if': '#id_payment_term_mode_0'
},
),
)
@@ -553,18 +541,6 @@ DEFAULTS = {
"the pool and can be ordered by other people."),
)
},
'payment_pending_hidden': {
'default': 'False',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Hide "payment pending" state on customer-facing pages'),
help_text=_("The payment instructions panel will still be shown to the primary customer, but no indication "
"of missing payment will be visible on the ticket pages of attendees who did not buy the ticket "
"themselves.")
)
},
'payment_giftcard__enabled': {
'default': 'True',
'type': bool
@@ -1014,16 +990,7 @@ DEFAULTS = {
},
'event_list_availability': {
'default': 'True',
'type': bool,
'serializer_class': serializers.BooleanField,
'form_class': forms.BooleanField,
'form_kwargs': dict(
label=_('Show availability in event overviews'),
help_text=_('If checked, the list of events will show if events are sold out. This might '
'make for longer page loading times if you have lots of events and the shown status might be out '
'of date for up to two minutes.'),
required=False
)
'type': bool
},
'event_list_type': {
'default': 'list',
@@ -1632,106 +1599,26 @@ Your {event} team"""))
'primary_color': {
'default': settings.PRETIX_PRIMARY_COLOR,
'type': str,
'form_class': forms.CharField,
'serializer_class': serializers.CharField,
'serializer_kwargs': dict(
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
),
'form_kwargs': dict(
label=_("Primary color"),
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
),
},
'theme_color_success': {
'default': '#50A167',
'type': str,
'form_class': forms.CharField,
'serializer_class': serializers.CharField,
'serializer_kwargs': dict(
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
),
'form_kwargs': dict(
label=_("Accent color for success"),
help_text=_("We strongly suggest to use a shade of green."),
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
),
'type': str
},
'theme_color_danger': {
'default': '#D36060',
'type': str,
'form_class': forms.CharField,
'serializer_class': serializers.CharField,
'serializer_kwargs': dict(
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
),
'form_kwargs': dict(
label=_("Accent color for errors"),
help_text=_("We strongly suggest to use a shade of red."),
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
),
'type': str
},
'theme_color_background': {
'default': '#FFFFFF',
'type': str,
'form_class': forms.CharField,
'serializer_class': serializers.CharField,
'serializer_kwargs': dict(
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
),
'form_kwargs': dict(
label=_("Page background color"),
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield no-contrast'})
),
'type': str
},
'theme_round_borders': {
'default': 'True',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_("Use round edges"),
)
'type': bool
},
'primary_font': {
'default': 'Open Sans',
'type': str,
'form_class': forms.ChoiceField,
'serializer_class': serializers.ChoiceField,
'serializer_kwargs': lambda: dict(**primary_font_kwargs()),
'form_kwargs': lambda: dict(
label=_('Font'),
help_text=_('Only respected by modern browsers.'),
widget=FontSelect,
**primary_font_kwargs()
),
'type': str
},
'presale_css_file': {
'default': None,
@@ -1767,13 +1654,7 @@ Your {event} team"""))
},
'organizer_logo_image_large': {
'default': 'False',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Use header image in its full size'),
help_text=_('We recommend to upload a picture at least 1170 pixels wide.'),
)
'type': bool
},
'og_image': {
'default': None,
@@ -1832,19 +1713,6 @@ Your {event} team"""))
"how to obtain a voucher code.")
)
},
'attendee_data_explanation_text': {
'default': '',
'type': LazyI18nString,
'serializer_class': I18nField,
'form_class': I18nFormField,
'form_kwargs': dict(
label=_("Attendee data explanation"),
widget=I18nTextarea,
widget_kwargs={'attrs': {'rows': '2'}},
help_text=_("This text will be shown above the questions asked for every admission product. You can use it e.g. to explain "
"why you need information from them.")
)
},
'checkout_email_helptext': {
'default': LazyI18nString.from_gettext(gettext_noop(
'Make sure to enter a valid email address. We will send you an order '
@@ -1865,26 +1733,11 @@ Your {event} team"""))
},
'organizer_info_text': {
'default': '',
'type': LazyI18nString,
'serializer_class': I18nField,
'form_class': I18nFormField,
'form_kwargs': dict(
label=_('Info text'),
widget=I18nTextarea,
help_text=_('Not displayed anywhere by default, but if you want to, you can use this e.g. in ticket templates.')
)
'type': LazyI18nString
},
'event_team_provisioning': {
'default': 'True',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Allow creating a new team during event creation'),
help_text=_('Users that do not have access to all events under this organizer, must select one of their teams '
'to have access to the created event. This setting allows users to create an event-specified team'
' on-the-fly, even when they do not have \"Can change teams and permissions\" permission.'),
)
'type': bool
},
'update_check_ack': {
'default': 'False',
@@ -1926,10 +1779,6 @@ Your {event} team"""))
'default': None,
'type': str
},
'mapquest_apikey': {
'default': None,
'type': str
},
'leaflet_tiles': {
'default': None,
'type': str
@@ -1962,51 +1811,13 @@ Your {event} team"""))
# When adding a new ordering, remember to also define it in the event model
)
},
'organizer_link_back': {
'default': 'False',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Link back to organizer overview on all event pages'),
)
},
'organizer_homepage_text': {
'default': '',
'type': LazyI18nString,
'serializer_class': I18nField,
'form_class': I18nFormField,
'form_kwargs': dict(
label=_('Homepage text'),
widget=I18nTextarea,
help_text=_('This will be displayed on the organizer homepage.')
)
},
'name_scheme': {
'default': 'full',
'type': str
},
'giftcard_length': {
'default': settings.ENTROPY['giftcard_secret'],
'type': int,
'form_class': forms.IntegerField,
'serializer_class': serializers.IntegerField,
'form_kwargs': dict(
label=_('Length of gift card codes'),
help_text=_('The system generates by default {}-character long gift card codes. However, if a different length '
'is required, it can be set here.'.format(settings.ENTROPY['giftcard_secret'])),
)
},
'giftcard_expiry_years': {
'default': None,
'type': int,
'form_class': forms.IntegerField,
'serializer_class': serializers.IntegerField,
'form_kwargs': dict(
label=_('Validity of gift card codes in years'),
help_text=_('If you set a number here, gift cards will by default expire at the end of the year after this '
'many years. If you keep it empty, gift cards do not have an explicit expiry date.'),
)
'type': int
},
'seating_choice': {
'default': 'True',
@@ -2042,10 +1853,6 @@ Your {event} team"""))
),
}
}
SETTINGS_AFFECTING_CSS = {
'primary_color', 'theme_color_success', 'theme_color_danger', 'primary_font',
'theme_color_background', 'theme_round_borders'
}
PERSON_NAME_TITLE_GROUPS = OrderedDict([
('english_common', (_('Most common English titles'), (
'Mr',
@@ -2245,30 +2052,6 @@ PERSON_NAME_SCHEMES = OrderedDict([
'_scheme': 'salutation_title_given_family',
},
}),
('salutation_title_given_family_degree', {
'fields': (
('salutation', pgettext_lazy('person_name', 'Salutation'), 1),
('title', pgettext_lazy('person_name', 'Title'), 1),
('given_name', _('Given name'), 2),
('family_name', _('Family name'), 2),
('degree', pgettext_lazy('person_name', 'Degree (after name)'), 2),
),
'concatenation': lambda d: (
' '.join(
str(p) for p in (d.get(key, '') for key in ["title", "given_name", "family_name"]) if p
) +
str((', ' if d.get('degree') else '')) +
str(d.get('degree', ''))
),
'sample': {
'salutation': pgettext_lazy('person_name_sample', 'Mr'),
'title': pgettext_lazy('person_name_sample', 'Dr'),
'given_name': pgettext_lazy('person_name_sample', 'John'),
'family_name': pgettext_lazy('person_name_sample', 'Doe'),
'degree': pgettext_lazy('person_name_sample', 'MA'),
'_scheme': 'salutation_title_given_family_degree',
},
}),
])
COUNTRIES_WITH_STATE_IN_ADDRESS = {
# Source: http://www.bitboost.com/ref/international-address-formats.html
@@ -2360,8 +2143,7 @@ class SettingsSandbox:
self._event.settings.set(self._convert_key(key), value)
def validate_event_settings(event, settings_dict):
from pretix.base.models import Event
def validate_settings(event, settings_dict):
from pretix.base.signals import validate_event_settings
if 'locales' in settings_dict and settings_dict['locale'] not in settings_dict['locales']:
@@ -2392,14 +2174,4 @@ def validate_event_settings(event, settings_dict):
'payment_term_last': _('The last payment date cannot be before the end of presale.')
})
if isinstance(event, Event):
validate_event_settings.send(sender=event, settings_dict=settings_dict)
def validate_organizer_settings(organizer, settings_dict):
# This is not doing anything for the time being.
# But earlier we called validate_event_settings for the organizer, too - and that didn't do anything for
# organizer-settings either.
#
# N.B.: When actually fleshing out this stub, adding it to the OrganizerUpdateForm should be considered.
pass
validate_event_settings.send(sender=event, settings_dict=settings_dict)

View File

@@ -3,14 +3,15 @@ from urllib.parse import urlencode, urlparse
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.core.validators import RegexValidator, validate_email
from django.db.models import Q
from django.forms import CheckboxSelectMultiple, formset_factory
from django.forms import formset_factory
from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.timezone import get_current_timezone_name
from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy
from django_countries import Countries
from django_countries.fields import LazyTypedChoiceField
from i18nfield.forms import (
I18nForm, I18nFormField, I18nFormSetMixin, I18nTextarea, I18nTextInput,
@@ -19,21 +20,18 @@ from pytz import common_timezones, timezone
from pretix.base.channels import get_all_sales_channels
from pretix.base.email import get_available_placeholders
from pretix.base.forms import (
I18nModelForm, PlaceholderValidator, SettingsForm,
)
from pretix.base.forms import I18nModelForm, PlaceholderValidator, SettingsForm
from pretix.base.models import Event, Organizer, TaxRule, Team
from pretix.base.models.event import EventMetaValue, SubEvent
from pretix.base.reldate import RelativeDateField, RelativeDateTimeField
from pretix.base.settings import (
PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS, validate_event_settings,
PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS, validate_settings,
)
from pretix.control.forms import (
ExtFileField, MultipleLanguagesWidget, SlugWidget, SplitDateTimeField,
SplitDateTimePickerWidget,
ExtFileField, FontSelect, MultipleLanguagesWidget, SlugWidget,
SplitDateTimeField, SplitDateTimePickerWidget,
)
from pretix.control.forms.widgets import Select2
from pretix.helpers.countries import CachedCountries
from pretix.multidomain.models import KnownDomain
from pretix.multidomain.urlreverse import build_absolute_uri
from pretix.plugins.banktransfer.payment import BankTransfer
@@ -313,16 +311,6 @@ class EventUpdateForm(I18nModelForm):
required=False,
help_text=_('You need to configure the custom domain in the webserver beforehand.')
)
self.fields['sales_channels'] = forms.MultipleChoiceField(
label=self.fields['sales_channels'].label,
help_text=self.fields['sales_channels'].help_text,
required=self.fields['sales_channels'].required,
initial=self.fields['sales_channels'].initial,
choices=(
(c.identifier, c.verbose_name) for c in get_all_sales_channels().values()
),
widget=forms.CheckboxSelectMultiple
)
def clean_domain(self):
d = self.cleaned_data['domain']
@@ -379,7 +367,6 @@ class EventUpdateForm(I18nModelForm):
'location',
'geo_lat',
'geo_lon',
'sales_channels'
]
field_classes = {
'date_from': SplitDateTimeField,
@@ -394,7 +381,6 @@ class EventUpdateForm(I18nModelForm):
'date_admission': SplitDateTimePickerWidget(attrs={'data-date-default': '#id_date_from_0'}),
'presale_start': SplitDateTimePickerWidget(),
'presale_end': SplitDateTimePickerWidget(attrs={'data-date-after': '#id_presale_start_0'}),
'sales_channels': CheckboxSelectMultiple()
}
@@ -445,6 +431,57 @@ class EventSettingsForm(SettingsForm):
'WhatsApp and Reddit only show a square preview, so we recommend to make sure it still looks good '
'only the center square is shown. If you do not fill this, we will use the logo given above.')
)
primary_color = forms.CharField(
label=_("Primary color"),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_success = forms.CharField(
label=_("Accent color for success"),
help_text=_("We strongly suggest to use a shade of green."),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_danger = forms.CharField(
label=_("Accent color for errors"),
help_text=_("We strongly suggest to use a dark shade of red."),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_background = forms.CharField(
label=_("Page background color"),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield no-contrast'})
)
theme_round_borders = forms.BooleanField(
label=_("Use round edges"),
required=False,
)
primary_font = forms.ChoiceField(
label=_('Font'),
choices=[
('Open Sans', 'Open Sans')
],
widget=FontSelect,
help_text=_('Only respected by modern browsers.')
)
auto_fields = [
'imprint_url',
@@ -481,25 +518,18 @@ class EventSettingsForm(SettingsForm):
'attendee_company_required',
'attendee_addresses_asked',
'attendee_addresses_required',
'attendee_data_explanation_text',
'banner_text',
'banner_text_bottom',
'order_email_asked_twice',
'last_order_modification_date',
'checkout_show_copy_answers_button',
'primary_color',
'theme_color_success',
'theme_color_danger',
'theme_color_background',
'theme_round_borders',
'primary_font',
]
def clean(self):
data = super().clean()
settings_dict = self.event.settings.freeze()
settings_dict.update(data)
validate_event_settings(self.event, data)
validate_settings(self.event, data)
return data
def __init__(self, *args, **kwargs):
@@ -562,7 +592,6 @@ class PaymentSettingsForm(SettingsForm):
'payment_term_last',
'payment_term_expire_automatically',
'payment_term_accept_late',
'payment_pending_hidden',
'payment_explanation',
]
tax_rate_default = forms.ModelChoiceField(
@@ -589,7 +618,7 @@ class PaymentSettingsForm(SettingsForm):
data = super().clean()
settings_dict = self.obj.settings.freeze()
settings_dict.update(data)
validate_event_settings(self.obj, data)
validate_settings(self.obj, data)
return data
def __init__(self, *args, **kwargs):
@@ -628,8 +657,6 @@ class ProviderForm(SettingsForm):
enabled = cleaned_data.get(self.settingspref + '_enabled')
if not enabled:
return
if cleaned_data.get(self.settingspref + '_hidden_url', None):
cleaned_data[self.settingspref + '_hidden_url'] = None
for k, v in self.fields.items():
val = cleaned_data.get(k)
if v._required and not val:
@@ -721,7 +748,7 @@ class InvoiceSettingsForm(SettingsForm):
data = super().clean()
settings_dict = self.obj.settings.freeze()
settings_dict.update(data)
validate_event_settings(self.obj, data)
validate_settings(self.obj, data)
return data
@@ -1092,16 +1119,15 @@ class CommentForm(I18nModelForm):
}
class CountriesAndEU(CachedCountries):
class CountriesAndEU(Countries):
override = {
'ZZ': _('Any country'),
'EU': _('European Union')
}
first = ['ZZ', 'EU']
cache_subkey = 'with_any_or_eu'
class TaxRuleLineForm(I18nForm):
class TaxRuleLineForm(forms.Form):
country = LazyTypedChoiceField(
choices=CountriesAndEU(),
required=False
@@ -1120,7 +1146,6 @@ class TaxRuleLineForm(I18nForm):
('vat', _('Charge VAT')),
('reverse', _('Reverse charge')),
('no', _('No VAT')),
('block', _('Sale not allowed')),
],
)
rate = forms.DecimalField(
@@ -1128,33 +1153,18 @@ class TaxRuleLineForm(I18nForm):
max_digits=10, decimal_places=2,
required=False
)
invoice_text = I18nFormField(
label=_('Text on invoice'),
required=False,
widget=I18nTextInput
)
class I18nBaseFormSet(I18nFormSetMixin, forms.BaseFormSet):
# compatibility shim for django-i18nfield library
def __init__(self, *args, **kwargs):
self.event = kwargs.pop('event', None)
if self.event:
kwargs['locales'] = self.event.settings.get('locales')
super().__init__(*args, **kwargs)
TaxRuleLineFormSet = formset_factory(
TaxRuleLineForm, formset=I18nBaseFormSet,
can_order=True, can_delete=True, extra=0
TaxRuleLineForm,
can_order=False, can_delete=True, extra=0
)
class TaxRuleForm(I18nModelForm):
class Meta:
model = TaxRule
fields = ['name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country']
fields = ['name', 'rate', 'price_includes_tax']
class WidgetCodeForm(forms.Form):

View File

@@ -1,22 +1,16 @@
from datetime import datetime, time
from decimal import Decimal
from urllib.parse import urlencode
from django import forms
from django.apps import apps
from django.conf import settings
from django.db.models import Exists, F, Model, OuterRef, Q, QuerySet
from django.db.models import Exists, F, OuterRef, Q
from django.db.models.functions import Coalesce, ExtractWeekDay
from django.urls import reverse, reverse_lazy
from django.utils.formats import date_format, localize
from django.utils.functional import cached_property
from django.utils.timezone import get_current_timezone, make_aware, now
from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy
from django.utils.translation import gettext_lazy as _, pgettext_lazy
from pretix.base.channels import get_all_sales_channels
from pretix.base.forms.widgets import (
DatePickerWidget, SplitDateTimePickerWidget,
)
from pretix.base.forms.widgets import DatePickerWidget
from pretix.base.models import (
Checkin, Event, EventMetaProperty, EventMetaValue, Invoice, InvoiceAddress,
Item, Order, OrderPayment, OrderPosition, OrderRefund, Organizer, Question,
@@ -25,9 +19,7 @@ from pretix.base.models import (
from pretix.base.signals import register_payment_providers
from pretix.control.forms.widgets import Select2
from pretix.control.signals import order_search_filter_q
from pretix.helpers.countries import CachedCountries
from pretix.helpers.database import FixedOrderBy, rolledback_transaction
from pretix.helpers.dicts import move_to_end
from pretix.helpers.i18n import i18ncomp
PAYMENT_PROVIDERS = []
@@ -91,38 +83,6 @@ class FilterForm(forms.Form):
else:
return self.orders[o]
def filter_to_strings(self):
string = []
for k, f in self.fields.items():
v = self.cleaned_data.get(k)
if v is None or (isinstance(v, (list, str, QuerySet)) and len(v) == 0):
continue
if k == "saveas":
continue
if isinstance(v, bool):
val = _('Yes') if v else _('No')
elif isinstance(v, QuerySet):
q = ['"' + str(m) + '"' for m in v]
if not q:
continue
val = ' or '.join(q)
elif isinstance(v, Model):
val = '"' + str(v) + '"'
elif isinstance(f, forms.MultipleChoiceField):
valdict = dict(f.choices)
val = ' or '.join([str(valdict.get(m)) for m in v])
elif isinstance(f, forms.ChoiceField):
val = str(dict(f.choices).get(v))
elif isinstance(v, datetime):
val = date_format(v, 'SHORT_DATETIME_FORMAT')
elif isinstance(v, Decimal):
val = localize(v)
else:
val = v
string.append('{}: {}'.format(f.label, val))
return string
class OrderFilterForm(FilterForm):
query = forms.CharField(
@@ -144,29 +104,20 @@ class OrderFilterForm(FilterForm):
label=_('Order status'),
choices=(
('', _('All orders')),
(_('Valid orders'), (
(Order.STATUS_PAID, _('Paid (or canceled with paid fee)')),
(Order.STATUS_PENDING, _('Pending')),
(Order.STATUS_PENDING + Order.STATUS_PAID, _('Pending or paid')),
)),
(_('Cancellations'), (
(Order.STATUS_CANCELED, _('Canceled')),
('cp', _('Canceled (or with paid fee)')),
('rc', _('Cancellation requested')),
)),
(_('Payment process'), (
(Order.STATUS_EXPIRED, _('Expired')),
(Order.STATUS_PENDING + Order.STATUS_EXPIRED, _('Pending or expired')),
('o', _('Pending (overdue)')),
('overpaid', _('Overpaid')),
('underpaid', _('Underpaid')),
('pendingpaid', _('Pending (but fully paid)')),
)),
(_('Approval process'), (
('na', _('Approved, payment pending')),
('pa', _('Approval pending')),
)),
(Order.STATUS_PAID, _('Paid (or canceled with paid fee)')),
(Order.STATUS_PENDING, _('Pending')),
('o', _('Pending (overdue)')),
(Order.STATUS_PENDING + Order.STATUS_PAID, _('Pending or paid')),
(Order.STATUS_EXPIRED, _('Expired')),
(Order.STATUS_PENDING + Order.STATUS_EXPIRED, _('Pending or expired')),
(Order.STATUS_CANCELED, _('Canceled')),
('cp', _('Canceled (or with paid fee)')),
('pa', _('Approval pending')),
('overpaid', _('Overpaid')),
('underpaid', _('Underpaid')),
('pendingpaid', _('Pending (but fully paid)')),
('testmode', _('Test mode')),
('rc', _('Cancellation requested')),
),
required=False,
)
@@ -256,11 +207,6 @@ class OrderFilterForm(FilterForm):
status=Order.STATUS_PENDING,
require_approval=True
)
elif s == 'na':
qs = qs.filter(
status=Order.STATUS_PENDING,
require_approval=False
)
elif s == 'testmode':
qs = qs.filter(
testmode=True
@@ -391,238 +337,6 @@ class EventOrderFilterForm(OrderFilterForm):
return qs
class FilterNullBooleanSelect(forms.NullBooleanSelect):
def __init__(self, attrs=None):
choices = (
('unknown', _('All')),
('true', _('Yes')),
('false', _('No')),
)
super(forms.NullBooleanSelect, self).__init__(attrs, choices)
class EventOrderExpertFilterForm(EventOrderFilterForm):
subevents_from = forms.SplitDateTimeField(
widget=SplitDateTimePickerWidget(attrs={
}),
label=pgettext_lazy('subevent', 'All dates starting at or after'),
required=False,
)
subevents_to = forms.SplitDateTimeField(
widget=SplitDateTimePickerWidget(attrs={
}),
label=pgettext_lazy('subevent', 'All dates starting before'),
required=False,
)
created_from = forms.SplitDateTimeField(
widget=SplitDateTimePickerWidget(attrs={
}),
label=_('Order placed at or after'),
required=False,
)
created_to = forms.SplitDateTimeField(
widget=SplitDateTimePickerWidget(attrs={
}),
label=_('Order placed before'),
required=False,
)
email = forms.CharField(
required=False,
label=_('E-mail address')
)
comment = forms.CharField(
required=False,
label=_('Comment')
)
locale = forms.ChoiceField(
required=False,
label=_('Locale'),
choices=settings.LANGUAGES
)
email_known_to_work = forms.NullBooleanField(
required=False,
widget=FilterNullBooleanSelect,
label=_('E-mail address verified'),
)
total = forms.DecimalField(
localize=True,
required=False,
label=_('Total amount'),
)
sales_channel = forms.ChoiceField(
label=_('Sales channel'),
required=False,
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
del self.fields['query']
del self.fields['question']
del self.fields['answer']
del self.fields['ordering']
if not self.event.has_subevents:
del self.fields['subevents_from']
del self.fields['subevents_to']
self.fields['sales_channel'].choices = [('', '')] + [
(k, v.verbose_name) for k, v in get_all_sales_channels().items()
]
locale_names = dict(settings.LANGUAGES)
self.fields['locale'].choices = [('', '')] + [(a, locale_names[a]) for a in self.event.settings.locales]
move_to_end(self.fields, 'item')
move_to_end(self.fields, 'provider')
self.fields['invoice_address_company'] = forms.CharField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('Company')
)
self.fields['invoice_address_name'] = forms.CharField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('Name')
)
self.fields['invoice_address_street'] = forms.CharField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('Address')
)
self.fields['invoice_address_zipcode'] = forms.CharField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('ZIP code'),
help_text=_('Exact matches only')
)
self.fields['invoice_address_city'] = forms.CharField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('City'),
help_text=_('Exact matches only')
)
self.fields['invoice_address_country'] = forms.ChoiceField(
required=False,
label=gettext('Invoice address') + ': ' + gettext('Country'),
choices=[('', '')] + list(CachedCountries())
)
self.fields['attendee_name'] = forms.CharField(
required=False,
label=_('Attendee name')
)
self.fields['attendee_email'] = forms.CharField(
required=False,
label=_('Attendee e-mail address')
)
self.fields['attendee_address_company'] = forms.CharField(
required=False,
label=gettext('Attendee address') + ': ' + gettext('Company')
)
self.fields['attendee_address_street'] = forms.CharField(
required=False,
label=gettext('Attendee address') + ': ' + gettext('Address')
)
self.fields['attendee_address_zipcode'] = forms.CharField(
required=False,
label=gettext('Attendee address') + ': ' + gettext('ZIP code'),
help_text=_('Exact matches only')
)
self.fields['attendee_address_city'] = forms.CharField(
required=False,
label=gettext('Attendee address') + ': ' + gettext('City'),
help_text=_('Exact matches only')
)
self.fields['attendee_address_country'] = forms.ChoiceField(
required=False,
label=gettext('Attendee address') + ': ' + gettext('Country'),
choices=[('', '')] + list(CachedCountries())
)
self.fields['ticket_secret'] = forms.CharField(
label=_('Ticket secret'),
required=False
)
for q in self.event.questions.all():
self.fields['question_{}'.format(q.pk)] = forms.CharField(
label=q.question,
required=False,
help_text=_('Exact matches only')
)
def filter_qs(self, qs):
fdata = self.cleaned_data
qs = super().filter_qs(qs)
if fdata.get('subevents_from'):
qs = qs.filter(
all_positions__subevent__date_from__gte=fdata.get('subevents_from'),
all_positions__canceled=False
).distinct()
if fdata.get('subevents_to'):
qs = qs.filter(
all_positions__subevent__date_from__lt=fdata.get('subevents_to'),
all_positions__canceled=False
).distinct()
if fdata.get('email'):
qs = qs.filter(
email__icontains=fdata.get('email')
)
if fdata.get('created_from'):
qs = qs.filter(datetime__gte=fdata.get('created_from'))
if fdata.get('created_to'):
qs = qs.filter(datetime__lte=fdata.get('created_to'))
if fdata.get('comment'):
qs = qs.filter(comment__icontains=fdata.get('comment'))
if fdata.get('sales_channel'):
qs = qs.filter(sales_channel=fdata.get('sales_channel'))
if fdata.get('total'):
qs = qs.filter(total=fdata.get('total'))
if fdata.get('email_known_to_work') is not None:
qs = qs.filter(email_known_to_work=fdata.get('email_known_to_work'))
if fdata.get('locale'):
qs = qs.filter(locale=fdata.get('locale'))
if fdata.get('invoice_address_company'):
qs = qs.filter(invoice_address__company__icontains=fdata.get('invoice_address_company'))
if fdata.get('invoice_address_name'):
qs = qs.filter(invoice_address__name_cached__icontains=fdata.get('invoice_address_name'))
if fdata.get('invoice_address_street'):
qs = qs.filter(invoice_address__street__icontains=fdata.get('invoice_address_street'))
if fdata.get('invoice_address_zipcode'):
qs = qs.filter(invoice_address__zipcode__iexact=fdata.get('invoice_address_zipcode'))
if fdata.get('invoice_address_city'):
qs = qs.filter(invoice_address__city__iexact=fdata.get('invoice_address_city'))
if fdata.get('invoice_address_country'):
qs = qs.filter(invoice_address__country=fdata.get('invoice_address_country'))
if fdata.get('attendee_name'):
qs = qs.filter(
all_positions__attendee_name_cached__icontains=fdata.get('attendee_name')
)
if fdata.get('attendee_address_company'):
qs = qs.filter(
all_positions__company__icontains=fdata.get('attendee_address_company')
).distinct()
if fdata.get('attendee_address_street'):
qs = qs.filter(
all_positions__street__icontains=fdata.get('attendee_address_street')
).distinct()
if fdata.get('attendee_address_city'):
qs = qs.filter(
all_positions__city__iexact=fdata.get('attendee_address_city')
).distinct()
if fdata.get('attendee_address_country'):
qs = qs.filter(
all_positions__country=fdata.get('attendee_address_country')
).distinct()
if fdata.get('ticket_secret'):
qs = qs.filter(
all_positions__secret__icontains=fdata.get('ticket_secret')
).distinct()
for q in self.event.questions.all():
if fdata.get(f'question_{q.pk}'):
answers = QuestionAnswer.objects.filter(
question_id=q.pk,
orderposition__order_id=OuterRef('pk'),
answer__iexact=fdata.get(f'question_{q.pk}')
)
qs = qs.annotate(**{f'q_{q.pk}': Exists(answers)}).filter(**{f'q_{q.pk}': True})
return qs
class OrderSearchFilterForm(OrderFilterForm):
orders = {'code': 'code', 'email': 'email', 'total': 'total',
'datetime': 'datetime', 'status': 'status',
@@ -1113,8 +827,8 @@ class CheckInFilterForm(FilterForm):
'-item': ('-item__name', '-variation__value', '-order__code'),
'seat': ('seat__sorting_rank', 'seat__guid'),
'-seat': ('-seat__sorting_rank', '-seat__guid'),
'date': ('subevent__date_from', 'subevent__id', 'order__code'),
'-date': ('-subevent__date_from', 'subevent__id', '-order__code'),
'date': ('subevent__date_from', 'order__code'),
'-date': ('-subevent__date_from', '-order__code'),
'name': {'_order': F('display_name').asc(nulls_first=True),
'display_name': Coalesce('attendee_name_cached', 'addon_to__attendee_name_cached')},
'-name': {'_order': F('display_name').desc(nulls_last=True),

View File

@@ -41,10 +41,6 @@ class GlobalSettingsForm(SettingsForm):
required=False,
label=_("OpenCage API key for geocoding"),
)),
('mapquest_apikey', SecretKeySettingsField(
required=False,
label=_("MapQuest API key for geocoding"),
)),
('leaflet_tiles', forms.CharField(
required=False,
label=_("Leaflet tiles URL pattern"),

View File

@@ -16,7 +16,6 @@ from i18nfield.forms import I18nFormField, I18nTextarea
from pretix.base.channels import get_all_sales_channels
from pretix.base.forms import I18nFormSet, I18nModelForm
from pretix.base.forms.widgets import DatePickerWidget
from pretix.base.models import (
Item, ItemCategory, ItemVariation, Question, QuestionOption, Quota,
)
@@ -112,26 +111,14 @@ class QuestionForm(I18nModelForm):
'dependency_question',
'dependency_values',
'print_on_invoice',
'valid_number_min',
'valid_number_max',
'valid_datetime_min',
'valid_datetime_max',
'valid_date_min',
'valid_date_max',
]
widgets = {
'valid_datetime_min': SplitDateTimePickerWidget(),
'valid_datetime_max': SplitDateTimePickerWidget(),
'valid_date_min': DatePickerWidget(),
'valid_date_max': DatePickerWidget(),
'items': forms.CheckboxSelectMultiple(
attrs={'class': 'scrolling-multiple-choice'}
),
'dependency_values': forms.SelectMultiple,
}
field_classes = {
'valid_datetime_min': SplitDateTimeField,
'valid_datetime_max': SplitDateTimeField,
'items': SafeModelMultipleChoiceField,
'dependency_question': SafeModelChoiceField,
}
@@ -239,8 +226,6 @@ class ItemCreateForm(I18nModelForm):
def __init__(self, *args, **kwargs):
self.event = kwargs['event']
self.user = kwargs.pop('user')
kwargs.setdefault('initial', {})
kwargs['initial'].setdefault('admission', True)
super().__init__(*args, **kwargs)
self.fields['category'].queryset = self.instance.event.categories.all()

View File

@@ -770,7 +770,7 @@ class EventCancelForm(forms.Form):
if d.get('subevent') and d.get('subevents_from'):
raise ValidationError(pgettext_lazy('subevent', 'Please either select a specific date or a date range, not both.'))
if d.get('all_subevents') and d.get('subevent_from'):
raise ValidationError(pgettext_lazy('subevent', 'Please either select all dates or a date range, not both.'))
raise ValidationError(pgettext_lazy('subevent', 'Please either select all subevents or a date range, not both.'))
if bool(d.get('subevents_from')) != bool(d.get('subevents_to')):
raise ValidationError(pgettext_lazy('subevent', 'If you set a date range, please set both a start and an end.'))
if self.event.has_subevents and not d['subevent'] and not d['all_subevents'] and not d.get('subevents_from'):

View File

@@ -4,19 +4,24 @@ from urllib.parse import urlparse
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db.models import Q
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _, pgettext_lazy
from django_scopes.forms import SafeModelMultipleChoiceField
from i18nfield.forms import I18nFormField, I18nTextarea
from pretix.api.models import WebHook
from pretix.api.webhooks import get_all_webhook_events
from pretix.base.forms import I18nModelForm, SettingsForm
from pretix.base.forms.widgets import SplitDateTimePickerWidget
from pretix.base.models import Device, Gate, GiftCard, Organizer, Team
from pretix.control.forms import ExtFileField, SplitDateTimeField
from pretix.control.forms import (
ExtFileField, FontSelect, MultipleLanguagesWidget, SplitDateTimeField,
)
from pretix.control.forms.event import SafeEventMultipleChoiceField
from pretix.multidomain.models import KnownDomain
from pretix.presale.style import get_fonts
class OrganizerForm(I18nModelForm):
@@ -213,26 +218,72 @@ class DeviceForm(forms.ModelForm):
class OrganizerSettingsForm(SettingsForm):
auto_fields = [
'organizer_info_text',
'event_list_type',
'event_list_availability',
'organizer_homepage_text',
'organizer_link_back',
'organizer_logo_image_large',
'giftcard_length',
'giftcard_expiry_years',
'locales',
'event_team_provisioning',
'primary_color',
'theme_color_success',
'theme_color_danger',
'theme_color_background',
'theme_round_borders',
'primary_font'
]
organizer_info_text = I18nFormField(
label=_('Info text'),
required=False,
widget=I18nTextarea,
help_text=_('Not displayed anywhere by default, but if you want to, you can use this e.g. in ticket templates.')
)
event_team_provisioning = forms.BooleanField(
label=_('Allow creating a new team during event creation'),
help_text=_('Users that do not have access to all events under this organizer, must select one of their teams '
'to have access to the created event. This setting allows users to create an event-specified team'
' on-the-fly, even when they do not have \"Can change teams and permissions\" permission.'),
required=False,
)
primary_color = forms.CharField(
label=_("Primary color"),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_success = forms.CharField(
label=_("Accent color for success"),
help_text=_("We strongly suggest to use a shade of green."),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_danger = forms.CharField(
label=_("Accent color for errors"),
help_text=_("We strongly suggest to use a shade of red."),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield'})
)
theme_color_background = forms.CharField(
label=_("Page background color"),
required=False,
validators=[
RegexValidator(regex='^#[0-9a-fA-F]{6}$',
message=_('Please enter the hexadecimal code of a color, e.g. #990000.')),
],
widget=forms.TextInput(attrs={'class': 'colorpickerfield no-contrast'})
)
theme_round_borders = forms.BooleanField(
label=_("Use round edges"),
required=False,
)
organizer_homepage_text = I18nFormField(
label=_('Homepage text'),
required=False,
widget=I18nTextarea,
help_text=_('This will be displayed on the organizer homepage.')
)
organizer_logo_image = ExtFileField(
label=_('Header image'),
ext_whitelist=(".png", ".jpg", ".gif", ".jpeg"),
@@ -243,6 +294,44 @@ class OrganizerSettingsForm(SettingsForm):
'can increase the size with the setting below. We recommend not using small details on the picture '
'as it will be resized on smaller screens.')
)
organizer_logo_image_large = forms.BooleanField(
label=_('Use header image in its full size'),
help_text=_('We recommend to upload a picture at least 1170 pixels wide.'),
required=False,
)
event_list_type = forms.ChoiceField(
label=_('Default overview style'),
choices=(
('list', _('List')),
('week', _('Week calendar')),
('calendar', _('Month calendar')),
)
)
event_list_availability = forms.BooleanField(
label=_('Show availability in event overviews'),
help_text=_('If checked, the list of events will show if events are sold out. This might '
'make for longer page loading times if you have lots of events and the shown status might be out '
'of date for up to two minutes.'),
required=False
)
organizer_link_back = forms.BooleanField(
label=_('Link back to organizer overview on all event pages'),
required=False
)
locales = forms.MultipleChoiceField(
choices=settings.LANGUAGES,
label=_("Use languages"),
widget=MultipleLanguagesWidget,
help_text=_('Choose all languages that your organizer homepage should be available in.')
)
primary_font = forms.ChoiceField(
label=_('Font'),
choices=[
('Open Sans', 'Open Sans')
],
widget=FontSelect,
help_text=_('Only respected by modern browsers.')
)
favicon = ExtFileField(
label=_('Favicon'),
ext_whitelist=(".ico", ".png", ".jpg", ".gif", ".jpeg"),
@@ -251,6 +340,24 @@ class OrganizerSettingsForm(SettingsForm):
help_text=_('If you provide a favicon, we will show it instead of the default pretix icon. '
'We recommend a size of at least 200x200px to accommodate most devices.')
)
giftcard_length = forms.IntegerField(
label=_('Length of gift card codes'),
help_text=_('The system generates by default {}-character long gift card codes. However, if a different length '
'is required, it can be set here.'.format(settings.ENTROPY['giftcard_secret'])),
required=False
)
giftcard_expiry_years = forms.IntegerField(
label=_('Validity of gift card codes in years'),
help_text=_('If you set a number here, gift cards will by default expire at the end of the year after this '
'many years. If you keep it empty, gift cards do not have an explicit expiry date.'),
required=False
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['primary_font'].choices += [
(a, {"title": a, "data": v}) for a, v in get_fonts().items()
]
class WebHookForm(forms.ModelForm):

View File

@@ -305,7 +305,6 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs):
'pretix.event.order.email.attachments.skipped': _('The email has been sent without attachments since they '
'would have been too large to be likely to arrive.'),
'pretix.event.order.email.custom_sent': _('A custom email has been sent.'),
'pretix.event.order.position.email.custom_sent': _('A custom email has been sent to an attendee.'),
'pretix.event.order.email.download_reminder_sent': _('An email has been sent with a reminder that the ticket '
'is available for download.'),
'pretix.event.order.email.expire_warning_sent': _('An email has been sent with a warning that the order is about '
@@ -398,7 +397,7 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs):
'pretix.event.testmode.activated': _('The shop has been taken into test mode.'),
'pretix.event.testmode.deactivated': _('The test mode has been disabled.'),
'pretix.event.added': _('The event has been created.'),
'pretix.event.changed': _('The event details have been changed.'),
'pretix.event.changed': _('The event settings have been changed.'),
'pretix.event.question.option.added': _('An answer option has been added to the question.'),
'pretix.event.question.option.deleted': _('An answer option has been removed from the question.'),
'pretix.event.question.option.changed': _('An answer option has been changed.'),

View File

@@ -176,7 +176,7 @@ def get_event_navigation(request: HttpRequest):
'event': request.event.slug,
'organizer': request.event.organizer.slug,
}),
'active': url.url_name in ('event.orders', 'event.order', 'event.orders.search') or "event.order." in url.url_name,
'active': url.url_name in ('event.orders', 'event.order') or "event.order." in url.url_name,
},
{
'label': _('Overview'),

View File

@@ -323,19 +323,3 @@ this is not an Event signal and will be called even if your plugin is not active
event if the search is performed within an event, and ``None`` otherwise. The search query will be passed as
``query``.
"""
order_search_forms = EventPluginSignal(
providing_args=['request']
)
"""
This signal allows you to return additional forms that should be rendered in the advanced order search.
You are passed ``request`` argument and are expected to return an instance of a form class that you bind
yourself when appropriate. Your form will be executed as part of the standard validation and rendering
cycle and rendered using default bootstrap styles.
You are required to set ``prefix`` on your form instance. You are required to implement a ``filter_qs(queryset)``
method on your form that returns a new, filtered query set. You are required to implement a ``filter_to_strings()``
method on your form that returns a list of strings describing the currently active filters.
As with all plugin signals, the ``sender`` keyword argument will contain the event.
"""

View File

@@ -31,7 +31,6 @@
{% bootstrap_field form.invoice_address_beneficiary layout="control" %}
{% bootstrap_field form.invoice_address_not_asked_free layout="control" %}
{% bootstrap_field form.invoice_address_custom_field layout="control" %}
{% bootstrap_field form.invoice_address_explanation_text layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Issuer details" %}</legend>
@@ -52,6 +51,7 @@
{% bootstrap_field form.invoice_additional_text layout="control" %}
{% bootstrap_field form.invoice_footer_text layout="control" %}
{% bootstrap_field form.invoice_logo_image layout="control" %}
{% bootstrap_field form.invoice_address_explanation_text layout="control" %}
{% bootstrap_field form.invoice_eu_currencies layout="control" %}
</fieldset>
</div>

View File

@@ -66,7 +66,6 @@
{% bootstrap_field form.payment_term_last layout="control" %}
{% bootstrap_field form.payment_term_expire_automatically layout="control" %}
{% bootstrap_field form.payment_term_accept_late layout="control" %}
{% bootstrap_field form.payment_pending_hidden layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Advanced" %}</legend>

View File

@@ -98,7 +98,6 @@
{% bootstrap_field sform.attendee_addresses_asked layout="control" %}
{% bootstrap_field sform.attendee_addresses_required layout="control" %}
{% bootstrap_field sform.checkout_show_copy_answers_button layout="control" %}
{% bootstrap_field sform.attendee_data_explanation_text layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Texts" %}</legend>
@@ -220,7 +219,6 @@
{% if sform.event_list_type %}
{% bootstrap_field sform.event_list_type layout="control" %}
{% endif %}
{% bootstrap_field form.sales_channels layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Cart" %}</legend>

View File

@@ -18,135 +18,97 @@
<form action="" method="post" class="form-horizontal">
{% csrf_token %}
{% bootstrap_form_errors form %}
<div class="row">
<div class="col-xs-12 col-lg-10">
<div class="tabbed-form">
<fieldset>
<legend>{% trans "General" %}</legend>
{% bootstrap_field form.name layout="control" %}
{% bootstrap_field form.rate addon_after="%" layout="control" %}
{% bootstrap_field form.price_includes_tax layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Advanced" %}</legend>
<div class="alert alert-legal">
{% blocktrans trimmed with docs="https://docs.pretix.eu/en/latest/user/events/taxes.html" %}
These settings are intended for advanced users. See the
<a href="{{ docs }}">documentation</a>
for more information. Note that we are not responsible for the correct handling
of taxes in your ticket shop. If in doubt, please contact a lawyer or tax consultant.
{% endblocktrans %}
</div>
{% bootstrap_field form.eu_reverse_charge layout="control" %}
{% bootstrap_field form.home_country layout="control" %}
<h3>{% trans "Custom taxation rules" %}</h3>
<div class="alert alert-warning">
{% blocktrans trimmed %}
These settings are intended for professional users with very specific taxation situations.
If you create any rule here, the reverse charge settings above will be ignored. The rules will be
checked in order and once the first rule matches the order, it will be used and all further rules will
be ignored. If no rule matches, tax will be charged.
{% endblocktrans %}
{% trans "All of these rules will only apply if an invoice address is set." %}
</div>
<div class="tabbed-form">
<fieldset>
<legend>{% trans "General" %}</legend>
{% bootstrap_field form.name layout="control" %}
{% bootstrap_field form.rate addon_after="%" layout="control" %}
{% bootstrap_field form.price_includes_tax layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Advanced" %}</legend>
<div class="alert alert-legal">
{% blocktrans trimmed with docs="https://docs.pretix.eu/en/latest/user/events/taxes.html" %}
These settings are intended for advanced users. See the
<a href="{{ docs }}">documentation</a>
for more information. Note that we are not responsible for the correct handling
of taxes in your ticket shop. If in doubt, please contact a lawyer or tax consultant.
{% endblocktrans %}
<br>
{% blocktrans trimmed %}
The rules will be checked in order and once the first rule matches the order, it will be used and all further rules will
be ignored. If no rule matches, tax will be charged.
{% endblocktrans %}
{% trans "All of these rules will only apply if an invoice address is set." %}
</div>
<div class="formset tax-rules-formset" data-formset data-formset-prefix="{{ formset.prefix }}">
{{ formset.management_form }}
{% bootstrap_formset_errors formset %}
<script type="form-template" data-formset-empty-form>
{% escapescript %}
<div class="row tax-rule-line" data-formset-form>
<div class="sr-only">
{{ formset.empty_form.id }}
{% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
{% bootstrap_field formset.empty_form.ORDER form_group_class="" layout="inline" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field formset.empty_form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-4">
{% bootstrap_field formset.empty_form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field formset.empty_form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-2 text-right flip">
<button type="button" class="btn btn-default" data-formset-move-up-button>
<i class="fa fa-arrow-up"></i></button>
<button type="button" class="btn btn-default" data-formset-move-down-button>
<i class="fa fa-arrow-down"></i></button>
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
<div class="col-sm-6 col-md-3 col-lg-4 col-md-offset-3">
{% bootstrap_field formset.empty_form.invoice_text layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field formset.empty_form.rate layout='inline' form_group_class="" %}
</div>
</div>
{% endescapescript %}
</script>
<div data-formset-body class="tax-rule-lines">
{% for form in formset %}
{% bootstrap_form_errors form %}
<div class="row tax-rule-line" data-formset-form>
<div class="sr-only">
{{ form.id }}
{% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
{% bootstrap_field form.ORDER form_group_class="" layout="inline" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-4">
{% bootstrap_field form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-2 text-right flip">
<button type="button" class="btn btn-default" data-formset-move-up-button>
<i class="fa fa-arrow-up"></i></button>
<button type="button" class="btn btn-default" data-formset-move-down-button>
<i class="fa fa-arrow-down"></i></button>
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
<div class="col-sm-6 col-md-3 col-lg-4 col-md-offset-3">
{% bootstrap_field form.invoice_text layout='inline' form_group_class="" %}
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
{% bootstrap_field form.rate layout='inline' form_group_class="" %}
</div>
</div>
{% endfor %}
</div>
<div class="row tax-rule-line" data-formset-form>
<div class="col-sm-12">
<button type="button" class="btn btn-default" data-formset-add>
<i class="fa fa-plus"></i> {% trans "Add a new rule" %}</button>
<div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
{{ formset.management_form }}
{% bootstrap_formset_errors formset %}
<div data-formset-body>
{% for form in formset %}
{% bootstrap_form_errors form %}
<div class="row" data-formset-form>
<div class="sr-only">
{{ form.id }}
{% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2">
{% bootstrap_field form.rate layout='inline' form_group_class="" %}
</div>
<div class="col-sm-1 text-right flip">
<button type="button" class="btn btn-block btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div>
</div>
</fieldset>
</div>
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}
</button>
</div>
</div>
<div class="col-xs-12 col-lg-2">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{% trans "Change history" %}
</h3>
{% endfor %}
</div>
{% include "pretixcontrol/includes/logs.html" with obj=rule %}
<script type="form-template" data-formset-empty-form>
{% escapescript %}
<div class="row" data-formset-form>
<div class="sr-only">
{{ form.id }}
{% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2">
{% bootstrap_field formset.empty_form.rate layout='inline' form_group_class="" %}
</div>
<div class="col-sm-1 text-right flip">
<button type="button" class="btn btn-block btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div>
{% endescapescript %}
</script>
<p>
<button type="button" class="btn btn-default" data-formset-add>
<i class="fa fa-plus"></i> {% trans "Add a new rule" %}</button>
</p>
</div>
</div>
</fieldset>
</div>
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}
</button>
</div>
</form>
{% endblock %}

View File

@@ -4,11 +4,11 @@
{% block form %}
{% bootstrap_field form.organizer layout="horizontal" %}
<div class="form-group">
<label class="col-md-3 control-label">{% trans "Event type" %}</label>
<label class="col-md-3 control-label">Event type</label>
<div class="col-md-9">
<div class="big-radio radio">
<label>
<input type="radio" value="" name="{{ form.has_subevents.html_name }}" {% if not form.has_subevents.value %}checked{% endif %}>
<input type="radio" value="" name="{{ form.has_subevents.html_name }}">
<span class="fa fa-calendar-o"></span>
<strong>{% trans "Singular event or non-event shop" %}</strong><br>
<div class="help-block">
@@ -27,7 +27,7 @@
</div>
<div class="big-radio radio">
<label>
<input type="radio" value="on" name="{{ form.has_subevents.html_name }}" {% if form.has_subevents.avalue %}checked{% endif %}>
<input type="radio" value="on" name="{{ form.has_subevents.html_name }}">
<span class="fa fa-calendar"></span>
<strong>{% trans "Event series or time slot booking" %}</strong>
<div class="help-block">

View File

@@ -6,7 +6,7 @@
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
{% bootstrap_form_errors form %}
{% bootstrap_form form layout='control' %}
{% bootstrap_form form layout='horizontal' %}
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}

View File

@@ -14,84 +14,9 @@
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.copy_from layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label">{% trans "Product type" %}</label>
<div class="col-md-9">
<div class="big-radio radio">
<label>
<input type="radio" value="on" name="{{ form.admission.html_name }}" {% if form.admission.value %}checked{% endif %}>
<span class="fa fa-user"></span>
<strong>{% trans "Admission product" %}</strong><br>
<div class="help-block">
{% blocktrans trimmed %}
Every purchase of this product represents one person who is allowed to enter your event.
By default, pretix will only ask for attendee information and offer ticket downloads for these products.
{% endblocktrans %}
</div>
<div class="help-block">
{% blocktrans trimmed %}
This option should be set for most things that you would call a "ticket". For product add-ons or bundles, this should
be set on the main ticket, except if the add-on products or bundled products represent additional people (e.g. group bundles).
{% endblocktrans %}
</div>
</label>
</div>
<div class="big-radio radio">
<label>
<input type="radio" value="" name="{{ form.admission.html_name }}" {% if not form.admission.value %}checked{% endif %}>
<span class="fa fa-cube"></span>
<strong>{% trans "Non-admission product" %}</strong>
<div class="help-block">
{% blocktrans trimmed %}
A product that does not represent a person. By default, pretix will not ask for attendee information or offer
ticket downloads.
{% endblocktrans %}
</div>
<div class="help-block">
{% blocktrans trimmed %}
Examples: Merchandise, donations, gift cards, add-ons to a main ticket.
{% endblocktrans %}
</div>
</label>
</div>
</div>
</div>
{% bootstrap_field form.has_variations layout="control" %}
{% bootstrap_field form.category layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label">{% trans "Product variations" %}</label>
<div class="col-md-9">
<div class="big-radio radio">
<label>
<input type="radio" value="" name="{{ form.has_variations.html_name }}" {% if not form.has_variations.value %}checked{% endif %}>
<span class="fa fa-fw fa-square"></span>
<strong>{% trans "Product without variations" %}</strong><br>
</label>
</div>
<div class="big-radio radio">
<label>
<input type="radio" value="on" name="{{ form.has_variations.html_name }}" {% if form.has_variations.value %}checked{% endif %}>
<span class="fa fa-fw fa-th-large"></span>
<strong>{% trans "Product with multiple variations" %}</strong>
<div class="help-block">
{% blocktrans trimmed %}
This product exists in multiple variations which are different in either their name, price, quota, or description.
All other settings need to be the same.
{% endblocktrans %}
</div>
<div class="help-block">
{% blocktrans trimmed %}
Examples: Ticket category with variations for "full price" and "reduced", merchandise with variations for different sizes,
workshop add-on with variations for simultaneous workshops.
{% endblocktrans %}
</div>
</label>
</div>
</div>
</div>
{% bootstrap_field form.admission layout="control" %}
</fieldset>
{% if form.quota_option %}
<fieldset>

View File

@@ -10,56 +10,13 @@
<div class="tabbed-form">
<fieldset>
<legend>{% trans "General" %}</legend>
{% bootstrap_field form.active layout="control" %}
{% bootstrap_field form.name layout="control" %}
<div class="internal-name-wrapper">
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.category layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label">{% trans "Product type" %}</label>
<div class="col-md-9">
<div class="big-radio radio">
<label>
<input type="radio" value="on" name="{{ form.admission.html_name }}" {% if form.admission.value %}checked{% endif %}>
<span class="fa fa-fw fa-user"></span>
<strong>{% trans "Admission product" %}</strong><br>
<div class="help-block">
{% blocktrans trimmed %}
Every purchase of this product represents one person who is allowed to enter your event.
By default, pretix will only ask for attendee information and offer ticket downloads for these products.
{% endblocktrans %}
</div>
<div class="help-block">
{% blocktrans trimmed %}
This option should be set for most things that you would call a "ticket". For product add-ons or bundles, this should
be set on the main ticket, except if the add-on products or bundled products represent additional people (e.g. group bundles).
{% endblocktrans %}
</div>
</label>
</div>
<div class="big-radio radio">
<label>
<input type="radio" value="" name="{{ form.admission.html_name }}" {% if not form.admission.value %}checked{% endif %}>
<span class="fa fa-fw fa-cube"></span>
<strong>{% trans "Non-admission product" %}</strong>
<div class="help-block">
{% blocktrans trimmed %}
A product that does not represent a person. By default, pretix will not ask for attendee information or offer
ticket downloads.
{% endblocktrans %}
</div>
<div class="help-block">
{% blocktrans trimmed %}
Examples: Merchandise, donations, gift cards, add-ons to a main ticket.
{% endblocktrans %}
</div>
</label>
</div>
</div>
</div>
{% bootstrap_field form.active layout="control" %}
{% bootstrap_field form.admission layout="control" %}
{% bootstrap_field form.description layout="control" %}
{% bootstrap_field form.picture layout="control" %}
{% bootstrap_field form.require_approval layout="control" %}

View File

@@ -73,7 +73,7 @@
</td>
<td>
{% if i.var_count %}
<span class="fa fa-th-large fa-fw text-muted" data-toggle="tooltip" title="{% trans "Product with variations" %}"></span>
<span class="fa fa-list-ul fa-fw text-muted" data-toggle="tooltip" title="{% trans "Product with variations" %}"></span>
{% endif %}
</td>
<td>

View File

@@ -32,18 +32,6 @@
accepted. If you want to allow both options, do not make this field required.
{% endblocktrans %}
</div>
<div id="valid-number">
{% bootstrap_field form.valid_number_min layout="control" %}
{% bootstrap_field form.valid_number_max layout="control" %}
</div>
<div id="valid-date">
{% bootstrap_field form.valid_date_min layout="control" %}
{% bootstrap_field form.valid_date_max layout="control" %}
</div>
<div id="valid-datetime">
{% bootstrap_field form.valid_datetime_min layout="control" %}
{% bootstrap_field form.valid_datetime_max layout="control" %}
</div>
<div id="answer-options">
<h3>{% trans "Answer options" %}</h3>
<noscript>

View File

@@ -268,12 +268,12 @@
<div class="panel panel-default items">
<div class="panel-heading">
<div class="pull-right flip">
<a href="{% url "control:event.order.info" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
<span class="fa fa-edit"></span>
{% trans "Change answers" %}
</a>
{% if order.changable and 'can_change_orders' in request.eventpermset %}
&middot; <a href="{% url "control:event.order.change" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
<a href="{% url "control:event.order.info" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
<span class="fa fa-edit"></span>
{% trans "Change answers" %}
</a> &middot;
<a href="{% url "control:event.order.change" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
<span class="fa fa-edit"></span>
{% trans "Change products" %}
</a>

View File

@@ -25,30 +25,22 @@
<strong>{{ pending }}</strong>. The order total is <strong>{{ total }}</strong>.
{% endblocktrans %}
</p>
{% if order.status == "c" or order.positions.count == 0 %}
<p>
{% blocktrans trimmed %}
Since the order is already canceled, this will not affect its state.
{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans trimmed with amount=refund.amount|money:request.event.currency method=refund.payment_provider.verbose_name %}
What should happen to the ticket order?
{% endblocktrans %}
</p>
<div class="form-inline">
<label class="radio">
<input type="radio" name="action" value="n" {% if not propose_cancel %}checked{% endif %}>
{% trans "Mark the order as unpaid and allow the customer to pay again with another payment method." %}
</label>
<br>
<label class="radio">
<input type="radio" name="action" value="r" {% if propose_cancel %}checked{% endif %}>
{% trans "Cancel the order irrevocably." %}
</label>
</div>
{% endif %}
<p>
{% blocktrans trimmed with amount=refund.amount|money:request.event.currency method=refund.payment_provider.verbose_name %}
What should happen to the ticket order?
{% endblocktrans %}
</p>
<div class="form-inline">
<label class="radio">
<input type="radio" name="action" value="n" {% if not propose_cancel %}checked{% endif %}>
{% trans "Mark the order as unpaid and allow the customer to pay again with another payment method." %}
</label>
<br>
<label class="radio">
<input type="radio" name="action" value="r" {% if propose_cancel %}checked{% endif %}>
{% trans "Cancel the order irrevocably." %}
</label>
</div>
<div class="form-group submit-group">
<a class="btn btn-default btn-lg"
href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">

View File

@@ -7,7 +7,7 @@
{% block title %}{% trans "Orders" %}{% endblock %}
{% block content %}
<h1>{% trans "Orders" %}</h1>
{% if not filter_form.filtered and orders|length == 0 and not filter_strings %}
{% if not filter_form.filtered and orders|length == 0 %}
<div class="empty-collection">
<p>
{% blocktrans trimmed %}
@@ -21,72 +21,57 @@
{% trans "Take your shop live" %}
</a>
{% else %}
<a href="{% eventurl request.event "presale:event.index" %}" class="btn btn-primary btn-lg" target="_blank">
<a href="{% eventurl request.event "presale:event.index" %}" class="btn btn-primary btn-lg">
{% trans "Go to the ticket shop" %}
</a>
{% endif %}
</div>
{% else %}
{% if filter_strings %}
<p>
<span class="fa fa-filter"></span>
{% trans "Search query:" %}
{{ filter_strings|join:" · " }}
·
<a href="{% url "control:event.orders.search" event=request.event.slug organizer=request.event.organizer.slug %}?{{ request.META.QUERY_STRING }}">
<span class="fa fa-edit"></span>
{% trans "Edit" %}
</a>
</p>
{% else %}
<div class="row filter-form">
<form class="col-md-2 col-xs-12"
action="{% url "control:event.orders.go" event=request.event.slug organizer=request.event.organizer.slug %}">
<div class="input-group">
<input type="text" name="code" class="form-control" placeholder="{% trans "Order code" %}" autofocus>
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">{% trans "Go!" %}</button>
<div class="row filter-form">
<form class="col-md-2 col-xs-12"
action="{% url "control:event.orders.go" event=request.event.slug organizer=request.event.organizer.slug %}">
<div class="input-group">
<input type="text" name="code" class="form-control" placeholder="{% trans "Order code" %}" autofocus>
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">{% trans "Go!" %}</button>
</span>
</div>
</form>
<form class="" action="" method="get">
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.status layout='inline' %}
</div>
{% if request.event.has_subevents %}
<div class="col-md-1 col-xs-6">
{% bootstrap_field filter_form.item layout='inline' %}
</div>
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.subevent layout='inline' %}
</div>
<div class="col-md-1 col-xs-6">
{% bootstrap_field filter_form.provider layout='inline' %}
</div>
{% else %}
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.item layout='inline' %}
</div>
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.provider layout='inline' %}
</div>
{% endif %}
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.query layout='inline' %}
</div>
<div class="col-md-2 col-xs-6">
<button class="btn btn-primary btn-block" type="submit">
<span class="fa fa-filter"></span>
<span class="hidden-md">
{% trans "Filter" %}
</span>
</div>
</form>
<form class="" action="" method="get">
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.status layout='inline' %}
</div>
{% if request.event.has_subevents %}
<div class="col-md-1 col-xs-6">
{% bootstrap_field filter_form.item layout='inline' %}
</div>
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.subevent layout='inline' %}
</div>
<div class="col-md-1 col-xs-6">
{% bootstrap_field filter_form.provider layout='inline' %}
</div>
{% else %}
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.item layout='inline' %}
</div>
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.provider layout='inline' %}
</div>
{% endif %}
<div class="col-md-2 col-xs-6">
{% bootstrap_field filter_form.query layout='inline' %}
</div>
<div class="col-md-1 col-xs-6">
<button class="btn btn-primary btn-block" type="submit">
<span class="fa fa-filter"></span>
</button>
</div>
<div class="col-md-1 col-xs-6">
<a href="{% url "control:event.orders.search" event=request.event.slug organizer=request.event.organizer.slug %}" class="btn btn-default btn-block" type="submit" data-toggle="tooltip" title="{% trans "Advanced search" %}">
<span class="fa fa-cog"></span>
</a>
</div>
</form>
</div>
{% endif %}
</button>
</div>
</form>
</div>
{% if filter_form.is_valid and filter_form.cleaned_data.question %}
<p class="text-muted">
<span class="fa fa-filter"></span>

View File

@@ -12,14 +12,7 @@
<button type="button" data-target=".sum-net" class="btn btn-default">{% trans "Revenue (net)" %}</button>
</div>
</div>
<h1>
{% trans "Order overview" %}
<a href="{% url "control:event.orders.export" event=request.event.slug organizer=request.event.organizer.slug %}?identifier=pdfreport"
class="btn btn-default" target="_blank">
<span class="fa fa-download"></span>
{% trans "PDF" %}
</a>
</h1>
<h1>{% trans "Order overview" %}</h1>
<div class="row filter-form">
<form class="" action="" method="get">
{% if request.event.has_subevents %}
@@ -65,14 +58,12 @@
<th>{% trans "Product" %}</th>
<th>{% trans "Canceled" %}¹</th>
<th>{% trans "Expired" %}</th>
<th>{% trans "Approval pending" %}</th>
<th colspan="3" class="text-center">{% trans "Purchased" %}</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th>{% trans "Pending" %}</th>
<th>{% trans "Paid" %}</th>
<th>{% trans "Total" %}</th>
@@ -85,7 +76,6 @@
<th>{{ tup.0 }}</th>
<th>{{ tup.0.num.canceled|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num.expired|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num.unapproved|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num.pending|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num.paid|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num.total|togglesum:request.event.currency }}</th>
@@ -105,12 +95,7 @@
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=pa&amp;provider={{ item.provider }}">
{{ item.num.unapproved|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=na&amp;provider={{ item.provider }}">
<a href="{{ listurl }}?item={{ item.id }}&amp;status=n&amp;provider={{ item.provider }}">
{{ item.num.pending|togglesum:request.event.currency }}
</a>
</td>
@@ -138,12 +123,7 @@
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}-{{ var.id }}&amp;status=pa&amp;provider={{ item.provider }}">
{{ var.num.unapproved|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}-{{ var.id }}&amp;status=na&amp;provider={{ item.provider }}">
<a href="{{ listurl }}?item={{ item.id }}-{{ var.id }}&amp;status=n&amp;provider={{ item.provider }}">
{{ var.num.pending|togglesum:request.event.currency }}
</a>
</td>
@@ -166,7 +146,6 @@
<th>{% trans "Total" %}</th>
<th>{{ total.num.canceled|togglesum:request.event.currency }}</th>
<th>{{ total.num.expired|togglesum:request.event.currency }}</th>
<th>{{ total.num.unapproved|togglesum:request.event.currency }}</th>
<th>{{ total.num.pending|togglesum:request.event.currency }}</th>
<th>{{ total.num.paid|togglesum:request.event.currency }}</th>
<th>{{ total.num.total|togglesum:request.event.currency }}</th>

View File

@@ -1,23 +0,0 @@
{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load eventurl %}
{% load urlreplace %}
{% load money %}
{% load bootstrap3 %}
{% block title %}{% trans "Order search" %}{% endblock %}
{% block content %}
<h1>{% trans "Order search" %}</h1>
<form class="form-horizontal" action="{% url "control:event.orders" event=request.event.slug organizer=request.event.organizer.slug %}" method="get">
{% for f in forms %}
{% bootstrap_form_errors f layout='control' %}
{% for field in f %}
{% bootstrap_field field layout='control' %}
{% endfor %}
{% endfor %}
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Search" %}
</button>
</div>
</form>
{% endblock %}

View File

@@ -1,13 +0,0 @@
{% extends "pretixcontrol/auth/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Disable notifications" %}{% endblock %}
{% block content %}
<form action="" method="post" class="form-signin">
{% csrf_token %}
<div class="text-center">
<p>Please confirm that you no longer want to receive notifications for any of your events.</p>
<p><button type="submit" class="btn btn-primary" value="Disable notifications">Disable notifications</button></p>
</div>
</form>
{% endblock %}

View File

@@ -283,7 +283,6 @@ urlpatterns = [
url(r'^orders/refunds/$', orders.RefundList.as_view(), name='event.orders.refunds'),
url(r'^orders/go$', orders.OrderGo.as_view(), name='event.orders.go'),
url(r'^orders/$', orders.OrderList.as_view(), name='event.orders'),
url(r'^orders/search$', orders.OrderSearch.as_view(), name='event.orders.search'),
url(r'^dangerzone/$', event.DangerZone.as_view(), name='event.dangerzone'),
url(r'^cancel/$', orders.EventCancel.as_view(), name='event.cancel'),
url(r'^shredder/$', shredder.StartShredView.as_view(), name='event.shredder.start'),

View File

@@ -10,6 +10,7 @@ from django.conf import settings
from django.contrib import messages
from django.contrib.contenttypes.models import ContentType
from django.core.files import File
from django.core.serializers.json import DjangoJSONEncoder
from django.db import transaction
from django.db.models import ProtectedError
from django.forms import inlineformset_factory
@@ -27,7 +28,6 @@ from django.views.generic import DeleteView, FormView, ListView
from django.views.generic.base import TemplateView, View
from django.views.generic.detail import SingleObjectMixin
from i18nfield.strings import LazyI18nString
from i18nfield.utils import I18nJSONEncoder
from pytz import timezone
from pretix.base.channels import get_all_sales_channels
@@ -56,7 +56,7 @@ from pretix.plugins.stripe.payment import StripeSettingsHolder
from pretix.presale.style import regenerate_css
from ...base.models.items import ItemMetaProperty
from ...base.settings import SETTINGS_AFFECTING_CSS, LazyI18nStringList
from ...base.settings import LazyI18nStringList
from ..logdisplay import OVERVIEW_BANLIST
from . import CreateView, PaginationMixin, UpdateView
@@ -161,7 +161,11 @@ class EventUpdate(DecoupleMixin, EventSettingsViewMixin, EventPermissionRequired
if self.confirm_texts_formset.has_changed():
data.update(confirm_texts=self.confirm_texts_formset.cleaned_data)
self.request.event.log_action('pretix.event.settings', user=self.request.user, data=data)
if any(p in self.sform.changed_data for p in SETTINGS_AFFECTING_CSS):
display_properties = (
'primary_color', 'theme_color_success', 'theme_color_danger', 'primary_font',
'theme_color_background', 'theme_round_borders',
)
if any(p in self.sform.changed_data for p in display_properties):
change_css = True
if form.has_changed():
self.request.event.log_action('pretix.event.changed', user=self.request.user, data={
@@ -933,7 +937,6 @@ class EventDelete(RecentAuthenticationRequiredMixin, EventPermissionRequiredMixi
data={
'event_id': self.request.event.pk,
'name': str(self.request.event.name),
'slug': self.request.event.slug,
'logentries': list(self.request.event.logentry_set.values_list('pk', flat=True))
}
)
@@ -1093,7 +1096,6 @@ class TaxCreate(EventSettingsViewMixin, EventPermissionRequiredMixin, CreateView
def formset(self):
return TaxRuleLineFormSet(
data=self.request.POST if self.request.method == "POST" else None,
event=self.request.event,
)
def get_context_data(self, **kwargs):
@@ -1105,8 +1107,8 @@ class TaxCreate(EventSettingsViewMixin, EventPermissionRequiredMixin, CreateView
def form_valid(self, form):
form.instance.event = self.request.event
form.instance.custom_rules = json.dumps([
f.cleaned_data for f in self.formset.ordered_forms if f not in self.formset.deleted_forms
], cls=I18nJSONEncoder)
f.cleaned_data for f in self.formset if f not in self.formset.deleted_forms
], cls=DjangoJSONEncoder)
messages.success(self.request, _('The new tax rule has been created.'))
ret = super().form_valid(form)
form.instance.log_action('pretix.event.taxrule.added', user=self.request.user, data=dict(form.cleaned_data))
@@ -1144,7 +1146,6 @@ class TaxUpdate(EventSettingsViewMixin, EventPermissionRequiredMixin, UpdateView
def formset(self):
return TaxRuleLineFormSet(
data=self.request.POST if self.request.method == "POST" else None,
event=self.request.event,
initial=json.loads(self.object.custom_rules) if self.object.custom_rules else []
)
@@ -1157,8 +1158,8 @@ class TaxUpdate(EventSettingsViewMixin, EventPermissionRequiredMixin, UpdateView
def form_valid(self, form):
messages.success(self.request, _('Your changes have been saved.'))
form.instance.custom_rules = json.dumps([
f.cleaned_data for f in self.formset.ordered_forms if f not in self.formset.deleted_forms
], cls=I18nJSONEncoder)
f.cleaned_data for f in self.formset if f not in self.formset.deleted_forms
], cls=DjangoJSONEncoder)
if form.has_changed():
self.object.log_action(
'pretix.event.taxrule.changed', user=self.request.user, data={

View File

@@ -14,7 +14,14 @@ logger = logging.getLogger(__name__)
class GeoCodeView(LoginRequiredMixin, View):
def get(self, request, *args, **kwargs):
q = self.request.GET.get('q')
gs = GlobalSettingsObject()
if not gs.settings.opencagedata_apikey:
return JsonResponse({
'success': False,
'results': []
}, status=200)
q = request.GET.get('q')
cd = cache.get('geocode:{}'.format(q))
if cd:
return JsonResponse({
@@ -22,26 +29,6 @@ class GeoCodeView(LoginRequiredMixin, View):
'results': cd
}, status=200)
gs = GlobalSettingsObject()
if gs.settings.opencagedata_apikey:
res = self._use_opencage(q)
if gs.settings.mapquest_apikey:
res = self._use_mapquest(q)
else:
return JsonResponse({
'success': False,
'results': []
}, status=200)
cache.set('geocode:{}'.format(q), res, timeout=3600 * 6)
return JsonResponse({
'success': True,
'results': res
}, status=200)
def _use_opencage(self, q):
gs = GlobalSettingsObject()
try:
r = requests.get(
'https://api.opencagedata.com/geocode/v1/json?q={}&key={}'.format(
@@ -64,31 +51,9 @@ class GeoCodeView(LoginRequiredMixin, View):
'lon': r['geometry']['lng'],
} for r in d['results']
]
return res
cache.set('geocode:{}'.format(q), res, timeout=3600 * 6)
def _use_mapquest(self, q):
gs = GlobalSettingsObject()
try:
r = requests.get(
'http://www.mapquestapi.com/geocoding/v1/address?location={}&key={}'.format(
quote(q), gs.settings.mapquest_apikey
)
)
r.raise_for_status()
except IOError:
logger.exception("Geocoding failed")
return JsonResponse({
'success': False,
'results': []
}, status=200)
else:
d = r.json()
res = [
{
'formatted': q,
'lat': r['locations'][0]['latLng']['lat'],
'lon': r['locations'][0]['latLng']['lng'],
} for r in d['results']
]
return res
return JsonResponse({
'success': True,
'results': res
}, status=200)

View File

@@ -236,10 +236,6 @@ class EventWizard(SafeSessionWizardView):
event.has_subevents = foundation_data['has_subevents']
event.testmode = True
form_dict['basics'].save()
event.log_action(
'pretix.event.added',
user=self.request.user,
)
if not EventWizardBasicsForm.has_control_rights(self.request.user, event.organizer):
if basics_data["team"] is not None:

View File

@@ -45,7 +45,7 @@ from pretix.base.models import (
from pretix.base.models.orders import (
CancellationRequest, OrderFee, OrderPayment, OrderPosition, OrderRefund,
)
from pretix.base.models.tax import cc_to_vat_prefix, is_eu_country
from pretix.base.models.tax import EU_COUNTRIES, cc_to_vat_prefix
from pretix.base.payment import PaymentException
from pretix.base.secrets import assign_ticket_secret
from pretix.base.services import tickets
@@ -74,8 +74,7 @@ from pretix.base.templatetags.rich_text import markdown_compile_email
from pretix.base.views.mixins import OrderQuestionsViewMixin
from pretix.base.views.tasks import AsyncAction
from pretix.control.forms.filter import (
EventOrderExpertFilterForm, EventOrderFilterForm, OverviewFilterForm,
RefundFilterForm,
EventOrderFilterForm, OverviewFilterForm, RefundFilterForm,
)
from pretix.control.forms.orders import (
CancelForm, CommentForm, ConfirmPaymentForm, EventCancelForm, ExporterForm,
@@ -85,7 +84,6 @@ from pretix.control.forms.orders import (
OrderRefundForm, OtherOperationsForm,
)
from pretix.control.permissions import EventPermissionRequiredMixin
from pretix.control.signals import order_search_forms
from pretix.control.views import PaginationMixin
from pretix.helpers.safedownload import check_token
from pretix.presale.signals import question_form_fields
@@ -93,31 +91,7 @@ from pretix.presale.signals import question_form_fields
logger = logging.getLogger(__name__)
class OrderSearchMixin:
def get_forms(self):
f = [
EventOrderExpertFilterForm(
data=self.request.GET,
event=self.request.event,
prefix='expert',
)
]
for recv, resp in order_search_forms.send(sender=self.request.event, request=self.request):
f.append(resp)
return f
class OrderSearch(OrderSearchMixin, EventPermissionRequiredMixin, TemplateView):
template_name = 'pretixcontrol/orders/search.html'
permission = 'can_view_orders'
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['forms'] = self.get_forms()
return ctx
class OrderList(OrderSearchMixin, EventPermissionRequiredMixin, PaginationMixin, ListView):
class OrderList(EventPermissionRequiredMixin, PaginationMixin, ListView):
model = Order
context_object_name = 'orders'
template_name = 'pretixcontrol/orders/index.html'
@@ -131,21 +105,12 @@ class OrderList(OrderSearchMixin, EventPermissionRequiredMixin, PaginationMixin,
if self.filter_form.is_valid():
qs = self.filter_form.filter_qs(qs)
for f in self.get_forms():
if any(k.startswith(f.prefix) for k in self.request.GET.keys()) and f.is_valid():
qs = f.filter_qs(qs)
return qs
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['filter_form'] = self.filter_form
ctx['filter_strings'] = []
for f in self.get_forms():
if any(k.startswith(f.prefix) for k in self.request.GET.keys()) and f.is_valid():
ctx['filter_strings'] += f.filter_to_strings()
# Only compute this annotations for this page (query optimization)
s = OrderPosition.objects.filter(
order=OuterRef('pk')
@@ -601,17 +566,16 @@ class OrderRefundProcess(OrderView):
if self.refund.state == OrderRefund.REFUND_STATE_EXTERNAL:
self.refund.done(user=self.request.user)
if self.order.status != Order.STATUS_CANCELED and self.order.positions.exists():
if self.request.POST.get("action") == "r":
mark_order_refunded(self.order, user=self.request.user)
elif not (self.order.status == Order.STATUS_PAID and self.order.pending_sum <= 0):
self.order.status = Order.STATUS_PENDING
self.order.set_expires(
now(),
self.order.event.subevents.filter(
id__in=self.order.positions.values_list('subevent_id', flat=True))
)
self.order.save(update_fields=['status', 'expires'])
if self.request.POST.get("action") == "r" and (self.order.status != Order.STATUS_CANCELED and self.order.positions.exists()):
mark_order_refunded(self.order, user=self.request.user)
elif not (self.order.status == Order.STATUS_PAID and self.order.pending_sum <= 0):
self.order.status = Order.STATUS_PENDING
self.order.set_expires(
now(),
self.order.event.subevents.filter(
id__in=self.order.positions.values_list('subevent_id', flat=True))
)
self.order.save(update_fields=['status', 'expires'])
messages.success(self.request, _('The refund has been processed.'))
else:
@@ -1166,7 +1130,7 @@ class OrderCheckVATID(OrderView):
messages.error(self.request, _('No country specified.'))
return redirect(self.get_order_url())
if not is_eu_country(ia.country):
if str(ia.country) not in EU_COUNTRIES:
messages.error(self.request, _('VAT ID could not be checked since a non-EU country has been '
'specified.'))
return redirect(self.get_order_url())
@@ -1551,7 +1515,7 @@ class OrderChange(OrderView):
elif change_subevent is not None:
ocm.change_subevent(p, *change_subevent)
if p.form.cleaned_data.get('seat') and (not p.seat or p.form.cleaned_data['seat'] != p.seat.seat_guid or change_subevent):
if p.form.cleaned_data.get('seat') and (not p.seat or p.form.cleaned_data['seat'] != p.seat.seat_guid):
ocm.change_seat(p, p.form.cleaned_data['seat'])
if p.form.cleaned_data['price'] is not None and p.form.cleaned_data['price'] != p.price:
@@ -1885,8 +1849,7 @@ class OrderEmailHistory(EventPermissionRequiredMixin, OrderViewMixin, ListView):
)
qs = order.all_logentries()
qs = qs.filter(
Q(action_type__contains="order.email") |
Q(action_type__contains="order.position.email")
action_type__contains="order.email"
)
return qs

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