Re-introduce plugin categories

This commit is contained in:
Raphael Michel
2020-02-08 12:38:43 +01:00
parent 9984fe97ba
commit bb5c7c5ad7
14 changed files with 111 additions and 58 deletions

View File

@@ -10,62 +10,75 @@
{% trans "Your changes have been saved." %}
</div>
{% endif %}
<div class="table-responsive">
<table class="table">
{% for plugin in plugins %}
<tr class="{% if plugin.app.compatibility_errors %}warning{% elif plugin.module in plugins_active %}success{% else %}default{% endif %}">
<td>
<strong>{{ plugin.name }}</strong>
{% if plugin.author %}
<p class="meta text-muted">{% blocktrans trimmed with v=plugin.version a=plugin.author %}
Version {{ v }} by <em>{{ a }}</em>
{% endblocktrans %}</p>
{% else %}
<p class="meta text-muted">{% blocktrans trimmed with v=plugin.version a=plugin.author %}
Version {{ v }}
{% endblocktrans %}</p>
{% endif %}
<p>{{ plugin.description }}</p>
{% if plugin.restricted and not request.user.is_staff %}
<span class="text-muted">
{% trans "This plugin needs to be enabled by a system administrator for your event." %}
</span>
{% endif %}
{% if plugin.app.compatibility_errors %}
<div class="alert alert-warning">
{% trans "This plugin cannot be enabled for the following reasons:" %}
<ul>
{% for e in plugin.app.compatibility_errors %}
<li>{{ e }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if plugin.app.compatibility_warnings %}
<div class="alert alert-warning">
{% trans "This plugin reports the following problems:" %}
<ul>
{% for e in plugin.app.compatibility_warnings %}
<li>{{ e }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</td>
<td class="text-right flip">
{% if plugin.app.compatibility_errors %}
<button class="btn disabled btn-block btn-default" disabled="disabled">{% trans "Incompatible" %}</button>
{% elif plugin.restricted and not staff_session %}
<button class="btn disabled btn-block btn-default" disabled="disabled">{% trans "Not available" %}</button>
{% elif plugin.module in plugins_active %}
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}" value="disable">{% trans "Disable" %}</button>
{% else %}
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}" value="enable">{% trans "Enable" %}</button>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<div class="tabbed-form">
{% for cat, catlabel, plist in plugins %}
<fieldset>
<legend>{{ catlabel }}</legend>
<div class="table-responsive">
<table class="table">
{% for plugin in plist %}
<tr class="{% if plugin.app.compatibility_errors %}warning{% elif plugin.module in plugins_active %}success{% else %}default{% endif %}">
<td>
<strong>{{ plugin.name }}</strong>
{% if plugin.author %}
<p class="meta text-muted">
{% blocktrans trimmed with v=plugin.version a=plugin.author %}
Version {{ v }} by <em>{{ a }}</em>
{% endblocktrans %}</p>
{% else %}
<p class="meta text-muted">
{% blocktrans trimmed with v=plugin.version a=plugin.author %}
Version {{ v }}
{% endblocktrans %}</p>
{% endif %}
<p>{{ plugin.description }}</p>
{% if plugin.restricted and not request.user.is_staff %}
<span class="text-muted">
{% trans "This plugin needs to be enabled by a system administrator for your event." %}
</span>
{% endif %}
{% if plugin.app.compatibility_errors %}
<div class="alert alert-warning">
{% trans "This plugin cannot be enabled for the following reasons:" %}
<ul>
{% for e in plugin.app.compatibility_errors %}
<li>{{ e }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if plugin.app.compatibility_warnings %}
<div class="alert alert-warning">
{% trans "This plugin reports the following problems:" %}
<ul>
{% for e in plugin.app.compatibility_warnings %}
<li>{{ e }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</td>
<td class="text-right flip">
{% if plugin.app.compatibility_errors %}
<button class="btn disabled btn-block btn-default"
disabled="disabled">{% trans "Incompatible" %}</button>
{% elif plugin.restricted and not staff_session %}
<button class="btn disabled btn-block btn-default"
disabled="disabled">{% trans "Not available" %}</button>
{% elif plugin.module in plugins_active %}
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}"
value="disable">{% trans "Disable" %}</button>
{% else %}
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}"
value="enable">{% trans "Enable" %}</button>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</fieldset>
{% endfor %}
</div>
</form>
{% endblock %}

View File

