|
|
|
|
@ -11,6 +11,7 @@ from django.views.decorators.csrf import csrf_exempt |
|
|
|
|
from django.contrib.admin.views.decorators import staff_member_required |
|
|
|
|
from django.core.files.storage import default_storage |
|
|
|
|
from django.core.files.base import ContentFile |
|
|
|
|
from django.views.generic import View |
|
|
|
|
|
|
|
|
|
from tournaments.models.device_token import DeviceToken |
|
|
|
|
|
|
|
|
|
@ -883,3 +884,39 @@ def team_details(request, tournament_id, team_id): |
|
|
|
|
'matches': all_matches, |
|
|
|
|
'debug': False # Set to False in production |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
class UserListExportView(LoginRequiredMixin, View): |
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
# Get users, excluding those with origin=UserOrigin.SITE, ordered by date_joined |
|
|
|
|
users = CustomUser.objects.exclude( |
|
|
|
|
origin=UserOrigin.SITE |
|
|
|
|
).order_by('date_joined') |
|
|
|
|
|
|
|
|
|
# Prepare the response |
|
|
|
|
response = HttpResponse(content_type='text/plain; charset=utf-8') |
|
|
|
|
|
|
|
|
|
# Write header |
|
|
|
|
headers = [ |
|
|
|
|
'Prenom', 'Nom', 'Club', 'Email', 'Telephone', |
|
|
|
|
'Login', 'Actif', 'Inscription', 'Tournois' |
|
|
|
|
] |
|
|
|
|
response.write('\t'.join(headers) + '\n') |
|
|
|
|
|
|
|
|
|
# Write data rows |
|
|
|
|
for user in users: |
|
|
|
|
row = [ |
|
|
|
|
str(user.first_name or ''), |
|
|
|
|
str(user.last_name or ''), |
|
|
|
|
str(user.latest_event_club_name() or ''), |
|
|
|
|
str(user.email or ''), |
|
|
|
|
str(user.phone or ''), |
|
|
|
|
str(user.username or ''), |
|
|
|
|
'Oui' if user.is_active else 'Non', |
|
|
|
|
user.date_joined.strftime('%Y-%m-%d %H:%M:%S'), |
|
|
|
|
str(user.event_count()) |
|
|
|
|
] |
|
|
|
|
# Replace any tabs or newlines in the data to prevent formatting issues |
|
|
|
|
row = [field.replace('\t', ' ') for field in row] |
|
|
|
|
response.write('\t'.join(row) + '\r\n') |
|
|
|
|
|
|
|
|
|
return response |
|
|
|
|
|