Start implementing listening sessions
parent
1df7cdcf40
commit
0199584f92
@ -0,0 +1,35 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2022-12-16 20:49
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import musicrate.core.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("core", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Session",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"token",
|
||||||
|
models.CharField(
|
||||||
|
default=musicrate.core.models.session_token,
|
||||||
|
max_length=43,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"playlist",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="core.playlist"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,10 @@
|
|||||||
|
from django import template
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
from qrcode import make
|
||||||
|
from qrcode.image.svg import SvgPathFillImage
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def qrcode(data):
|
||||||
|
return mark_safe(make(data, box_size=20, image_factory=SvgPathFillImage).to_string().decode('utf-8'))
|
@ -0,0 +1,8 @@
|
|||||||
|
from django import template
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def youtube(v):
|
||||||
|
return format_html('<iframe allow="autoplay; encrypted-media" allowfullscreen="" src="https://www.youtube-nocookie.com/embed/{}" width="560" height="315" frameborder="0"></iframe>', v)
|
@ -0,0 +1,11 @@
|
|||||||
|
{% extends "core/base.html" %}
|
||||||
|
|
||||||
|
{% load qrcode %}
|
||||||
|
|
||||||
|
{% block body_class %}center{% endblock %}
|
||||||
|
{% block body %}
|
||||||
|
{% qrcode session_url %}
|
||||||
|
<p>{{ session_url }}</p>
|
||||||
|
|
||||||
|
<a href="{% url 'view_artist' session.playlist.pk 0 %}">Starten</a>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,43 @@
|
|||||||
|
{% extends "core/base.html" %}
|
||||||
|
|
||||||
|
{% load qrcode %}
|
||||||
|
{% load youtube %}
|
||||||
|
|
||||||
|
{% block body_class %}center{% endblock %}
|
||||||
|
{% block body %}
|
||||||
|
<h1>{{ artist.name }}</h1>
|
||||||
|
<p>{{ artist.genre }} · {{ artist.origin }}<br>{{ artist.comment }}</p>
|
||||||
|
|
||||||
|
<div class="links">
|
||||||
|
{% for type, link in links %}
|
||||||
|
{% if type == 'youtube' %}
|
||||||
|
{% youtube link %}
|
||||||
|
{% else %}
|
||||||
|
<p>{{ link | urlize }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
{% if offset > 0 %}
|
||||||
|
<a href="{% url 'view_artist' playlist offset|add:-1 %}">< Zurück</a>
|
||||||
|
{% else %}
|
||||||
|
<a></a>
|
||||||
|
{% endif %}
|
||||||
|
{{ offset|add:1 }}/{{ count }}
|
||||||
|
{% if offset < count|add:-1 %}
|
||||||
|
<a href="{% url 'view_artist' playlist offset|add:1 %}">Weiter ></a>
|
||||||
|
{% else %}
|
||||||
|
<a></a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if session_url %}
|
||||||
|
<a href="#session">QR-Code anzeigen</a>
|
||||||
|
<div class="modal" id="session">
|
||||||
|
<a href="#"></a>
|
||||||
|
{% qrcode session_url %}
|
||||||
|
{{ session_url }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -1,8 +1,13 @@
|
|||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.create_playlist, name='create_playlist'),
|
path('', views.create_playlist, name='create_playlist'),
|
||||||
path('<slug:playlist>', views.playlist, name='playlist'),
|
path('session/', views.session, name='session'),
|
||||||
|
path('<slug:playlist>/', include([
|
||||||
|
path('', views.playlist, name='playlist'),
|
||||||
|
path('start', views.start_session, name='start_session'),
|
||||||
|
path('<int:offset>/', views.view_artist, name='view_artist'),
|
||||||
|
])),
|
||||||
]
|
]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
class JoinSessionForm(forms.Form):
|
||||||
|
pass
|
@ -0,0 +1,4 @@
|
|||||||
|
{% extends "core/base.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,8 @@
|
|||||||
|
{% extends "core/base.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button type="submit">Anhörabend beitreten</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
@ -1,7 +1,11 @@
|
|||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.vote, name='vote'),
|
path('join/<slug:session>/', views.join_session, name='join_session'),
|
||||||
|
path('<slug:playlist>/', include([
|
||||||
|
path('', views.artist, name='current_artist'),
|
||||||
|
path('<int:offset>/', views.artist, name='artist'),
|
||||||
|
])),
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
|
||||||
|
from .forms import JoinSessionForm
|
||||||
|
from ..core.models import Session
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def vote(request):
|
def join_session(request, session):
|
||||||
return render(request, 'vote/vote.html', {})
|
session = get_object_or_404(Session, pk=session)
|
||||||
|
|
||||||
|
form = JoinSessionForm()
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = JoinSessionForm(request.POST)
|
||||||
|
if not form.is_valid():
|
||||||
|
return render(request, 'vote/join_session.html', {'form': JoinSessionForm()})
|
||||||
|
|
||||||
|
return render(request, 'vote/join_session.html', {'form': form})
|
||||||
|
|
||||||
|
def artist(request, playlist, offset=None):
|
||||||
|
return render(request, 'vote/artist.html', {})
|
||||||
|
Loading…
Reference in New Issue