Initial commit: WrestleDesk full project

- Django backend with DRF (clubs, wrestlers, trainers, exercises, templates, trainings, homework, locations, leistungstest)
- Next.js 16 frontend with React, Shadcn UI, Tailwind
- JWT authentication
- Full CRUD for all entities
- Calendar view for trainings
- Homework management system
- Leistungstest tracking
This commit is contained in:
Andrej Spielmann
2026-03-26 13:24:57 +01:00
commit 3fefc550fe
256 changed files with 38295 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
from rest_framework import viewsets, filters
from rest_framework.permissions import IsAuthenticated
from rest_framework.decorators import action
from rest_framework.response import Response
from django_filters.rest_framework import DjangoFilterBackend
from utils.permissions import ClubFilterBackend, ClubLevelPermission
from .models import Wrestler
from .serializers import WrestlerSerializer
from wrestleDesk.pagination import StandardResultsSetPagination
class WrestlerViewSet(viewsets.ModelViewSet):
queryset = Wrestler.objects.select_related('club').all()
serializer_class = WrestlerSerializer
pagination_class = StandardResultsSetPagination
permission_classes = [IsAuthenticated]
filter_backends = [DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter]
filterset_fields = ['group', 'is_active', 'gender']
search_fields = ['first_name', 'last_name', 'license_number']
ordering_fields = ['last_name', 'first_name', 'created_at']
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
club = self.request.query_params.get('club')
if club and club != 'all':
queryset = queryset.filter(club_id=club)
return queryset
@action(detail=False, methods=['get'])
def available_for_training(self, request):
"""
Returns ALL wrestlers without club filtering.
Used when selecting wrestlers for a training session
where wrestlers from other clubs may attend.
"""
queryset = Wrestler.objects.select_related('club').filter(is_active=True)
search = request.query_params.get('search')
if search:
queryset = queryset.filter(first_name__icontains=search) | queryset.filter(last_name__icontains=search)
group = request.query_params.get('group')
if group:
queryset = queryset.filter(group=group)
queryset = queryset.order_by('last_name', 'first_name')
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)