Adds QR code to broadcast pages

clubs
Laurent 2 years ago
parent 77cba7b6a7
commit 85f52e5bd3
  1. 1
      padelclub_backend/settings.py
  2. 13
      padelclub_backend/settings_app.py
  3. 3
      tournaments/models/tournament.py
  4. 6
      tournaments/static/tournaments/css/style.css
  5. 6
      tournaments/templates/tournaments/broadcast_base.html
  6. 6
      tournaments/templates/tournaments/broadcasted_auto.html
  7. 7
      tournaments/templates/tournaments/broadcasted_group_stages.html
  8. 6
      tournaments/templates/tournaments/broadcasted_matches.html
  9. 21
      tournaments/views.py

@ -42,6 +42,7 @@ INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken',
'dj_rest_auth',
'qr_code',
]
AUTH_USER_MODEL = "tournaments.CustomUser"

@ -28,3 +28,16 @@ EMAIL_HOST_USER = 'xlr@alwaysdata.net'
EMAIL_HOST_PASSWORD = 'XLRSport$2024'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Padel Club <xlr@alwaysdata.net>'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
'qr-code': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'qr-code-cache',
'TIMEOUT': 3600
}
}
QR_CODE_CACHE_ALIAS = 'qr-code'

@ -143,7 +143,8 @@ class Tournament(models.Model):
now = timezone.now()
today_matches = [match for match in self.all_matches() if match.start_date.date() == now]
today_matches = [match for match in self.all_matches() if match.start_date]
today_matches = [match for match in today_matches if match.start_date.date() == now]
today_matches.sort(key=lambda m: m.start_date)
matches, group_stages = self.broadcasted_matches_and_group_stages()

@ -268,6 +268,10 @@ tr {
background-color: red;
}
svg {
border-radius: 16px;
}
.bubble {
padding: 20px;
background-color: white;
@ -514,7 +518,7 @@ tr {
.table-row-4-colums {
display: grid;
grid-template-columns: 1px auto 50px 70px 150px; /* first column is a hack */
grid-template-columns: 1px auto 50px 70px 180px; /* first column is a hack */
align-items: center; /* Vertically center the content within each column */
padding: 5px 0px;
}

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
{% load static %}
{% load qr_code %}
<head>
{% include 'tournaments/base_head.html' %}
@ -28,6 +29,11 @@
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="alignright">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div>
</header>

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
{% load static %}
{% load qr_code %}
<head>
{% include 'tournaments/base_head.html' %}
@ -91,6 +92,11 @@
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="alignright">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div>
</header>

@ -1,5 +1,7 @@
<!DOCTYPE html>
{% load static %}
{% load qr_code %}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
@ -60,6 +62,11 @@
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="alignright">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div>
<div class="grid-x padding-bottom">

@ -1,5 +1,6 @@
<!DOCTYPE html>
{% load static %}
{% load qr_code %}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
@ -58,6 +59,11 @@
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="alignright">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div>
<div class="grid-x padding-bottom">

@ -2,6 +2,8 @@ from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from django.utils.encoding import force_str
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.urls import reverse
from .tokens import account_activation_token
from tournaments.models import group_stage
@ -24,6 +26,8 @@ from django.http import JsonResponse
from django.db.models import Q
import json
from qr_code.qrcode.utils import QRCodeOptions
def index(request):
today = date.today()
@ -103,6 +107,8 @@ def tournament_broadcasted_summons(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_summons.html', {
'tournament': tournament,
'qr_code_url': qr_code_url(request, tournament_id),
'qr_code_options': qr_code_options(),
})
def tournament_summons_json(request, tournament_id):
@ -115,18 +121,31 @@ def tournament_broadcast_home(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcast.html', {
'tournament': tournament,
'qr_code_url': qr_code_url(request, tournament_id),
'qr_code_options': qr_code_options(),
})
def automatic_broadcast(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_auto.html', {
'tournament': tournament,
'qr_code_url': qr_code_url(request, tournament_id),
'qr_code_options': qr_code_options(),
})
def qr_code_url(request, tournament_id):
qr_code_url = reverse('tournament', args=[tournament_id])
return request.build_absolute_uri(qr_code_url)
def qr_code_options():
return QRCodeOptions(size=10, border=4, error_correction='L')
def tournament_matches(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_matches.html', {
'tournament': tournament,
'qr_code_url': qr_code_url(request, tournament_id),
'qr_code_options': qr_code_options(),
})
def broadcast_json(request, tournament_id):
@ -155,6 +174,8 @@ def tournament_broadcasted_group_stages(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_group_stages.html', {
'tournament': tournament,
'qr_code_url': qr_code_url(request, tournament_id),
'qr_code_options': qr_code_options(),
})
def tournament_live_group_stage_json(request, tournament_id):

Loading…
Cancel
Save