mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 08:22:10 +01:00 
			
		
		
		
	Create multiple channels in case of five people-pools
This commit is contained in:
		@@ -309,7 +309,7 @@ class Command(BaseCommand):
 | 
				
			|||||||
                        await Matrix.set_room_power_level(f"#orga-{slug}:tfjm.org",
 | 
					                        await Matrix.set_room_power_level(f"#orga-{slug}:tfjm.org",
 | 
				
			||||||
                                                          f"@{orga.matrix_username}:tfjm.org", 50)
 | 
					                                                          f"@{orga.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
                        await Matrix.set_room_power_level(f"#tirage-au-sort-{slug}:tfjm.org",
 | 
					                        await Matrix.set_room_power_level(f"#tirage-au-sort-{slug}:tfjm.org",
 | 
				
			||||||
                                                    f"@{orga.matrix_username}:tfjm.org", 50)
 | 
					                                                          f"@{orga.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                # Invite participants
 | 
					                # Invite participants
 | 
				
			||||||
                for participation in tournament.participations.filter(valid=True).all():
 | 
					                for participation in tournament.participations.filter(valid=True).all():
 | 
				
			||||||
@@ -327,97 +327,104 @@ class Command(BaseCommand):
 | 
				
			|||||||
                # Create pool-specific channels
 | 
					                # Create pool-specific channels
 | 
				
			||||||
                for pool in tournament.pools.all():
 | 
					                for pool in tournament.pools.all():
 | 
				
			||||||
                    self.stdout.write(f"Managing {pool}...")
 | 
					                    self.stdout.write(f"Managing {pool}...")
 | 
				
			||||||
                    if not Matrix.resolve_room_alias(f"#poule-{slug}-{pool.id}:tfjm.org"):
 | 
					                    five = pool.participations.count() >= 5
 | 
				
			||||||
                        await Matrix.create_room(
 | 
					                    for i in range(2 if five else 1):
 | 
				
			||||||
                            visibility=RoomVisibility.public,
 | 
					                        # Fix for five teams-pools
 | 
				
			||||||
                            alias=f"poule-{slug}-{pool.id}",
 | 
					                        suffix = f"-{chr(ord('A') + i)}" if five else ""
 | 
				
			||||||
                            name=
 | 
					                        if not Matrix.resolve_room_alias(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org"):
 | 
				
			||||||
                            f"{name} - Jour {pool.round} - Poule "
 | 
					                            await Matrix.create_room(
 | 
				
			||||||
                            f"{', '.join(participation.team.trigram for participation in pool.participations.all())}",
 | 
					                                visibility=RoomVisibility.public,
 | 
				
			||||||
                            topic=f"Discussion avec les équipes - {pool}",
 | 
					                                alias=f"poule-{slug}-{pool.id}{suffix}",
 | 
				
			||||||
                            federate=False,
 | 
					                                name=f"{name} - Jour {pool.round} - Poule " +
 | 
				
			||||||
                            preset=RoomPreset.private_chat,
 | 
					                                     ', '.join(participation.team.trigram
 | 
				
			||||||
                        )
 | 
					                                               for participation in pool.participations.all()) + suffix,
 | 
				
			||||||
                    if not Matrix.resolve_room_alias(f"#poule-{slug}-{pool.id}-jurys:tfjm.org"):
 | 
					                                topic=f"Discussion avec les équipes - {pool}{suffix}",
 | 
				
			||||||
                        await Matrix.create_room(
 | 
					                                federate=False,
 | 
				
			||||||
                            visibility=RoomVisibility.public,
 | 
					                                preset=RoomPreset.private_chat,
 | 
				
			||||||
                            alias=f"poule-{slug}-{pool.id}-jurys",
 | 
					                            )
 | 
				
			||||||
                            name=
 | 
					                        if not Matrix.resolve_room_alias(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org"):
 | 
				
			||||||
                            f"{name} - Jour {pool.round} - Jurys poule "
 | 
					                            await Matrix.create_room(
 | 
				
			||||||
                            f"{', '.join(participation.team.trigram for participation in pool.participations.all())}",
 | 
					                                visibility=RoomVisibility.public,
 | 
				
			||||||
                            topic=f"Discussion avec les jurys - {pool}",
 | 
					                                alias=f"poule-{slug}-{pool.id}{suffix}-jurys",
 | 
				
			||||||
                            federate=False,
 | 
					                                name=f"{name} - Jour {pool.round}{suffix} - Jurys poule " +
 | 
				
			||||||
                            preset=RoomPreset.private_chat,
 | 
					                                     ', '.join(participation.team.trigram
 | 
				
			||||||
                        )
 | 
					                                               for participation in pool.participations.all()) + suffix,
 | 
				
			||||||
 | 
					                                topic=f"Discussion avec les jurys - {pool}{suffix}",
 | 
				
			||||||
 | 
					                                federate=False,
 | 
				
			||||||
 | 
					                                preset=RoomPreset.private_chat,
 | 
				
			||||||
 | 
					                            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}:tfjm.org", avatar_uri)
 | 
					                        await Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org", avatar_uri)
 | 
				
			||||||
                    await Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}-jurys:tfjm.org", avatar_uri)
 | 
					                        await Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org", avatar_uri)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    url_params = urlencode(dict(url=pool.bbb_url,
 | 
					                        bbb_url = pool.bbb_url
 | 
				
			||||||
                                                isAudioConf='false', displayName='$matrix_display_name',
 | 
					                        if five:
 | 
				
			||||||
                                                avatarUrl='$matrix_avatar_url', userId='$matrix_user_id')) \
 | 
					                            bbb_url = bbb_url.split(";")[i].strip()
 | 
				
			||||||
                        .replace("%24", "$")
 | 
					                        url_params = urlencode(dict(url=bbb_url,
 | 
				
			||||||
                    await Matrix.add_integration(
 | 
					                                                    isAudioConf='false', displayName='$matrix_display_name',
 | 
				
			||||||
                        f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                                                    avatarUrl='$matrix_avatar_url', userId='$matrix_user_id')) \
 | 
				
			||||||
                        f"https://scalar.vector.im/api/widgets/bigbluebutton.html?{url_params}",
 | 
					                            .replace("%24", "$")
 | 
				
			||||||
                        f"bbb-{slug}-{pool.id}", "bigbluebutton", "BigBlueButton", str(pool))
 | 
					                        await Matrix.add_integration(
 | 
				
			||||||
                    await Matrix.add_integration(
 | 
					                            f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                        f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                            f"https://scalar.vector.im/api/widgets/bigbluebutton.html?{url_params}",
 | 
				
			||||||
                        f"https://board.tfjm.org/boards/{slug}-{pool.id}", f"board-{slug}-{pool.id}",
 | 
					                            f"bbb-{slug}-{pool.id}{suffix}", "bigbluebutton", "BigBlueButton", str(pool))
 | 
				
			||||||
                        "customwidget", "Tableau", str(pool))
 | 
					                        await Matrix.add_integration(
 | 
				
			||||||
 | 
					                            f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
				
			||||||
 | 
					                            f"https://board.tfjm.org/boards/{slug}-{pool.id}", f"board-{slug}-{pool.id}",
 | 
				
			||||||
 | 
					                            "customwidget", "Tableau", str(pool))
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                    # Invite admins and give permissions
 | 
					                        # Invite admins and give permissions
 | 
				
			||||||
                    for admin in AdminRegistration.objects.all():
 | 
					                        for admin in AdminRegistration.objects.all():
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                            f"@{admin.matrix_username}:tfjm.org")
 | 
					                                                f"@{admin.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                            f"@{admin.matrix_username}:tfjm.org")
 | 
					                                                f"@{admin.matrix_username}:tfjm.org")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                                          f"@{admin.matrix_username}:tfjm.org", 95)
 | 
					                                                              f"@{admin.matrix_username}:tfjm.org", 95)
 | 
				
			||||||
                        await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                                          f"@{admin.matrix_username}:tfjm.org", 95)
 | 
					                                                              f"@{admin.matrix_username}:tfjm.org", 95)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                    # Invite organizers and give permissions
 | 
					                        # Invite organizers and give permissions
 | 
				
			||||||
                    for orga in VolunteerRegistration.objects.all():
 | 
					                        for orga in VolunteerRegistration.objects.all():
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                            f"@{orga.matrix_username}:tfjm.org")
 | 
					                                                f"@{orga.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                            f"@{orga.matrix_username}:tfjm.org")
 | 
					                                                f"@{orga.matrix_username}:tfjm.org")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if not orga.is_admin:
 | 
					                            if not orga.is_admin:
 | 
				
			||||||
                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                                await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                                              f"@{orga.matrix_username}:tfjm.org", 50)
 | 
					                                                                  f"@{orga.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                                await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                                              f"@{orga.matrix_username}:tfjm.org", 50)
 | 
					                                                                  f"@{orga.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    # Invite the jury, give good permissions
 | 
					                        # Invite the jury, give good permissions
 | 
				
			||||||
                    for jury in pool.juries.all():
 | 
					                        for jury in pool.juries.all():
 | 
				
			||||||
                        await Matrix.invite(f"#annonces-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
					                            await Matrix.invite(f"#annonces-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#general-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
					                            await Matrix.invite(f"#general-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#flood-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
					                            await Matrix.invite(f"#flood-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#jury-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
					                            await Matrix.invite(f"#jury-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#orga-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
					                            await Matrix.invite(f"#orga-{slug}:tfjm.org", f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                            f"@{jury.matrix_username}:tfjm.org")
 | 
					                                                f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                            await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                            f"@{jury.matrix_username}:tfjm.org")
 | 
					                                                f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
                        await Matrix.invite(f"#tirage-au-sort-{slug}:tfjm.org",
 | 
					                            await Matrix.invite(f"#tirage-au-sort-{slug}:tfjm.org",
 | 
				
			||||||
                                            f"@{jury.matrix_username}:tfjm.org")
 | 
					                                                f"@{jury.matrix_username}:tfjm.org")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if not jury.is_admin:
 | 
					                            if not jury.is_admin:
 | 
				
			||||||
                            await Matrix.set_room_power_level(f"#jury-{slug}:tfjm.org",
 | 
					                                await Matrix.set_room_power_level(f"#jury-{slug}:tfjm.org",
 | 
				
			||||||
                                                              f"@{jury.matrix_username}:tfjm.org", 50)
 | 
					                                                                  f"@{jury.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                                await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                                        f"@{jury.matrix_username}:tfjm.org", 50)
 | 
					                                                                  f"@{jury.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
                            await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}-jurys:tfjm.org",
 | 
					                                await Matrix.set_room_power_level(f"#poule-{slug}-{pool.id}{suffix}-jurys:tfjm.org",
 | 
				
			||||||
                                                        f"@{jury.matrix_username}:tfjm.org", 50)
 | 
					                                                                  f"@{jury.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                    # Invite participants to the right pool
 | 
					                        # Invite participants to the right pool
 | 
				
			||||||
                    for participation in pool.participations.all():
 | 
					                        for participation in pool.participations.all():
 | 
				
			||||||
                        for participant in participation.team.participants.all():
 | 
					                            for participant in participation.team.participants.all():
 | 
				
			||||||
                            await Matrix.invite(f"#poule-{slug}-{pool.id}:tfjm.org",
 | 
					                                await Matrix.invite(f"#poule-{slug}-{pool.id}{suffix}:tfjm.org",
 | 
				
			||||||
                                                f"@{participant.matrix_username}:tfjm.org")
 | 
					                                                    f"@{participant.matrix_username}:tfjm.org")
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
            # Create private channels for teams
 | 
					            # Create private channels for teams
 | 
				
			||||||
            for team in Team.objects.all():
 | 
					            for team in Team.objects.all():
 | 
				
			||||||
@@ -435,6 +442,6 @@ class Command(BaseCommand):
 | 
				
			|||||||
                    await Matrix.invite(f"#equipe-{team.trigram.lower}:tfjm.org",
 | 
					                    await Matrix.invite(f"#equipe-{team.trigram.lower}:tfjm.org",
 | 
				
			||||||
                                        f"@{participant.matrix_username}:tfjm.org")
 | 
					                                        f"@{participant.matrix_username}:tfjm.org")
 | 
				
			||||||
                    await Matrix.set_room_power_level(f"#equipe-{team.trigram.lower()}:tfjm.org",
 | 
					                    await Matrix.set_room_power_level(f"#equipe-{team.trigram.lower()}:tfjm.org",
 | 
				
			||||||
                                                f"@{participant.matrix_username}:tfjm.org", 50)
 | 
					                                                      f"@{participant.matrix_username}:tfjm.org", 50)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        asyncio.get_event_loop().run_until_complete(main())
 | 
					        asyncio.get_event_loop().run_until_complete(main())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@
 | 
				
			|||||||
                </dd>
 | 
					                </dd>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <dt class="col-sm-3">{% trans "BigBlueButton link:" %}</dt>
 | 
					                <dt class="col-sm-3">{% trans "BigBlueButton link:" %}</dt>
 | 
				
			||||||
                <dd class="col-sm-9"><a href="{{ pool.bbb_url }}">{{ pool.bbb_url }}</a></dd>
 | 
					                <dd class="col-sm-9">{{ pool.bbb_url|urlize }}</dd>
 | 
				
			||||||
            </dl>
 | 
					            </dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div class="card bg-light shadow">
 | 
					            <div class="card bg-light shadow">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user