diff --git a/src/pretix/control/forms/organizer.py b/src/pretix/control/forms/organizer.py index 6834ec1414..a1be50e814 100644 --- a/src/pretix/control/forms/organizer.py +++ b/src/pretix/control/forms/organizer.py @@ -6,7 +6,7 @@ from django.utils.translation import ugettext_lazy as _ from i18nfield.forms import I18nFormField, I18nTextarea from pretix.base.forms import I18nModelForm, SettingsForm -from pretix.base.models import Organizer, Team +from pretix.base.models import Device, Organizer, Team from pretix.control.forms import ExtFileField, MultipleLanguagesWidget from pretix.multidomain.models import KnownDomain from pretix.presale.style import get_fonts @@ -107,7 +107,7 @@ class TeamForm(forms.ModelForm): data = super().clean() if self.instance.pk and not data['can_change_teams']: if not self.instance.organizer.teams.exclude(pk=self.instance.pk).filter( - can_change_teams=True, members__isnull=False + can_change_teams=True, members__isnull=False ).exists(): raise ValidationError(_('The changes could not be saved because there would be no remaining team with ' 'the permission to change teams and permissions.')) @@ -115,6 +115,23 @@ class TeamForm(forms.ModelForm): return data +class DeviceForm(forms.ModelForm): + + def __init__(self, *args, **kwargs): + organizer = kwargs.pop('organizer') + super().__init__(*args, **kwargs) + self.fields['limit_events'].queryset = organizer.events.all() + + class Meta: + model = Device + fields = ['name', 'all_events', 'limit_events'] + widgets = { + 'limit_events': forms.CheckboxSelectMultiple(attrs={ + 'data-inverse-dependency': '#id_all_events' + }), + } + + class OrganizerSettingsForm(SettingsForm): organizer_info_text = I18nFormField( diff --git a/src/pretix/control/templates/pretixcontrol/organizers/base.html b/src/pretix/control/templates/pretixcontrol/organizers/base.html index ab88911115..7a67d8f70b 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/base.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/base.html @@ -33,6 +33,13 @@ {% endif %} + {% if 'can_change_organizer_settings' in request.orgapermset %} +
+ {% blocktrans trimmed %} + You haven't connected any hardware devices yet. + {% endblocktrans %} +
+ + {% trans "Connect a device" %} ++ {% trans "Connect a device" %} +
+| {% trans "Device ID" %} | +{% trans "Name" %} | +{% trans "Hardware model" %} | +{% trans "Software" %} | +{% trans "Setup date" %} | +{% trans "Events" %} | ++ |
|---|---|---|---|---|---|---|
| + {{ d.device_id }} + | ++ {{ d.name }} + | ++ {{ d.hardware_brand|default_if_none:"" }} {{ d.hardware_model|default_if_none:"" }} + | ++ {{ d.software_brand|default_if_none:"" }} {{ d.software_version|default_if_none:"" }} + | ++ {% if d.initialized %} + {{ d.initialized|date:"SHORT_DATETIME_FORMAT" }} + {% else %} + {% trans "Not yet initialized" %} + {% endif %} + | +
+ {% if d.all_events %}
+ {% trans "All" %}
+ {% else %}
+
|
+ + {% if not d.initialized %} + + {% trans "Connect" %} + {% endif %} + + | +