diff --git a/pod/live/admin.py b/pod/live/admin.py index 7a1316a06a..6f6898bb1e 100644 --- a/pod/live/admin.py +++ b/pod/live/admin.py @@ -139,7 +139,7 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): def qrcode(self, obj): return obj.qrcode - qrcode.short_description = _("QR Code") + qrcode.short_description = _("QR code") qrcode.allow_tags = True class Media: diff --git a/pod/live/models.py b/pod/live/models.py index 804ff795fc..12f0dedc7c 100644 --- a/pod/live/models.py +++ b/pod/live/models.py @@ -1,8 +1,5 @@ """Esup-Pod "live" models.""" -import base64 import hashlib -import io -import qrcode import os from ckeditor.fields import RichTextField @@ -21,12 +18,12 @@ from django.urls import reverse from django.utils import timezone from django.utils.html import format_html -from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from pod.main.lang_settings import ALL_LANG_CHOICES as __ALL_LANG_CHOICES__ from pod.main.lang_settings import PREF_LANG_CHOICES as __PREF_LANG_CHOICES__ from django.utils.translation import get_language +from pod.main.utils import generate_qrcode from pod.authentication.models import AccessGroup from pod.main.models import get_nextautoincrement from pod.video.models import Video, Type @@ -272,25 +269,8 @@ def is_recording_admin(self): @property def qrcode(self, request=None): - url_scheme = "https" if SECURE_SSL_REDIRECT else "http" - url_immediate_event = reverse("live:event_immediate_edit", args={self.id}) - data = "".join( - [ - url_scheme, - "://", - get_current_site(request).domain, - url_immediate_event, - ] - ) - img = qrcode.make(data) - buffer = io.BytesIO() - img.save(buffer, format="PNG") - img_str = base64.b64encode(buffer.getvalue()).decode("utf-8") alt = _("QR code to record immediately an event") - return mark_safe( - f'{alt}' - ) + return generate_qrcode("live:event_immediate_edit", self.id, alt, request) def set_broadcaster_file(self, filename): trans_folder = os.path.join(MEDIA_ROOT, LIVE_TRANSCRIPTIONS_FOLDER) diff --git a/pod/live/templates/live/event-info.html b/pod/live/templates/live/event-info.html index 484319f8c3..20bd1a58d1 100644 --- a/pod/live/templates/live/event-info.html +++ b/pod/live/templates/live/event-info.html @@ -2,6 +2,7 @@ {% load static %} {% load tagging_tags %} {% load thumbnail %} +{% load event_tags %}
{% if event.description %} @@ -58,7 +59,7 @@

{% trans 'Type:' %}

{% if event.is_draft == False or event.owner == request.user or request.user in event.additional_owners.all or request.user.is_superuser %} -