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

@@ -46,6 +46,9 @@ name string The human-readable name of your plugin
author string Your name author string Your name
version string A human-readable version code of your plugin version string A human-readable version code of your plugin
description string A more verbose description of what your plugin does. description string A more verbose description of what your plugin does.
category string Category of a plugin. Either one of ``"FEATURE"``, ``"PAYMENT"``,
``"INTEGRATION"``, ``"CUSTOMIZATION"``, ``"FORMATS"``, or ``"API"``,
or any other string.
visible boolean (optional) ``True`` by default, can hide a plugin so it cannot be normally activated. visible boolean (optional) ``True`` by default, can hide a plugin so it cannot be normally activated.
restricted boolean (optional) ``False`` by default, restricts a plugin such that it can only be enabled restricted boolean (optional) ``False`` by default, restricts a plugin such that it can only be enabled
for an event by system administrators / superusers. for an event by system administrators / superusers.
@@ -69,6 +72,7 @@ A working example would be::
name = _("PayPal") name = _("PayPal")
author = _("the pretix team") author = _("the pretix team")
version = '1.0.0' version = '1.0.0'
category = 'PAYMENT
visible = True visible = True
restricted = False restricted = False
description = _("This plugin allows you to receive payments via PayPal") description = _("This plugin allows you to receive payments via PayPal")

View File

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

View File

@@ -2,6 +2,7 @@ import json
import re import re
from collections import OrderedDict from collections import OrderedDict
from decimal import Decimal from decimal import Decimal
from itertools import groupby
from urllib.parse import urlsplit from urllib.parse import urlsplit
from django.conf import settings from django.conf import settings
@@ -213,8 +214,32 @@ class EventPlugins(EventSettingsViewMixin, EventPermissionRequiredMixin, Templat
from pretix.base.plugins import get_all_plugins from pretix.base.plugins import get_all_plugins
context = super().get_context_data(*args, **kwargs) context = super().get_context_data(*args, **kwargs)
context['plugins'] = [p for p in get_all_plugins(self.object) if not p.name.startswith('.') plugins = [p for p in get_all_plugins(self.object) if not p.name.startswith('.')
and getattr(p, 'visible', True)] 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() context['plugins_active'] = self.object.get_plugins()
return context return context

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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