@@ -2,6 +2,7 @@ import json
import re
from collections import OrderedDict
from decimal import Decimal
from itertools import groupby
from urllib.parse import urlsplit
from django.conf import settings
@@ -213,8 +214,32 @@ class EventPlugins(EventSettingsViewMixin, EventPermissionRequiredMixin, Templat
from pretix.base.plugins import get_all_plugins
context = super().get_context_data(*args, **kwargs)
context['plugins'] = [p for p in get_all_plugins(self.object) if not p.name.startswith('.')
and getattr(p, 'visible', True)]
plugins = [p for p in get_all_plugins(self.object) if not p.name.startswith('.')
and getattr(p, 'visible', True)]
order = [
'FEATURE',
'PAYMENT',
'INTEGRATION',
'CUSTOMIZATION',
'FORMATS',
'API',
]
labels = {
'FEATURE': _('Features'),
'PAYMENT': _('Payment providers'),
'INTEGRATION': _('Integrations'),
'CUSTOMIZATION': _('Customizations'),
'FORMATS': _('Output and export formats'),
'API': _('API features'),
}
context['plugins'] = sorted([
(c, labels.get(c, c), list(plist))
for c, plist
in groupby(
sorted(plugins, key=lambda p: str(getattr(p, 'category', _('Other')))),
lambda p: str(getattr(p, 'category', _('Other')))
)
], key=lambda c: (order.index(c[0]), c[1]) if c[0] in order else (999, str(c[1])))
context['plugins_active'] = self.object.get_plugins()
return context

View File

@@ -12,6 +12,7 @@ class BadgesApp(AppConfig):
name = _("Badges")
author = _("the pretix team")
version = version
category = "FEATURE"
description = _("This plugin allows you to generate badges or name tags for your attendees.")
def ready(self):

View File

@@ -12,6 +12,7 @@ class BankTransferApp(AppConfig):
class PretixPluginMeta:
name = _("Bank transfer")
author = _("the pretix team")
category = 'PAYMENT'
version = version
description = _("This plugin allows you to receive payments " +
"via bank transfer ")

View File

@@ -12,6 +12,7 @@ class ManualPaymentApp(AppConfig):
name = _("Manual payment")
author = _("the pretix team")
version = version
category = 'PAYMENT'
description = _("This plugin adds a customizable payment method for manual processing.")

View File

@@ -13,6 +13,7 @@ class PaypalApp(AppConfig):
name = _("PayPal")
author = _("the pretix team")
version = version
category = 'PAYMENT'
description = _("This plugin allows you to receive payments via PayPal")
def ready(self):

View File

@@ -13,6 +13,7 @@ class PretixdroidApp(AppConfig):
author = _("the pretix team")
version = version
visible = True
category = 'INTEGRATION'
description = _("This plugin allows you to use the pretixdroid and pretixdesk apps for your event.")
def ready(self):

View File

@@ -13,6 +13,7 @@ class ReportsApp(AppConfig):
name = _("Report exporter")
author = _("the pretix team")
version = version
category = 'FORMATS'
description = _("This plugin allows you to generate printable reports about your sales.")
def ready(self):

View File

@@ -12,6 +12,7 @@ class ReturnURLApp(AppConfig):
name = _("Redirection from order page")
author = _("the pretix team")
version = version
category = 'API'
description = _("This plugin allows to link to payments and redirect back afterwards. This is useful in "
"combination with our API.")

View File

@@ -11,6 +11,7 @@ class SendMailApp(AppConfig):
class PretixPluginMeta:
name = _("Send out emails")
author = _("the pretix team")
category = 'FEATURE'
version = version
description = _("This plugin allows you to send out emails " +
"to all your customers.")

View File

@@ -12,6 +12,7 @@ class StatisticsApp(AppConfig):
name = _("Statistics")
author = _("the pretix team")
version = version
category = 'FEATURE'
description = _("This plugin shows you various statistics.")
def ready(self):

View File

@@ -13,6 +13,7 @@ class StripeApp(AppConfig):
name = _("Stripe")
author = _("the pretix team")
version = version
category = 'PAYMENT'
description = _("This plugin allows you to receive credit card payments " +
"via Stripe")

View File

@@ -13,6 +13,7 @@ class TicketOutputPdfApp(AppConfig):
name = _("PDF ticket output")
author = _("the pretix team")
version = version
category = 'FORMATS'
description = _("This plugin allows you to print out tickets as PDF files")
def ready(self):