|
|
|
|
@ -903,10 +903,40 @@ def my_tournaments(request): |
|
|
|
|
return render(request, 'registration/my_tournaments.html', { |
|
|
|
|
'upcoming_tournaments': upcoming_tournaments, |
|
|
|
|
'running_tournaments': running_tournaments, |
|
|
|
|
'ended_tournaments': ended_tournaments, |
|
|
|
|
'ended_tournaments': ended_tournaments[:12], |
|
|
|
|
'user_name': user.username |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
@login_required |
|
|
|
|
def all_my_ended_tournaments(request): |
|
|
|
|
user_licence_id = request.user.licence_id |
|
|
|
|
|
|
|
|
|
# If no licence_id, return empty lists |
|
|
|
|
if user_licence_id is None: |
|
|
|
|
return render(request, '/tournaments.html', { |
|
|
|
|
'tournaments': [], |
|
|
|
|
'title': "Palmarès", |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
# Get all tournaments for the user based on their licence |
|
|
|
|
validator = LicenseValidator(user_licence_id) |
|
|
|
|
stripped_license = validator.stripped_license |
|
|
|
|
|
|
|
|
|
def filter_user_tournaments(tournaments): |
|
|
|
|
return [t for t in tournaments if t.team_registrations.filter( |
|
|
|
|
player_registrations__licence_id__icontains=stripped_license, |
|
|
|
|
walk_out=False |
|
|
|
|
).exists()] |
|
|
|
|
|
|
|
|
|
ended_tournaments = filter_user_tournaments(finished_tournaments(None)) |
|
|
|
|
|
|
|
|
|
return render(request, |
|
|
|
|
"tournaments/tournaments_list.html", |
|
|
|
|
{ |
|
|
|
|
'tournaments': ended_tournaments, |
|
|
|
|
'title': "Palmarès", |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin |
|
|
|
|
|
|
|
|
|
class ProfileUpdateView(LoginRequiredMixin, UpdateView): |
|
|
|
|
|