Commit cecaaacc authored by laurent doreille's avatar laurent doreille

issue #30 + adaptation for python 3.8

parent 438b38f1
...@@ -3,4 +3,4 @@ import flask ...@@ -3,4 +3,4 @@ import flask
blueprint = flask.Blueprint("account", __name__, template_folder="templates") blueprint = flask.Blueprint("account", __name__, template_folder="templates")
from hiboo.account import login, home, settings from hiboo.account import login, home, settings, controllers
\ No newline at end of file \ No newline at end of file
from hiboo.account import blueprint
from hiboo import models, security
from flask_babel import lazy_gettext as _
import flask
import flask_login
@blueprint.route("profiles/delete/<uuid>", methods=["GET", "POST"])
@security.authentication_required()
def profile_delete(uuid):
profile = models.Profile.query.filter_by(uuid=uuid).first()
models.db.session.delete(profile)
models.db.session.commit()
flask.flash(_("Profile is correctly deleted."), "success")
return flask.render_template("account_profiles.html")
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<th>{% trans %}Status{% endtrans %}</th> <th>{% trans %}Status{% endtrans %}</th>
<th>{% trans %}Created on{% endtrans %}</th> <th>{% trans %}Created on{% endtrans %}</th>
<th>{% trans %}Comment{% endtrans %}</th> <th>{% trans %}Comment{% endtrans %}</th>
<th>{% trans %}Delete{% endtrans %}</th>
</tr> </tr>
{% for profile in current_user.profiles %} {% for profile in current_user.profiles %}
{% set status=profile.STATUSES[profile.status] %} {% set status=profile.STATUSES[profile.status] %}
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
<td><span class="badge bg-{{ status[0] }}">{{ status[1] }}</span></td> <td><span class="badge bg-{{ status[0] }}">{{ status[1] }}</span></td>
<td>{{ profile.created_at.date() }}</td> <td>{{ profile.created_at.date() }}</td>
<td>{{ profile.comment }}</td> <td>{{ profile.comment }}</td>
<td><a href="{{ url_for('account.profile_delete',uuid=profile.uuid) }}">{% trans %}Delete{% endtrans %}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
......
...@@ -62,10 +62,13 @@ class ImageCaptchaField(fields.CaptchaField): ...@@ -62,10 +62,13 @@ class ImageCaptchaField(fields.CaptchaField):
png = io.BytesIO() png = io.BytesIO()
self.make_image(self.context["challenge"]).save(png, "PNG") self.make_image(self.context["challenge"]).save(png, "PNG")
output = base64.b64encode(png.getvalue()).decode("ascii") output = base64.b64encode(png.getvalue()).decode("ascii")
return widgets.HTMLString( captchaImg = widgets.HTMLString(
'<p><img src="data:image/png;base64,{}"></p>'.format(output) '<p><img src="data:image/png;base64,{}"></p>'.format(output)
+ super(ImageCaptchaField, self).__call__(**kwargs) );
)
inputFields = widgets.HTMLString(super(ImageCaptchaField, self).__call__(**kwargs))
return captchaImg + inputFields
def make_char(self, char, rotation_range=15): def make_char(self, char, rotation_range=15):
""" Renders a character """ Renders a character
......
  • le module python ne propose plus sa version contrib werkzeug.contrib utilisé par flask d'où le "downgrade" Pillow remplace PIL et nécessite une adaptation pour le captcha

    issue #30 corrigée

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment