diff --git a/src/pretix/api/auth/devicesecurity.py b/src/pretix/api/auth/devicesecurity.py index 18a99336bd..806f7aa621 100644 --- a/src/pretix/api/auth/devicesecurity.py +++ b/src/pretix/api/auth/devicesecurity.py @@ -20,7 +20,6 @@ # . # import logging -from collections import OrderedDict from django.dispatch import receiver from django.utils.translation import gettext_lazy as _ @@ -52,10 +51,18 @@ class BaseSecurityProfile: """ raise NotImplementedError() + @property + def priority(self) -> int: + """ + Priority for ordering, higher will come first. + """ + return 100 + class FullAccessSecurityProfile(BaseSecurityProfile): identifier = 'full' verbose_name = _('Full device access (reading and changing orders and gift cards, reading of products and settings)') + priority = 1000 def is_allowed(self, request): return True @@ -190,13 +197,15 @@ def get_all_security_profiles(): if _ALL_PROFILES: return _ALL_PROFILES - types = OrderedDict() + types = [] for recv, ret in register_device_security_profile.send(None): if isinstance(ret, (list, tuple)): for r in ret: - types[r.identifier] = r + types.append(r) else: - types[ret.identifier] = ret + types.append(ret) + types.sort(key=lambda el: el.priority, reverse=True) + types = {r.identifier: r for r in types} _ALL_PROFILES = types return types