Razmig Sarkissian 2 months ago
commit eee03f7708
  1. 10
      CLAUDE.md
  2. 11
      api/serializers.py
  3. 1
      api/urls.py
  4. 15
      api/views.py
  5. 2
      tournaments/templates/admin/tournaments/dashboard.html

@ -0,0 +1,10 @@
This is a django project that is used for padel tournaments management.
Here are the different apps:
- api: the api is used to communicate with the mobile app
- authentication: regroups authentications services
- biz: it's our CRM project to manage customers
- shop: the website that hosts the shop
- sync: the project used to synchronize the data between apps and the backend
- tournaments: the main website the display everything about the padel tournaments
In production, the project runs with ASGI because we use websockets in the sync app.

@ -134,6 +134,17 @@ class TournamentSerializer(serializers.ModelSerializer):
model = Tournament
fields = '__all__'
class TournamentSummarySerializer(serializers.ModelSerializer):
registration_count = serializers.SerializerMethodField()
class Meta:
model = Tournament
fields = ['id', 'name', 'start_date', 'day_duration', 'team_count', 'federal_category', 'federal_level_category', 'federal_age_category', 'registration_count']
def get_registration_count(self, obj):
return len(obj.teams(True))
class EventSerializer(serializers.ModelSerializer):
class Meta:
#club_id = serializers.PrimaryKeyRelatedField(queryset=Club.objects.all())

@ -11,6 +11,7 @@ router.register(r'users', views.UserViewSet)
router.register(r'user-agents', views.ShortUserViewSet)
router.register(r'clubs', views.ClubViewSet)
router.register(r'tournaments', views.TournamentViewSet)
router.register(r'tournament-summaries', views.TournamentSummaryViewSet)
router.register(r'images', views.ImageViewSet)
router.register(r'events', views.EventViewSet)
router.register(r'rounds', views.RoundViewSet)

@ -12,7 +12,7 @@ from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
from django.shortcuts import get_object_or_404
from .serializers import ClubSerializer, CourtSerializer, DateIntervalSerializer, DrawLogSerializer, TournamentSerializer, UserSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamScoreSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer, PurchaseSerializer, ShortUserSerializer, FailedApiCallSerializer, LogSerializer, DeviceTokenSerializer, CustomUserSerializer, UnregisteredTeamSerializer, UnregisteredPlayerSerializer, ImageSerializer, ActivitySerializer, ProspectSerializer, EntitySerializer
from .serializers import ClubSerializer, CourtSerializer, DateIntervalSerializer, DrawLogSerializer, TournamentSerializer, UserSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamScoreSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer, PurchaseSerializer, ShortUserSerializer, FailedApiCallSerializer, LogSerializer, DeviceTokenSerializer, CustomUserSerializer, UnregisteredTeamSerializer, UnregisteredPlayerSerializer, ImageSerializer, ActivitySerializer, ProspectSerializer, EntitySerializer, TournamentSummarySerializer
from tournaments.models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration, Court, DateInterval, Purchase, FailedApiCall, Log, DeviceToken, DrawLog, UnregisteredTeam, UnregisteredPlayer, Image
from biz.models import Activity, Prospect, Entity
@ -73,6 +73,19 @@ class ClubViewSet(SoftDeleteViewSet):
def perform_create(self, serializer):
serializer.save(creator=self.request.user)
class TournamentSummaryViewSet(SoftDeleteViewSet):
queryset = Tournament.objects.all()
serializer_class = TournamentSummarySerializer
def get_queryset(self):
if self.request.user.is_anonymous:
return []
return self.queryset.filter(
Q(event__creator=self.request.user) | Q(related_user=self.request.user)
).distinct()
class TournamentViewSet(SoftDeleteViewSet):
queryset = Tournament.objects.all()
serializer_class = TournamentSerializer

@ -188,6 +188,7 @@
<th style="padding: 8px 12px; text-align: left;">Date Joined</th>
<th style="padding: 8px 12px; text-align: left;">Email</th>
<th style="padding: 8px 12px; text-align: left;">Phone</th>
<th style="padding: 8px 12px; text-align: left;">Events</th>
</tr>
</thead>
<tbody>
@ -209,6 +210,7 @@
<td style="padding: 8px 12px;">{{ user.date_joined|date:"M d, Y H:i" }}</td>
<td style="padding: 8px 12px;"><a href="mailto:{{ user.email }}">{{ user.email }}</a></td>
<td style="padding: 8px 12px;">{{ user.phone }}</td>
<td style="padding: 8px 12px;">{{ user.event_count }}</td>
</tr>
{% empty %}
<tr>

Loading…
Cancel
Save