mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 16:02:26 +01:00 
			
		
		
		
	More data in CSV file
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -598,7 +598,7 @@ class TournamentPaymentsView(VolunteerMixin, SingleTableMixin, DetailView):
 | 
			
		||||
 | 
			
		||||
class TournamentExportCSVView(VolunteerMixin, DetailView):
 | 
			
		||||
    """
 | 
			
		||||
    Export team information in a CSV file.
 | 
			
		||||
    Export all team informations in a CSV file.
 | 
			
		||||
    """
 | 
			
		||||
    model = Tournament
 | 
			
		||||
 | 
			
		||||
@@ -609,24 +609,46 @@ class TournamentExportCSVView(VolunteerMixin, DetailView):
 | 
			
		||||
            content_type='text/csv',
 | 
			
		||||
            headers={'Content-Disposition': f'attachment; filename="Tournoi de {tournament.name}.csv"'},
 | 
			
		||||
        )
 | 
			
		||||
        writer = csv.DictWriter(resp, ('Tournoi', 'Équipe', 'Trigramme', 'Nom', 'Prénom', 'Email',
 | 
			
		||||
                                       'Genre', 'Date de naissance'))
 | 
			
		||||
        writer = csv.DictWriter(resp, ('Tournoi', 'Équipe', 'Trigramme', 'Sélectionnée',
 | 
			
		||||
                                       'Nom', 'Prénom', 'Email', 'Type', 'Genre', 'Date de naissance',
 | 
			
		||||
                                       'Adresse', 'Code postal', 'Ville', 'Téléphone',
 | 
			
		||||
                                       'Classe', 'Établissement',
 | 
			
		||||
                                       'Nom responsable légal⋅e', 'Téléphone responsable légal⋅e',
 | 
			
		||||
                                       'Email responsable légal⋅e',
 | 
			
		||||
                                       'Problèmes de santé', 'Contraintes de logement'))
 | 
			
		||||
        writer.writeheader()
 | 
			
		||||
 | 
			
		||||
        for participation in tournament.participations.filter(valid=True).order_by('team__trigram').all():
 | 
			
		||||
        participations = tournament.participations
 | 
			
		||||
        if 'all' not in request.GET:
 | 
			
		||||
            participations = participations.filter(valid=True)
 | 
			
		||||
        for participation in participations.order_by('-valid', 'team__trigram').all():
 | 
			
		||||
            for registration in participation.team.participants\
 | 
			
		||||
                    .order_by('coachregistration', 'user__last_name').all():
 | 
			
		||||
                writer.writerow({
 | 
			
		||||
                    'Tournoi': tournament.name,
 | 
			
		||||
                    'Équipe': participation.team.name,
 | 
			
		||||
                    'Trigramme': participation.team.trigram,
 | 
			
		||||
                    'Sélectionnée': ("oui" if participation.valid else
 | 
			
		||||
                                     "en attente" if participation.valid is False else "non"),
 | 
			
		||||
                    'Nom': registration.user.last_name,
 | 
			
		||||
                    'Prénom': registration.user.first_name,
 | 
			
		||||
                    'Email': registration.user.email,
 | 
			
		||||
                    'Genre': registration.get_gender_display() if isinstance(registration, StudentRegistration)
 | 
			
		||||
                    else 'Encadrant⋅e',
 | 
			
		||||
                    'Date de naissance': registration.birth_date if isinstance(registration, StudentRegistration)
 | 
			
		||||
                    else 'Encadrant⋅e',
 | 
			
		||||
                    'Type': registration.type.capitalize(),
 | 
			
		||||
                    'Genre': registration.get_gender_display() if registration.is_student else '',
 | 
			
		||||
                    'Date de naissance': registration.birth_date if registration.is_student else '',
 | 
			
		||||
                    'Adresse': registration.address,
 | 
			
		||||
                    'Code postal': registration.zip_code,
 | 
			
		||||
                    'Ville': registration.city,
 | 
			
		||||
                    'Téléphone': registration.phone_number,
 | 
			
		||||
                    'Classe': registration.get_student_class_display() if registration.is_student
 | 
			
		||||
                    else registration.last_degree,
 | 
			
		||||
                    'Établissement': registration.school if registration.is_student
 | 
			
		||||
                    else registration.professional_activity,
 | 
			
		||||
                    'Nom responsable légal⋅e': registration.responsible_name if registration.is_student else '',
 | 
			
		||||
                    'Téléphone responsable légal⋅e': registration.responsible_phone if registration.is_student else '',
 | 
			
		||||
                    'Email responsable légal⋅e': registration.responsible_email if registration.is_student else '',
 | 
			
		||||
                    'Problèmes de santé': registration.health_issues,
 | 
			
		||||
                    'Contraintes de logement': registration.housing_constraints,
 | 
			
		||||
                })
 | 
			
		||||
 | 
			
		||||
        return resp
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user