pretix-withdrawal 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pretix_withdrawal-1.0.0/LICENSE +13 -0
- pretix_withdrawal-1.0.0/MANIFEST.in +5 -0
- pretix_withdrawal-1.0.0/PKG-INFO +84 -0
- pretix_withdrawal-1.0.0/README.rst +57 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/__init__.py +1 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/apps.py +53 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/forms.py +274 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/locale/de/LC_MESSAGES/django.po +548 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/locale/de_Informal/.gitkeep +0 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/locale/de_Informal/LC_MESSAGES/django.po +545 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/locale/django.pot +484 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/migrations/0001_initial.py +66 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/migrations/__init__.py +0 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/models.py +268 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/signals.py +214 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/static/pretix_withdrawal/.gitkeep +0 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/.gitkeep +0 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/detail.html +135 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/event_settings.html +10 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/list.html +197 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/order_info.html +50 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/settings.html +39 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/control/settle.html +112 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/templates/pretix_withdrawal/presale_form.html +32 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/urls.py +56 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal/views.py +439 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal.egg-info/PKG-INFO +84 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal.egg-info/SOURCES.txt +34 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal.egg-info/dependency_links.txt +1 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal.egg-info/entry_points.txt +5 -0
- pretix_withdrawal-1.0.0/pretix_withdrawal.egg-info/top_level.txt +1 -0
- pretix_withdrawal-1.0.0/pyproject.toml +42 -0
- pretix_withdrawal-1.0.0/setup.cfg +49 -0
- pretix_withdrawal-1.0.0/setup.py +3 -0
- pretix_withdrawal-1.0.0/tests/test_main.py +3 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018 Raphael Michel
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pretix-withdrawal
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Support right of withdrawal from purchases to comply with EU legislation.
|
|
5
|
+
Author-email: pretix team <support@pretix.eu>
|
|
6
|
+
Maintainer-email: pretix team <support@pretix.eu>
|
|
7
|
+
License: Copyright 2018 Raphael Michel
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
|
20
|
+
|
|
21
|
+
Project-URL: homepage, https://github.com/pretix/pretix-withdrawal
|
|
22
|
+
Project-URL: repository, https://github.com/pretix/pretix-withdrawal.git
|
|
23
|
+
Keywords: pretix
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
Withdrawal
|
|
29
|
+
==========================
|
|
30
|
+
|
|
31
|
+
This is a plugin for `pretix`_.
|
|
32
|
+
|
|
33
|
+
To comply with EU legislation you need to add support the right of withdrawal for online purchases. This plugin adds
|
|
34
|
+
a visually distinct link in the footer of every page of the pretix-shop. This link leads to a form on organizer-level
|
|
35
|
+
to allow the customer to withdraw from an online purchase. When submitted, this form notifies the organizer (or any
|
|
36
|
+
team-member assigned through the pretix notification system) via email and creates a WithdrawalRequest accessible in
|
|
37
|
+
pretix-control.
|
|
38
|
+
|
|
39
|
+
Development setup
|
|
40
|
+
-----------------
|
|
41
|
+
|
|
42
|
+
1. Make sure that you have a working `pretix development setup`_.
|
|
43
|
+
|
|
44
|
+
2. Clone this repository.
|
|
45
|
+
|
|
46
|
+
3. Activate the virtual environment you use for pretix development.
|
|
47
|
+
|
|
48
|
+
4. Execute ``python setup.py develop`` within this directory to register this application with pretix's plugin registry.
|
|
49
|
+
|
|
50
|
+
5. Execute ``make`` within this directory to compile translations.
|
|
51
|
+
|
|
52
|
+
6. Restart your local pretix server. You can now use the plugin from this repository for your events by enabling it in
|
|
53
|
+
the 'plugins' tab in the settings.
|
|
54
|
+
|
|
55
|
+
This plugin has CI set up to enforce a few code style rules. To check locally, you need these packages installed::
|
|
56
|
+
|
|
57
|
+
pip install flake8 isort black
|
|
58
|
+
|
|
59
|
+
To check your plugin for rule violations, run::
|
|
60
|
+
|
|
61
|
+
black --check .
|
|
62
|
+
isort -c .
|
|
63
|
+
flake8 .
|
|
64
|
+
|
|
65
|
+
You can auto-fix some of these issues by running::
|
|
66
|
+
|
|
67
|
+
isort .
|
|
68
|
+
black .
|
|
69
|
+
|
|
70
|
+
To automatically check for these issues before you commit, you can run ``.install-hooks``.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
License
|
|
74
|
+
-------
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Copyright 2026 pretix GmbH
|
|
78
|
+
|
|
79
|
+
Released under the terms of the proprietary pretix Enterprise license.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
.. _pretix: https://github.com/pretix/pretix
|
|
84
|
+
.. _pretix development setup: https://docs.pretix.eu/en/latest/development/setup.html
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Withdrawal
|
|
2
|
+
==========================
|
|
3
|
+
|
|
4
|
+
This is a plugin for `pretix`_.
|
|
5
|
+
|
|
6
|
+
To comply with EU legislation you need to add support the right of withdrawal for online purchases. This plugin adds
|
|
7
|
+
a visually distinct link in the footer of every page of the pretix-shop. This link leads to a form on organizer-level
|
|
8
|
+
to allow the customer to withdraw from an online purchase. When submitted, this form notifies the organizer (or any
|
|
9
|
+
team-member assigned through the pretix notification system) via email and creates a WithdrawalRequest accessible in
|
|
10
|
+
pretix-control.
|
|
11
|
+
|
|
12
|
+
Development setup
|
|
13
|
+
-----------------
|
|
14
|
+
|
|
15
|
+
1. Make sure that you have a working `pretix development setup`_.
|
|
16
|
+
|
|
17
|
+
2. Clone this repository.
|
|
18
|
+
|
|
19
|
+
3. Activate the virtual environment you use for pretix development.
|
|
20
|
+
|
|
21
|
+
4. Execute ``python setup.py develop`` within this directory to register this application with pretix's plugin registry.
|
|
22
|
+
|
|
23
|
+
5. Execute ``make`` within this directory to compile translations.
|
|
24
|
+
|
|
25
|
+
6. Restart your local pretix server. You can now use the plugin from this repository for your events by enabling it in
|
|
26
|
+
the 'plugins' tab in the settings.
|
|
27
|
+
|
|
28
|
+
This plugin has CI set up to enforce a few code style rules. To check locally, you need these packages installed::
|
|
29
|
+
|
|
30
|
+
pip install flake8 isort black
|
|
31
|
+
|
|
32
|
+
To check your plugin for rule violations, run::
|
|
33
|
+
|
|
34
|
+
black --check .
|
|
35
|
+
isort -c .
|
|
36
|
+
flake8 .
|
|
37
|
+
|
|
38
|
+
You can auto-fix some of these issues by running::
|
|
39
|
+
|
|
40
|
+
isort .
|
|
41
|
+
black .
|
|
42
|
+
|
|
43
|
+
To automatically check for these issues before you commit, you can run ``.install-hooks``.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
License
|
|
47
|
+
-------
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Copyright 2026 pretix GmbH
|
|
51
|
+
|
|
52
|
+
Released under the terms of the proprietary pretix Enterprise license.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
.. _pretix: https://github.com/pretix/pretix
|
|
57
|
+
.. _pretix development setup: https://docs.pretix.eu/en/latest/development/setup.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from django.utils.translation import gettext_lazy as _
|
|
2
|
+
|
|
3
|
+
from . import __version__
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from pretix.base.plugins import PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID, PluginConfig
|
|
7
|
+
except ImportError:
|
|
8
|
+
raise RuntimeError("Please use pretix 2026.3.0 or above to run this plugin!")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PluginApp(PluginConfig):
|
|
12
|
+
default = True
|
|
13
|
+
name = "pretix_withdrawal"
|
|
14
|
+
verbose_name = "Withdrawal"
|
|
15
|
+
|
|
16
|
+
class PretixPluginMeta:
|
|
17
|
+
name = _("Withdrawal")
|
|
18
|
+
author = "pretix team"
|
|
19
|
+
description = _(
|
|
20
|
+
"Add support to withdraw from pretix online purchases to comply with EU legislation."
|
|
21
|
+
)
|
|
22
|
+
visible = True
|
|
23
|
+
version = __version__
|
|
24
|
+
category = "FEATURE"
|
|
25
|
+
compatibility = "pretix>=2026.3.0.dev0"
|
|
26
|
+
level = PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID
|
|
27
|
+
settings_links = [
|
|
28
|
+
(
|
|
29
|
+
(_("Settings"), _("Withdrawal")),
|
|
30
|
+
"plugins:pretix_withdrawal:control.organizer.settings",
|
|
31
|
+
{},
|
|
32
|
+
),
|
|
33
|
+
(
|
|
34
|
+
(_("Settings"), _("Withdrawal")),
|
|
35
|
+
"plugins:pretix_withdrawal:control.event.settings",
|
|
36
|
+
{},
|
|
37
|
+
),
|
|
38
|
+
]
|
|
39
|
+
navigation_links = [
|
|
40
|
+
(
|
|
41
|
+
(_("Orders"), _("Withdrawals")),
|
|
42
|
+
"plugins:pretix_withdrawal:control.event.index",
|
|
43
|
+
{},
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
(_("Withdrawals"),),
|
|
47
|
+
"plugins:pretix_withdrawal:control.organizer.index",
|
|
48
|
+
{},
|
|
49
|
+
),
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
def ready(self):
|
|
53
|
+
from . import signals # NOQA
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from django.db.models import Q
|
|
3
|
+
from django.urls import reverse
|
|
4
|
+
from django.utils.translation import gettext_lazy as _
|
|
5
|
+
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
|
|
6
|
+
from pretix.base.forms import (
|
|
7
|
+
I18nMarkdownTextarea,
|
|
8
|
+
I18nModelForm,
|
|
9
|
+
PlaceholderValidator,
|
|
10
|
+
SettingsForm,
|
|
11
|
+
)
|
|
12
|
+
from pretix.base.models.organizer import TeamQuerySet
|
|
13
|
+
from pretix.base.validators import multimail_validate
|
|
14
|
+
from pretix.control.forms import ModelChoiceFieldWithNone
|
|
15
|
+
from pretix.control.forms.filter import FilterForm
|
|
16
|
+
from pretix.control.forms.widgets import Select2
|
|
17
|
+
from pretix.helpers.database import get_deterministic_ordering
|
|
18
|
+
|
|
19
|
+
from .models import Withdrawal
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CreateForm(I18nModelForm):
|
|
23
|
+
required_css_class = "required"
|
|
24
|
+
|
|
25
|
+
class Meta:
|
|
26
|
+
model = Withdrawal
|
|
27
|
+
fields = ("email", "name", "order_code", "message")
|
|
28
|
+
widgets = {
|
|
29
|
+
"email": forms.EmailInput(
|
|
30
|
+
attrs={
|
|
31
|
+
"autocomplete": "email",
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
"name": forms.TextInput(
|
|
35
|
+
attrs={
|
|
36
|
+
"autocomplete": "name",
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def __init__(self, *args, **kwargs):
|
|
42
|
+
organizer = kwargs.pop("organizer")
|
|
43
|
+
super().__init__(*args, **kwargs)
|
|
44
|
+
self.fields["message"].help_text = (
|
|
45
|
+
organizer.settings.withdrawal_form_message_help_text
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class OrganizerSettingsForm(SettingsForm):
|
|
50
|
+
withdrawal_contact_mail = forms.CharField(
|
|
51
|
+
label=_("Email address"),
|
|
52
|
+
required=True,
|
|
53
|
+
validators=[multimail_validate],
|
|
54
|
+
help_text=_(
|
|
55
|
+
"If we receive a withdrawal, we will notify you on this email address. You can specify multiple recipients separated by commas."
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
withdrawal_label = I18nFormField(
|
|
60
|
+
label=_("Label"),
|
|
61
|
+
required=True,
|
|
62
|
+
widget=I18nTextInput,
|
|
63
|
+
help_text=_(
|
|
64
|
+
"Used for the link in the footer and as the headline on the withdrawal form."
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
withdrawal_form_above_msg = I18nFormField(
|
|
68
|
+
label=_("Message shown above the form"),
|
|
69
|
+
required=True,
|
|
70
|
+
widget=I18nTextarea,
|
|
71
|
+
widget_kwargs={"attrs": {"rows": "3"}},
|
|
72
|
+
)
|
|
73
|
+
withdrawal_form_message_help_text = I18nFormField(
|
|
74
|
+
label=_("Help-text shown below the message input field"),
|
|
75
|
+
required=True,
|
|
76
|
+
widget=I18nTextarea,
|
|
77
|
+
widget_kwargs={"attrs": {"rows": "2"}},
|
|
78
|
+
)
|
|
79
|
+
withdrawal_submit_label = I18nFormField(
|
|
80
|
+
label=_("Label of the submit button"),
|
|
81
|
+
required=True,
|
|
82
|
+
widget=I18nTextInput,
|
|
83
|
+
)
|
|
84
|
+
withdrawal_received_success_msg = I18nFormField(
|
|
85
|
+
label=_("Message shown after successful submission"),
|
|
86
|
+
required=True,
|
|
87
|
+
widget=I18nTextarea,
|
|
88
|
+
widget_kwargs={"attrs": {"rows": "3"}},
|
|
89
|
+
)
|
|
90
|
+
withdrawal_received_mail_subject = I18nFormField(
|
|
91
|
+
label=_("Subject"),
|
|
92
|
+
max_length=250,
|
|
93
|
+
required=True,
|
|
94
|
+
widget=I18nTextInput,
|
|
95
|
+
)
|
|
96
|
+
withdrawal_received_mail_body = I18nFormField(
|
|
97
|
+
label=_("Body"),
|
|
98
|
+
required=True,
|
|
99
|
+
widget=I18nMarkdownTextarea,
|
|
100
|
+
widget_kwargs={"attrs": {"rows": "12"}},
|
|
101
|
+
)
|
|
102
|
+
withdrawal_warn_mail_subject = I18nFormField(
|
|
103
|
+
label=_("Subject"),
|
|
104
|
+
max_length=250,
|
|
105
|
+
required=True,
|
|
106
|
+
widget=I18nTextInput,
|
|
107
|
+
)
|
|
108
|
+
withdrawal_warn_mail_body = I18nFormField(
|
|
109
|
+
label=_("Body"),
|
|
110
|
+
required=True,
|
|
111
|
+
widget=I18nTextarea,
|
|
112
|
+
widget_kwargs={"attrs": {"rows": "12"}},
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
def __init__(self, *args, **kwargs):
|
|
116
|
+
super().__init__(*args, **kwargs)
|
|
117
|
+
self.event = kwargs.pop("obj")
|
|
118
|
+
|
|
119
|
+
phs = ["{email}", "{code}"]
|
|
120
|
+
phs_str = ", ".join(phs)
|
|
121
|
+
self.fields["withdrawal_received_success_msg"].validators = [
|
|
122
|
+
PlaceholderValidator(phs)
|
|
123
|
+
]
|
|
124
|
+
self.fields["withdrawal_received_success_msg"].help_text = _(
|
|
125
|
+
"Available placeholders: {list}"
|
|
126
|
+
).format(list=phs_str)
|
|
127
|
+
|
|
128
|
+
phs_empty = "{name}"
|
|
129
|
+
phs = ["{code}", "{name}", "{created}", "{organizer}"]
|
|
130
|
+
phs_str = ", ".join(phs)
|
|
131
|
+
self.fields["withdrawal_received_mail_subject"].validators = self.fields[
|
|
132
|
+
"withdrawal_received_mail_body"
|
|
133
|
+
].validators = [PlaceholderValidator(phs)]
|
|
134
|
+
self.fields["withdrawal_received_mail_subject"].help_text = self.fields[
|
|
135
|
+
"withdrawal_received_mail_body"
|
|
136
|
+
].help_text = _(
|
|
137
|
+
"Available placeholders: {list}. Note that {empty} can be empty."
|
|
138
|
+
).format(
|
|
139
|
+
list=phs_str, empty=phs_empty
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
phs = ["{code}", "{event}", "{organizer}"]
|
|
143
|
+
phs_str = ", ".join(phs)
|
|
144
|
+
self.fields["withdrawal_warn_mail_subject"].validators = self.fields[
|
|
145
|
+
"withdrawal_warn_mail_body"
|
|
146
|
+
].validators = [PlaceholderValidator(phs)]
|
|
147
|
+
self.fields["withdrawal_warn_mail_subject"].help_text = self.fields[
|
|
148
|
+
"withdrawal_warn_mail_body"
|
|
149
|
+
].help_text = _("Available placeholders: {list}").format(list=phs_str)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class WithdrawalFilterForm(FilterForm):
|
|
153
|
+
orders = {"code": "order_code", "created": "created"}
|
|
154
|
+
|
|
155
|
+
query = forms.CharField(
|
|
156
|
+
label=_("Search for…"),
|
|
157
|
+
widget=forms.TextInput(
|
|
158
|
+
attrs={
|
|
159
|
+
"placeholder": _("Search for…"),
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
required=False,
|
|
163
|
+
)
|
|
164
|
+
status = forms.ChoiceField(
|
|
165
|
+
label=_("Status"),
|
|
166
|
+
choices=(
|
|
167
|
+
("all", _("All withdrawals")),
|
|
168
|
+
("settled", _("settled")),
|
|
169
|
+
("", _("not settled")),
|
|
170
|
+
),
|
|
171
|
+
required=False,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
def __init__(self, *args, **kwargs):
|
|
175
|
+
self.request = kwargs.pop("request")
|
|
176
|
+
super().__init__(*args, **kwargs)
|
|
177
|
+
|
|
178
|
+
def filter_qs(self, qs):
|
|
179
|
+
fdata = self.cleaned_data
|
|
180
|
+
qs = super().filter_qs(qs)
|
|
181
|
+
if fdata.get("query"):
|
|
182
|
+
u = fdata.get("query")
|
|
183
|
+
qs = qs.filter(
|
|
184
|
+
Q(order_code__icontains=u)
|
|
185
|
+
| Q(order__code__icontains=u)
|
|
186
|
+
| Q(email__icontains=u)
|
|
187
|
+
| Q(name__icontains=u)
|
|
188
|
+
)
|
|
189
|
+
if fdata.get("status"):
|
|
190
|
+
s = fdata.get("status")
|
|
191
|
+
if s == "settled":
|
|
192
|
+
qs = qs.filter(settled__isnull=False)
|
|
193
|
+
else:
|
|
194
|
+
qs = qs.filter(settled__isnull=True)
|
|
195
|
+
|
|
196
|
+
if fdata.get("ordering"):
|
|
197
|
+
qs = qs.order_by(
|
|
198
|
+
*get_deterministic_ordering(Withdrawal, self.get_order_by())
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return qs
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class OrganizerWithdrawalFilterForm(WithdrawalFilterForm):
|
|
205
|
+
orders = {"code": "order_code", "created": "created", "event": "event"}
|
|
206
|
+
|
|
207
|
+
@staticmethod
|
|
208
|
+
def event_filter_queryset(user, session, organizer):
|
|
209
|
+
if user.has_active_staff_session(session.session_key):
|
|
210
|
+
return organizer.events.all()
|
|
211
|
+
return organizer.events.filter(
|
|
212
|
+
Q(
|
|
213
|
+
organizer_id__in=user.teams.filter(
|
|
214
|
+
TeamQuerySet.event_permission_q("event.orders:read"),
|
|
215
|
+
all_events=True,
|
|
216
|
+
).values_list("organizer", flat=True)
|
|
217
|
+
)
|
|
218
|
+
| Q(
|
|
219
|
+
id__in=user.teams.filter(
|
|
220
|
+
TeamQuerySet.event_permission_q("event.orders:read"),
|
|
221
|
+
).values_list("limit_events__id", flat=True)
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
def __init__(self, *args, **kwargs):
|
|
226
|
+
events_include_none = kwargs.pop("events_include_none", False)
|
|
227
|
+
super().__init__(*args, **kwargs)
|
|
228
|
+
|
|
229
|
+
self.fields["event"] = ModelChoiceFieldWithNone(
|
|
230
|
+
label=_("Event"),
|
|
231
|
+
queryset=OrganizerWithdrawalFilterForm.event_filter_queryset(
|
|
232
|
+
self.request.user, self.request.session, self.request.organizer
|
|
233
|
+
),
|
|
234
|
+
widget=Select2(
|
|
235
|
+
attrs={
|
|
236
|
+
"data-model-select2": "event",
|
|
237
|
+
"data-select2-url": reverse("control:events.typeahead")
|
|
238
|
+
+ "?organizer="
|
|
239
|
+
+ self.request.organizer.slug
|
|
240
|
+
+ "&permission=event.orders:read"
|
|
241
|
+
+ ("&include_none" if events_include_none else ""),
|
|
242
|
+
"data-placeholder": _("All events"),
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
empty_label=_("All events"),
|
|
246
|
+
none_label=_("No event"),
|
|
247
|
+
required=False,
|
|
248
|
+
)
|
|
249
|
+
self.fields["event"].widget.choices = self.fields["event"].choices
|
|
250
|
+
|
|
251
|
+
def filter_qs(self, qs):
|
|
252
|
+
fdata = self.cleaned_data
|
|
253
|
+
qs = super().filter_qs(qs)
|
|
254
|
+
|
|
255
|
+
if fdata.get("event") == "_none":
|
|
256
|
+
qs = qs.filter(event__isnull=True)
|
|
257
|
+
elif fdata.get("event"):
|
|
258
|
+
qs = qs.filter(event=fdata.get("event"))
|
|
259
|
+
|
|
260
|
+
return qs
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class CommentForm(I18nModelForm):
|
|
264
|
+
class Meta:
|
|
265
|
+
model = Withdrawal
|
|
266
|
+
fields = ["internal_notes"]
|
|
267
|
+
widgets = {
|
|
268
|
+
"internal_notes": forms.Textarea(
|
|
269
|
+
attrs={
|
|
270
|
+
"rows": 6,
|
|
271
|
+
"class": "helper-width-100",
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
}
|