Skip to content

Commit d8ab718

Browse files
committed
enhance global admin settings design
1 parent e314f5f commit d8ab718

File tree

4 files changed

+152
-45
lines changed

4 files changed

+152
-45
lines changed

app/eventyay/config/settings.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import configparser
14+
import importlib_metadata
1415
import importlib.util
1516
import os
1617
import sys
@@ -188,7 +189,24 @@ def instance_name(request):
188189
PLUGINS = []
189190
for entry_point in entry_points(group='pretalx.plugin'):
190191
PLUGINS.append(entry_point.module)
191-
# INSTALLED_APPS += tuple(entry_point.module)
192+
# TODO:
193+
# pretalx_venueless , pretalx_downstream and pretalx_pages module's import statement must be changed w.r.t. enext.
194+
# Then you can uncomment the below code safely.
195+
# INSTALLED_APPS += (entry_point.module, )
196+
197+
entry_points = importlib_metadata.entry_points()
198+
199+
PRETIX_PLUGINS_EXCLUDE = config.get('eventyay', 'plugins_exclude', fallback='').split(',')
200+
201+
for entry_point in entry_points.select(group='pretix.plugin'):
202+
if entry_point.module not in PRETIX_PLUGINS_EXCLUDE:
203+
PLUGINS.append(entry_point.module)
204+
# TODO:
205+
# pretix_venueless and pretix_pages module's import statement must be changed w.r.t. enext.
206+
# Then you can remove the below check safely.
207+
if entry_point.module == 'pretix_venueless' or entry_point.module == 'pretix_pages':
208+
continue
209+
INSTALLED_APPS += (entry_point.module,)
192210

193211
_LIBRARY_MIDDLEWARES = (
194212
'corsheaders.middleware.CorsMiddleware',

app/eventyay/control/forms/global_settings.py

Lines changed: 80 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ def __init__(self, *args, **kwargs):
232232
required=False,
233233
),
234234
),
235+
(
236+
'payment_stripe_connect_publishable_key',
237+
forms.CharField(
238+
label=_('Stripe Connect: Publishable key'),
239+
required=False,
240+
validators=(StripeKeyValidator('pk_live_'),),
241+
),
242+
),
243+
(
244+
'payment_stripe_connect_test_secret_key',
245+
SecretKeySettingsField(
246+
label=_('Stripe Connect: Secret key (test)'),
247+
required=False,
248+
validators=(StripeKeyValidator(['sk_test_', 'rk_test_']),),
249+
),
250+
),
251+
(
252+
'payment_stripe_connect_test_publishable_key',
253+
forms.CharField(
254+
label=_('Stripe Connect: Publishable key (test)'),
255+
required=False,
256+
validators=(StripeKeyValidator('pk_test_'),),
257+
),
258+
),
235259
(
236260
'ticket_fee_percentage',
237261
forms.DecimalField(
@@ -242,52 +266,66 @@ def __init__(self, *args, **kwargs):
242266
help_text=_('A percentage fee will be charged for each ticket sold.'),
243267
validators=[MinValueValidator(0)],
244268
),
245-
(
246-
'payment_stripe_connect_publishable_key',
247-
forms.CharField(
248-
label=_('Stripe Connect: Publishable key'),
249-
required=False,
250-
validators=(StripeKeyValidator('pk_live_'),),
251-
),
252-
),
253-
(
254-
'payment_stripe_connect_test_secret_key',
255-
SecretKeySettingsField(
256-
label=_('Stripe Connect: Secret key (test)'),
257-
required=False,
258-
validators=(StripeKeyValidator(['sk_test_', 'rk_test_']),),
259-
),
260-
),
261-
(
262-
'payment_stripe_connect_test_publishable_key',
263-
forms.CharField(
264-
label=_('Stripe Connect: Publishable key (test)'),
265-
required=False,
266-
validators=(StripeKeyValidator('pk_test_'),),
267-
),
268-
),
269-
(
270-
'stripe_webhook_secret_key',
271-
SecretKeySettingsField(
272-
label=_('Stripe Webhook: Secret key'),
273-
required=False,
274-
),
275-
),
276-
(
277-
'ticket_fee_percentage',
278-
forms.DecimalField(
279-
label=_('Ticket fee percentage'),
280-
required=False,
281-
decimal_places=2,
282-
max_digits=10,
283-
help_text=_('A percentage fee will be charged for each ticket sold.'),
284-
validators=[MinValueValidator(0)],
285-
),
286-
),
287269
),
288270
]
289271
)
290272

273+
self.field_groups = [
274+
(_('Basics'), [
275+
'footer_text',
276+
'footer_link',
277+
'banner_message',
278+
'banner_message_detail',
279+
]),
280+
(_('Localization'), [
281+
'region',
282+
]),
283+
(_('Email'), [
284+
'mail_from',
285+
'email_vendor',
286+
'send_grid_api_key',
287+
'smtp_host',
288+
'smtp_port',
289+
'smtp_username',
290+
'smtp_password',
291+
'smtp_use_tls',
292+
'smtp_use_ssl',
293+
]),
294+
(_('Payment Gateways'), [
295+
# PayPal (from plugin)
296+
'payment_paypal_connect_client_id',
297+
'payment_paypal_connect_secret_key',
298+
'payment_paypal_connect_endpoint',
299+
300+
# Stripe
301+
'payment_stripe_connect_client_id',
302+
'payment_stripe_connect_secret_key',
303+
'payment_stripe_connect_publishable_key',
304+
'payment_stripe_connect_test_secret_key',
305+
'payment_stripe_connect_test_publishable_key',
306+
'payment_stripe_connect_app_fee_percent',
307+
'payment_stripe_connect_app_fee_max',
308+
'payment_stripe_connect_app_fee_min',
309+
310+
'payment_stripe_secret_key',
311+
'payment_stripe_publishable_key',
312+
'payment_stripe_test_secret_key',
313+
'payment_stripe_test_publishable_key',
314+
# new stripe webhook
315+
'stripe_webhook_secret_key',
316+
]),
317+
(_('Ticket fee'), [
318+
'ticket_fee_percentage',
319+
]),
320+
(_('Maps'), [
321+
'opencagedata_apikey',
322+
'mapquest_apikey',
323+
'leaflet_tiles',
324+
'leaflet_tiles_attribution',
325+
]),
326+
]
327+
328+
291329

292330
class UpdateSettingsForm(SettingsForm):
293331
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_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_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_label == "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/eventyay/control/templatetags/hierarkey_form.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,8 @@ def propagated(parser, token):
7474
nodelist = parser.parse(('endpropagated',))
7575
parser.delete_first_token()
7676
return PropagatedNode(nodelist, event, [f[1:-1] for f in args], url)
77+
78+
79+
@register.filter
80+
def get_item(dictionary, key):
81+
return dictionary.get(key)

0 commit comments

Comments
 (0)