From 966d0c77d6929c6acb63f5792cf8ffaea1091852 Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Wed, 8 Jun 2016 02:03:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=84=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SWSCloudCore/application.py | 32 ++++++------ .../templates/administrator/login.html | 19 ++++--- .../templates/administrator/plans/edit.html | 51 +++++++++++++++++++ .../templates/administrator/plans/index.html | 2 +- SWSCloudCore/views/administrator/__init__.py | 41 +++++++++++++++ setup.py | 2 +- 6 files changed, 122 insertions(+), 25 deletions(-) create mode 100644 SWSCloudCore/templates/administrator/plans/edit.html diff --git a/SWSCloudCore/application.py b/SWSCloudCore/application.py index 74922d1..c30f586 100644 --- a/SWSCloudCore/application.py +++ b/SWSCloudCore/application.py @@ -73,28 +73,30 @@ def page_not_found(e): @app.before_request def before_request(): - # app.logger.debug("db.connect") - g.errors = {'total': 0, 'items': []} g.settings = dict() - - try: - database.connect() - except Exception as e: - # TODO: code to email alert - # g.endpoint = request.endpoint.replace('.', '/') - return render_template('errors/500.html'), 500 - # извлекаем настройки и определяем их в глобальную переменную for setting in models.Settings.select(models.Settings.key, models.Settings.val).execute(): g.settings[setting.key] = setting.val +@app.before_first_request +def before_first_request(): + try: + database.connect() + except Exception as e: + app.logger.error(e) + # TODO: code to email alert + # g.endpoint = request.endpoint.replace('.', '/') + return render_template('errors/500.html'), 500 + + @app.after_request def after_request(response): # app.logger.debug("db.close") - try: - database.close() - except Exception as e: - # TODO: code to email alert - pass + # try: + # database.close() + # except Exception as e: + # app.logger.error(e) + # TODO: code to email alert + # pass return response diff --git a/SWSCloudCore/templates/administrator/login.html b/SWSCloudCore/templates/administrator/login.html index 498d54a..4af2071 100644 --- a/SWSCloudCore/templates/administrator/login.html +++ b/SWSCloudCore/templates/administrator/login.html @@ -3,17 +3,20 @@ {% block content %}
- {% if g.errors['total'] > 0 %} -
-
    - {% for error in g.errors['items'] %}
  • {{ error }}
  • {% endfor %} -
-
- {% endif %} + {% with messages = get_flashed_messages() %} + {% if messages %} +
+
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+
+ {% endif %} + {% endwith %}