From 3476c8a9ec19d76156d58ec2f7c9621ed43a63fd Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Wed, 20 May 2020 16:21:28 +1200 Subject: [PATCH 1/2] SJS Sort rrset members by content before comparison to ensure correct compare. Also default comment to blank entry rather than missing entry, to allow sorting to work correctly. --- powerdnsadmin/models/record.py | 27 ++++++++++++++++++++++++--- powerdnsadmin/routes/domain.py | 7 +++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/powerdnsadmin/models/record.py b/powerdnsadmin/models/record.py index 9ff95e1..f3c0e99 100644 --- a/powerdnsadmin/models/record.py +++ b/powerdnsadmin/models/record.py @@ -14,6 +14,11 @@ from .setting import Setting from .domain import Domain from .domain_setting import DomainSetting +def byRecordContent(e): + return e['content'] + +def byRecordContentPair(e): + return e[0]['content'] class Record(object): """ @@ -60,7 +65,14 @@ class Record(object): .format(e)) return [] - return jdata['rrsets'] + rrsets=[] + for r in jdata['rrsets']: + while len(r['comments'])index): + c=r['comments'][index]['content'] + else: + c='' record_entry = RecordEntry( name=r_name, type=r['type'], status='Disabled' if record['disabled'] else 'Active', ttl=r['ttl'], data=record['content'], - comment=r['comments'][index]['content'] - if r['comments'] else '', + comment=c, is_allowed_edit=True) index += 1 records.append(record_entry) From a598c527299e172e68d0988b00472e3595673e72 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Fri, 22 May 2020 17:37:39 +0700 Subject: [PATCH 2/2] Fix base template current_user is Anonymous when we are not authenticated. Need to check if email attribute is defined before using it --- powerdnsadmin/templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/templates/base.html b/powerdnsadmin/templates/base.html index 8fadf98..8f3238e 100644 --- a/powerdnsadmin/templates/base.html +++ b/powerdnsadmin/templates/base.html @@ -30,7 +30,7 @@ {% if OFFLINE_MODE %} {% set gravatar_url = "/static/img/gravatar.png" %} - {% else %} + {% elif current_user.email is defined %} {% set gravatar_url = current_user.email|email_to_gravatar_url(size=80) %} {% endif %}