Skip to content

Commit 0e96f43

Browse files
fix(chore): global settings redesign (#1030)
* enhance global admin settings design * fix i18n issue * fix plugins discovery * update pyproject.toml * catch concerete, specific error class * delete redundant getitem * adjust with new stripe and paypal migrations commit * adjust pyproject.toml file --------- Co-authored-by: Mario Behling <[email protected]>
1 parent d4c788b commit 0e96f43

File tree

5 files changed

+145
-12
lines changed

5 files changed

+145
-12
lines changed

app/eventyay/config/settings.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
"""
1212

1313
import configparser
14+
import importlib
15+
import importlib_metadata
1416
import importlib.util
1517
import os
1618
import sys
19+
from collections import OrderedDict
1720
from importlib.metadata import entry_points
1821
from pathlib import Path
1922
from urllib.parse import urlparse
@@ -208,10 +211,52 @@ def instance_name(request):
208211
)
209212
)
210213

211-
PLUGINS = []
212-
for entry_point in entry_points(group='pretalx.plugin'):
213-
PLUGINS.append(entry_point.module)
214-
# INSTALLED_APPS += tuple(entry_point.module)
214+
raw_exclude = config.get('eventyay', 'plugins_exclude', fallback='')
215+
PLUGINS_EXCLUDE = [m.strip() for m in raw_exclude.split(',') if m.strip()]
216+
217+
eps = importlib_metadata.entry_points()
218+
219+
# Pretix plugins
220+
pretix_plugins = [
221+
ep.module
222+
for ep in eps.select(group='pretix.plugin')
223+
if ep.module not in PLUGINS_EXCLUDE
224+
]
225+
226+
# Pretalx plugins
227+
pretalx_plugins = [
228+
ep.module
229+
for ep in eps.select(group='pretalx.plugin')
230+
if ep.module not in PLUGINS_EXCLUDE
231+
]
232+
233+
ALL_PLUGINS = sorted(pretix_plugins + pretalx_plugins)
234+
235+
236+
# ---------------------------
237+
# TODO: Adjust import paths for pretix_venueless, pretix_downstream, pretalx_pages
238+
# Once ready, remove below 2 lines of code and just add Pretix plugins to INSTALLED_APPS like:
239+
# INSTALLED_APPS += tuple(pretix_plugins)
240+
SAFE_PRETIX_PLUGINS = [
241+
m for m in pretix_plugins if m not in {'pretix_venueless', 'pretix_pages'}
242+
]
243+
INSTALLED_APPS += tuple(SAFE_PRETIX_PLUGINS)
244+
245+
# ---------------------------
246+
# TODO: Adjust import paths for pretalx_venueless, pretalx_downstream, pretalx_pages
247+
# Once ready, uncomment the following line to add Pretalx plugins to INSTALLED_APPS
248+
# INSTALLED_APPS += tuple(pretalx_plugins)
249+
250+
# Optional: Dynamic Import
251+
LOADED_PLUGINS = OrderedDict()
252+
for module_name in ALL_PLUGINS:
253+
try:
254+
module = importlib.import_module(module_name)
255+
LOADED_PLUGINS[module_name] = module
256+
except ModuleNotFoundError as e:
257+
print(f"Plugin not found: {module_name} ({e})")
258+
except ImportError as e:
259+
print(f"Failed to import plugin {module_name}: {e}")
215260

216261
_LIBRARY_MIDDLEWARES = (
217262
'corsheaders.middleware.CorsMiddleware',

app/eventyay/control/forms/global_settings.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,48 @@ def __init__(self, *args, **kwargs):
281281
]
282282
)
283283

284+
self.field_groups = [
285+
('basics', _('Basics'), [
286+
'footer_text', 'footer_link', 'banner_message', 'banner_message_detail',
287+
]),
288+
('localization', _('Localization'), [
289+
'region',
290+
]),
291+
('email', _('Email'), [
292+
'mail_from', 'email_vendor', 'send_grid_api_key',
293+
'smtp_host', 'smtp_port', 'smtp_username', 'smtp_password',
294+
'smtp_use_tls', 'smtp_use_ssl',
295+
]),
296+
('payment_gateways', _('Payment Gateways'), [
297+
# PayPal
298+
'payment_paypal_connect_client_id',
299+
'payment_paypal_connect_secret_key',
300+
'payment_paypal_connect_endpoint',
301+
302+
# Stripe
303+
'payment_stripe_connect_client_id',
304+
'payment_stripe_connect_secret_key',
305+
'payment_stripe_connect_publishable_key',
306+
'payment_stripe_connect_test_secret_key',
307+
'payment_stripe_connect_test_publishable_key',
308+
'payment_stripe_connect_app_fee_percent',
309+
'payment_stripe_connect_app_fee_max',
310+
'payment_stripe_connect_app_fee_min',
311+
312+
'payment_stripe_secret_key',
313+
'payment_stripe_publishable_key',
314+
'payment_stripe_test_secret_key',
315+
'payment_stripe_test_publishable_key',
316+
'stripe_webhook_secret_key',
317+
]),
318+
('ticket_fee', _('Ticket fee'), [
319+
'ticket_fee_percentage',
320+
]),
321+
('maps', _('Maps'), [
322+
'opencagedata_apikey', 'mapquest_apikey', 'leaflet_tiles', 'leaflet_tiles_attribution',
323+
]),
324+
]
325+
284326

285327
class UpdateSettingsForm(SettingsForm):
286328
update_check_perform = forms.BooleanField(

app/eventyay/control/templates/pretixcontrol/global_settings.html

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "pretixcontrol/global_settings_base.html" %}
22
{% load i18n %}
33
{% load bootstrap3 %}
4+
{% load getitem %}
45
{% load static %}
56

67
{% block custom_header %}
@@ -11,10 +12,55 @@
1112
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
1213
{% csrf_token %}
1314
{% bootstrap_form_errors form %}
14-
{% bootstrap_form form layout='control' %}
15+
<ul class="nav nav-tabs" role="tablist">
16+
{% for group_key, group_label, field_names in form.field_groups %}
17+
<li role="presentation" class="{% if forloop.first %}active{% endif %}">
18+
<a href="#tab{{ forloop.counter }}" aria-controls="tab{{ forloop.counter }}" role="tab" data-toggle="tab">
19+
{{ group_label }}
20+
</a>
21+
</li>
22+
{% endfor %}
23+
</ul>
24+
25+
<div class="tab-content">
26+
{% for group_key, group_label, field_names in form.field_groups %}
27+
<div role="tabpanel" class="tab-pane {% if forloop.first %}active{% endif %}" id="tab{{ forloop.counter }}">
28+
{% if group_key == "payment_gateways" %}
29+
<fieldset>
30+
<legend>{% translate "Stripe" %}</legend>
31+
{% for field_name in field_names %}
32+
{% if "payment_stripe" in field_name or "stripe_webhook" in field_name %}
33+
{% with form|getitem:field_name as field %}
34+
{% bootstrap_field field layout='control' %}
35+
{% endwith %}
36+
{% endif %}
37+
{% endfor %}
38+
</fieldset>
39+
40+
<fieldset>
41+
<legend>{% translate "PayPal" %}</legend>
42+
{% for field_name in field_names %}
43+
{% if "payment_paypal" in field_name %}
44+
{% with form|getitem:field_name as field %}
45+
{% bootstrap_field field layout='control' %}
46+
{% endwith %}
47+
{% endif %}
48+
{% endfor %}
49+
</fieldset>
50+
{% else %}
51+
{% for field_name in field_names %}
52+
{% with form|getitem:field_name as field %}
53+
{% bootstrap_field field layout='control' %}
54+
{% endwith %}
55+
{% endfor %}
56+
{% endif %}
57+
</div>
58+
{% endfor %}
59+
</div>
60+
1561
<div class="form-group submit-group">
1662
<button type="submit" class="btn btn-primary btn-save">
17-
{% trans "Save" %}
63+
{% translate "Save" %}
1864
</button>
1965
</div>
2066
</form>

app/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ dependencies = [
9797
"elementpath>=4.7.0",
9898
"emoji>=2.14.1",
9999
"et-xmlfile>=2.0.0",
100-
"eventyay-paypal @ git+https://github.com/fossasia/eventyay-tickets-paypal.git@4728e6733d971edb4db6df4ebfe12caefd371d55",
101-
"eventyay-stripe @ git+https://github.com/fossasia/eventyay-tickets-stripe.git@1d461de9ac7ef743cb2e6ddbace3434ba5ec6fcc",
100+
"eventyay-paypal @ git+https://github.com/fossasia/eventyay-tickets-paypal.git@1765e5b1aa31da570e16a09a076e96ab623436d1",
101+
"eventyay-stripe @ git+https://github.com/fossasia/eventyay-tickets-stripe.git@a76e42f537666a19ac57072ffd32cd44353b8032",
102102
"execnet>=2.1.1",
103103
"faker>=37.3.0",
104104
"fakeredis>=2.26.2",

app/uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)