mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
parent
dc6cead5cd
commit
936ea0ea8e
3 changed files with 30 additions and 1 deletions
|
@ -26,6 +26,15 @@
|
|||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h3>{{ _('Scan QR code') }}</h3>
|
||||
<p><small>{% trans download_mobile=url_for(".mobile") %}On a mobile device, with <a href="{{ download_mobile }}">a compatible app installed</a>.{% endtrans %}</small></p>
|
||||
</td>
|
||||
<td>
|
||||
{{ qrcode | safe }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h3>{{ _('Send via Emails') }}</h3>
|
||||
|
|
|
@ -9,8 +9,10 @@ some shortcuts to make your life better when coding (see `pull_project`
|
|||
and `add_project_id` for a quick overview)
|
||||
"""
|
||||
from functools import wraps
|
||||
from io import StringIO
|
||||
import json
|
||||
import os
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
|
@ -28,6 +30,8 @@ from flask import (
|
|||
)
|
||||
from flask_babel import gettext as _
|
||||
from flask_mail import Message
|
||||
import qrcode
|
||||
import qrcode.image.svg
|
||||
from sqlalchemy_continuum import Operation
|
||||
from werkzeug.exceptions import NotFound
|
||||
from werkzeug.security import check_password_hash, generate_password_hash
|
||||
|
@ -586,7 +590,22 @@ def invite():
|
|||
"Sorry, there was an error while trying to send the invitation emails."
|
||||
)
|
||||
# Fall-through: we stay on the same page and display the form again
|
||||
return render_template("send_invites.html", form=form)
|
||||
|
||||
# Generate the SVG QRCode.
|
||||
invite_link = url_for(
|
||||
".join_project",
|
||||
project_id=g.project.id,
|
||||
token=g.project.generate_token(),
|
||||
_external=True,
|
||||
)
|
||||
invite_link = urlunparse(urlparse(invite_link)._replace(scheme="ihatemoney"))
|
||||
qr = qrcode.QRCode(image_factory=qrcode.image.svg.SvgPathImage)
|
||||
qr.add_data(invite_link)
|
||||
qr.make(fit=True)
|
||||
img = qr.make_image(attrib={"class": "qrcode"})
|
||||
qrcode_svg = img.to_string().decode()
|
||||
|
||||
return render_template("send_invites.html", form=form, qrcode=qrcode_svg)
|
||||
|
||||
|
||||
@main.route("/<project_id>/")
|
||||
|
|
|
@ -40,6 +40,7 @@ install_requires =
|
|||
Werkzeug>=2,<2.1 # See https://github.com/spiral-project/ihatemoney/pull/1015
|
||||
itsdangerous>=2,<3
|
||||
Jinja2>=3,<4
|
||||
qrcode>=7,<8
|
||||
requests>=2.22,<3
|
||||
SQLAlchemy-Continuum>=1.3.12,<2
|
||||
SQLAlchemy>=1.3.0,<1.4 # New 1.4 changes API, see #728
|
||||
|
|
Loading…
Reference in a new issue