From cecaaaccf0b42aa8b15b473870329c311cd5351e Mon Sep 17 00:00:00 2001 From: laurent doreille Date: Sun, 24 May 2020 13:18:21 +0200 Subject: [PATCH] issue #30 + adaptation for python 3.8 --- hiboo/account/__init__.py | 2 +- hiboo/account/controllers.py | 16 ++++++++++++++++ hiboo/account/templates/account_profiles.html | 2 ++ hiboo/captcha/captcha.py | 9 ++++++--- requirements.txt | 3 +++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 hiboo/account/controllers.py diff --git a/hiboo/account/__init__.py b/hiboo/account/__init__.py index 1d8e9db..5dd8b36 100644 --- a/hiboo/account/__init__.py +++ b/hiboo/account/__init__.py @@ -3,4 +3,4 @@ import flask blueprint = flask.Blueprint("account", __name__, template_folder="templates") -from hiboo.account import login, home, settings \ No newline at end of file +from hiboo.account import login, home, settings, controllers \ No newline at end of file diff --git a/hiboo/account/controllers.py b/hiboo/account/controllers.py new file mode 100644 index 0000000..3785d5c --- /dev/null +++ b/hiboo/account/controllers.py @@ -0,0 +1,16 @@ +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/", 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") diff --git a/hiboo/account/templates/account_profiles.html b/hiboo/account/templates/account_profiles.html index e7bdb7a..7d7d486 100644 --- a/hiboo/account/templates/account_profiles.html +++ b/hiboo/account/templates/account_profiles.html @@ -15,6 +15,7 @@ {% trans %}Status{% endtrans %} {% trans %}Created on{% endtrans %} {% trans %}Comment{% endtrans %} + {% trans %}Delete{% endtrans %} {% for profile in current_user.profiles %} {% set status=profile.STATUSES[profile.status] %} @@ -24,6 +25,7 @@ {{ status[1] }} {{ profile.created_at.date() }} {{ profile.comment }} + {% trans %}Delete{% endtrans %} {% endfor %} diff --git a/hiboo/captcha/captcha.py b/hiboo/captcha/captcha.py index 0b93874..c77fe01 100644 --- a/hiboo/captcha/captcha.py +++ b/hiboo/captcha/captcha.py @@ -62,10 +62,13 @@ class ImageCaptchaField(fields.CaptchaField): png = io.BytesIO() self.make_image(self.context["challenge"]).save(png, "PNG") output = base64.b64encode(png.getvalue()).decode("ascii") - return widgets.HTMLString( + captchaImg = widgets.HTMLString( '

'.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): """ Renders a character diff --git a/requirements.txt b/requirements.txt index a7a855b..a840999 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ +werkzeug==0.16.1 +email-validator +Pillow Flask Flask-Login Flask-SQLAlchemy -- GitLab