Merge branch 'master' into url_for_static_assets

This commit is contained in:
Khanh Ngo 2020-05-24 21:16:00 +07:00 committed by GitHub
commit 73c267848c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 6 deletions

View File

@ -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'])<len(r['records']):
r['comments'].append({"content":"", "account":""})
r['records'], r['comments'] = (list(t) for t in zip(*sorted(zip(r['records'],r['comments']),key=byRecordContentPair)))
rrsets.append(r)
return rrsets
def add(self, domain_name, rrset):
"""
@ -131,6 +143,11 @@ class Record(object):
for r in rrsets[1:]:
rrest['records'] = rrest['records'] + r['records']
rrest['comments'] = rrest['comments'] + r['comments']
while len(rrest['comments'])<len(rrest['records']):
rrest['comments'].append({"content":"", "account":""})
zipped_list = zip(rrest['records'],rrest['comments'])
tuples = zip(*sorted(zipped_list,key=byRecordContentPair))
rrest['records'], rrest['comments'] = [list(t) for t in tuples]
return rrest
def build_rrsets(self, domain_name, submitted_records):
@ -185,7 +202,10 @@ class Record(object):
record_comments = [{
"content": record["record_comment"],
"account": ""
}] if record.get("record_comment") else []
}] if record.get("record_comment") else [{
"content": "",
"account": ""
}]
# Add the formatted record to rrsets list
rrsets.append({
@ -237,7 +257,8 @@ class Record(object):
# comparison between current and submitted rrsets
for r in current_rrsets:
for comment in r['comments']:
del comment['modified_at']
if 'modified_at' in comment:
del comment['modified_at']
# List of rrsets to be added
new_rrsets = {"rrsets": []}

View File

@ -99,14 +99,17 @@ def domain(domain_name):
# PDA jinja2 template can understand.
index = 0
for record in r['records']:
if (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)

View File

@ -30,7 +30,7 @@
<body class="hold-transition skin-blue sidebar-mini {% if not SETTING.get('fullscreen_layout') %}layout-boxed{% endif %}">
{% if OFFLINE_MODE %}
{% set gravatar_url = "{{ url_for('static', filename='img/gravatar.png') }}" %}
{% else %}
{% elif current_user.email is defined %}
{% set gravatar_url = current_user.email|email_to_gravatar_url(size=80) %}
{% endif %}
<div class="wrapper">