{% extends "pretixcontrol/event/settings_base.html" %}
{% load i18n %}
{% load static %}
{% load bootstrap3 %}
{% block inside %}
    <h1>{% trans "Available plugins" %}</h1>
    <p>
        {% blocktrans trimmed %}
            On this page, you can choose plugins you want to enable for your event. Plugins might bring additional
            software functionality, connect your event to third-party services, or apply other forms of customizations.
        {% endblocktrans %}
    </p>
    <form action="" method="post" class="form-horizontal form-plugins">
        {% csrf_token %}
        {% if "success" in request.GET %}
            <div class="alert alert-success">
                {% trans "Your changes have been saved." %}
            </div>
        {% endif %}
        <div class="tabbed-form">
            {% for cat, catlabel, plist, has_pictures in plugins %}
                <fieldset>
                    <legend>{{ catlabel }}</legend>
                    <div class="plugin-list">
                        {% for plugin in plist %}
                            <div class="plugin-container {% if plugin.featured %}featured-plugin{% endif %}">
                            {% if plugin.featured %}
                               <div class="panel panel-default">
                                    <div class="panel-body">
                            {% endif %}
                                        <div class="plugin-text">
                                        {% if plugin.featured or plugin.experimental %}
                                            <p class="text-muted">
                                            {% if plugin.featured %}
                                                <span class="fa fa-thumbs-up" aria-hidden="true"></span>
                                                {% trans "Top recommendation" %}
                                            {% endif %}
                                            {% if plugin.experimental %}
                                                <span class="fa fa-flask" aria-hidden="true"></span>
                                                {% trans "Experimental feature" %}
                                            {% endif %}
                                            </p>
                                        {% endif %}
                                        {% if plugin.picture %}
                                            <p><img src="{% static plugin.picture %}" class="plugin-picture"></p>
                                        {% endif %}
                                            <h4>
                                                {{ plugin.name }}
                                                {% if show_meta %}
                                                    <span class="text-muted text-sm">{{ plugin.version }}</span>
                                                {% endif %}
                                                {% if plugin.module in plugins_active %}
                                                    <span class="label label-success">
                                                        <span class="fa fa-check" aria-hidden="true"></span>
                                                        {% trans "Active" %}
                                                    </span>
                                                {% endif %}
                                            </h4>
                                            {% include "pretixcontrol/event/fragment_plugin_description.html" with plugin=plugin %}
                                        </div>
                                        {% if plugin.app.compatibility_errors %}
                                            <div class="plugin-action">
                                                <span class="text-muted">{% trans "Incompatible" %}</span>
                                            </div>
                                        {% elif plugin.restricted and plugin.module not in request.event.settings.allowed_restricted_plugins %}
                                            <div class="plugin-action">
                                                <span class="text-muted">{% trans "Not available" %}</span>
                                            </div>
                                        {% elif plugin.module in plugins_active %}
                                            <div class="plugin-action flip">
                                                <button class="btn btn-default{% if plugin.featured %} btn-lg{% endif %}" name="plugin:{{ plugin.module }}"
                                                        value="disable">{% trans "Disable" %}</button>
                                            </div>
                                        {% else %}
                                            <div class="plugin-action flip">
                                                <button class="btn btn-primary{% if plugin.featured %} btn-lg{% endif %}" name="plugin:{{ plugin.module }}"
                                                        value="enable">{% trans "Enable" %}</button>
                                            </div>
                                        {% endif %}
                            {% if plugin.featured %}
                                    </div>
                                </div>
                            {% endif %}
                            </div>
                        {% endfor %}
                    </div>
                </fieldset>
            {% endfor %}
        </div>
    </form>
{% endblock %}
