From 256ac0a7f2a0a1d7ab6a510c85552cbfc1fc6a7a Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <yohann.danello@gmail.com>
Date: Fri, 24 Apr 2020 14:04:56 +0200
Subject: [PATCH] Order registration by promotion rather than by roles

---
 management/commands/export_wei_registrations.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/management/commands/export_wei_registrations.py b/management/commands/export_wei_registrations.py
index fc23c71..f76852c 100644
--- a/management/commands/export_wei_registrations.py
+++ b/management/commands/export_wei_registrations.py
@@ -55,7 +55,7 @@ class Command(BaseCommand):
         qs = qs.filter(club=wei).order_by(
             Lower('bus__name'),
             Lower('team__name'),
-            'roles',
+            'user__profile__promotion',
             Lower('user__last_name'),
             Lower('user__first_name'),
         ).distinct()
@@ -85,5 +85,5 @@ class Command(BaseCommand):
             s += sep + user.profile.section_generated
             s += sep + bus.name
             s += sep + (team.name if team else "--")
-            s += sep + ", ".join(role.name for role in membership.roles.all())
+            s += sep + ", ".join(role.name for role in membership.roles.filter(~Q(name="Adhérent WEI")).all())
             self.stdout.write(s)
-- 
GitLab