From e32186409ae67952f68dec5c30bcee287b98cec2 Mon Sep 17 00:00:00 2001 From: CaptainQwark Date: Thu, 30 Jun 2016 22:04:59 +0200 Subject: [PATCH 1/2] fixed order_by syntax on history view --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index a7e8860..3d646b4 100644 --- a/app/views.py +++ b/app/views.py @@ -233,7 +233,7 @@ def dashboard(): domain_count = Domain.query.count() users = User.query.all() history_number = History.query.count() - history = History.query.order_by("created_on desc").limit(4) + history = History.query.order_by(History.created_on.desc()).limit(4) server = Server(server_id='localhost') statistics = server.get_statistic() if statistics: From 9db71eaef5114984a4310e341d6cfa3b085b0231 Mon Sep 17 00:00:00 2001 From: CaptainQwark Date: Fri, 1 Jul 2016 21:41:41 +0200 Subject: [PATCH 2/2] fix for updates on pdns 4.0.0-rc2+ and remove flask.ext deprecation warnings --- app/lib/utils.py | 3 +++ app/models.py | 10 +++++----- app/views.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/lib/utils.py b/app/lib/utils.py index bc57c94..3498c10 100644 --- a/app/lib/utils.py +++ b/app/lib/utils.py @@ -64,6 +64,9 @@ def fetch_json(remote_url, method='GET', data=None, params=None, headers=None): if method == "DELETE": return True + if r.status_code == 204: + return {} + try: assert('json' in r.headers['content-type']) except Exception as e: diff --git a/app/models.py b/app/models.py index 8c365ad..7170916 100644 --- a/app/models.py +++ b/app/models.py @@ -10,7 +10,7 @@ import onetimepass from datetime import datetime from distutils.version import StrictVersion -from flask.ext.login import AnonymousUserMixin +from flask_login import AnonymousUserMixin from app import app, db from lib import utils @@ -720,7 +720,7 @@ class Record(object): if check: r = check[0] if r['type'] in ('A', 'AAAA' ,'CNAME'): - return {'status': 'error', 'msg': 'Record might was already exist with type "A", "AAAA", "CNAME"'} + return {'status': 'error', 'msg': 'Record already exists with type "A", "AAAA" or "CNAME"'} # continue if the record is ready to be added headers = {} @@ -896,10 +896,10 @@ class Record(object): headers = {} headers['X-API-Key'] = PDNS_API_KEY jdata1 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_delete) - logging.debug('jdata1: ', jdata1) +# logging.debug('jdata1: ', jdata1) jdata2 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_new) - logging.debug('jdata2: ', jdata2) +# logging.debug('jdata2: ', jdata2) if 'error' in jdata2.keys(): logging.error('Cannot apply record changes.') @@ -1174,4 +1174,4 @@ class Setting(db.Model): logging.error('Cannot edit setting %s' % setting) logging.debug(traceback.format_exec()) db.session.rollback() - return False \ No newline at end of file + return False diff --git a/app/views.py b/app/views.py index 3d646b4..8e92d02 100644 --- a/app/views.py +++ b/app/views.py @@ -6,7 +6,7 @@ import pyqrcode import base64 from functools import wraps -from flask.ext.login import login_user, logout_user, current_user, login_required +from flask_login import login_user, logout_user, current_user, login_required from flask import Flask, g, request, make_response, jsonify, render_template, session, redirect, url_for, send_from_directory from werkzeug import secure_filename