Skip to content

Commit e937b99

Browse files
lcduongodkhang
andauthored
Improve export text and button (#177)
Co-authored-by: lcduong <[email protected]>
1 parent eca5be9 commit e937b99

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

src/pretalx/agenda/templates/agenda/header_row.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<span>{% translate "Version" %} <a href="{{ request.event.urls.changelog }}">{{ schedule.version|default:"–" }}</a></span>
2525
<details class="dropdown">
2626
<summary class="btn btn-sm btn-outline-info">
27-
<i class="fa fa-code"></i><i class="fa fa-caret-down"></i>
27+
<i class="fa fa-calendar-plus-o"></i> Add to Calendar <i class="fa fa-caret-down"></i>
2828
</summary>
2929
<ul class="dropdown-content dropdown-content-s{% if rtl %}e{% else %}w{% endif %}">
3030
{% for exporter in exporters %}{% if exporter.public %}

src/pretalx/common/exporter.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from io import StringIO
1+
import base64
2+
from io import StringIO, BytesIO
23
from urllib.parse import quote
3-
from xml.etree import ElementTree as ET
44

55
import qrcode
66
import qrcode.image.svg
@@ -94,10 +94,27 @@ class urls(EventUrls):
9494
base = "{self.event.urls.export}{self.quoted_identifier}"
9595

9696
def get_qrcode(self):
97-
image = qrcode.make(
98-
self.urls.base.full(), image_factory=qrcode.image.svg.SvgImage
97+
# Generate QR code
98+
qr = qrcode.QRCode(
99+
version=1,
100+
error_correction=qrcode.constants.ERROR_CORRECT_L,
101+
box_size=5,
102+
border=4,
99103
)
100-
return mark_safe(ET.tostring(image.get_image()).decode())
104+
qr.add_data(self.urls.base.full())
105+
qr.make(fit=True)
106+
107+
# Create an image from the QR Code instance
108+
img = qr.make_image(fill_color="black", back_color="white")
109+
# Convert the image to a data URL
110+
buffer = BytesIO()
111+
img.save(buffer, format="PNG")
112+
img_str = base64.b64encode(buffer.getvalue()).decode()
113+
114+
# Use the data URL in an HTML img tag
115+
html_img = f'<img src="data:image/png;base64,{img_str}" alt="QR Code"/>'
116+
117+
return mark_safe(html_img)
101118

102119

103120
class CSVExporterMixin:

src/pretalx/schedule/exporters.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def data(self):
114114

115115
class FrabXmlExporter(ScheduleData):
116116
identifier = "schedule.xml"
117-
verbose_name = "XML (frab compatible)"
117+
verbose_name = "Sessions XML"
118118
public = True
119119
show_qrcode = True
120120
favs_retrieve = False
@@ -147,13 +147,13 @@ def render(self, **kwargs):
147147

148148
class MyFrabXmlExporter(FrabXmlExporter):
149149
identifier = "schedule-my.xml"
150-
verbose_name = "My XML (frab compatible)"
150+
verbose_name = "My ⭐ Sessions XML"
151151
favs_retrieve = True
152152

153153

154154
class FrabXCalExporter(ScheduleData):
155155
identifier = "schedule.xcal"
156-
verbose_name = "XCal (frab compatible)"
156+
verbose_name = "Sessions XCAL"
157157
public = True
158158
favs_retrieve = False
159159
talk_ids = []
@@ -178,13 +178,13 @@ def render(self, **kwargs):
178178

179179
class MyFrabXCalExporter(FrabXCalExporter):
180180
identifier = "schedule-my.xcal"
181-
verbose_name = "My XCal (frab compatible)"
181+
verbose_name = "My ⭐ Sessions XCAL"
182182
favs_retrieve = True
183183

184184

185185
class FrabJsonExporter(ScheduleData):
186186
identifier = "schedule.json"
187-
verbose_name = "JSON (frab compatible)"
187+
verbose_name = "Sessions JSON"
188188
public = True
189189
favs_retrieve = False
190190
talk_ids = []
@@ -338,13 +338,13 @@ def render(self, **kwargs):
338338

339339
class MyFrabJsonExporter(FrabJsonExporter):
340340
identifier = "schedule-my.json"
341-
verbose_name = "My JSON (frab compatible)"
341+
verbose_name = "My ⭐ Sessions JSON"
342342
favs_retrieve = True
343343

344344

345345
class ICalExporter(BaseExporter):
346346
identifier = "schedule.ics"
347-
verbose_name = "iCal"
347+
verbose_name = "Sessions iCal"
348348
public = True
349349
show_qrcode = True
350350
favs_retrieve = False
@@ -378,5 +378,5 @@ def render(self, **kwargs):
378378

379379
class MyICalExporter(ICalExporter):
380380
identifier = "schedule-my.ics"
381-
verbose_name = "My iCal"
381+
verbose_name = "My ⭐ Sessions iCal"
382382
favs_retrieve = True

0 commit comments

Comments
 (0)