diff --git a/app/models.py b/app/models.py index a73e784..7933987 100644 --- a/app/models.py +++ b/app/models.py @@ -18,6 +18,8 @@ from flask_login import AnonymousUserMixin from app import app, db from app.lib import utils from app.lib.log import logger + +# LOG CONFIGS logging = logger('MODEL', app.config['LOG_LEVEL'], app.config['LOG_FILE']).config() if 'LDAP_TYPE' in app.config.keys(): @@ -894,7 +896,7 @@ class Record(object): list_deleted_records = [x for x in list_current_records if x not in list_new_records] # convert back to list of hash - deleted_records = [x for x in current_records if [x['name'],x['type']] in list_deleted_records and x['type'] in app.config['RECORDS_ALLOW_EDIT']] + deleted_records = [x for x in current_records if [x['name'],x['type']] in list_deleted_records and (x['type'] in app.config['RECORDS_ALLOW_EDIT'] and x['type'] != 'SOA')] # return a tuple return deleted_records, new_records @@ -1042,12 +1044,14 @@ class Record(object): }) postdata_for_new = {"rrsets": final_records} - + logging.info(postdata_for_new) + logging.info(postdata_for_delete) + logging.info(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain))) try: headers = {} headers['X-API-Key'] = PDNS_API_KEY - jdata1 = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_delete) - jdata2 = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_new) + jdata1 = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain)), headers=headers, method='PATCH', data=postdata_for_delete) + jdata2 = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain)), headers=headers, method='PATCH', data=postdata_for_new) if 'error' in jdata2.keys(): logging.error('Cannot apply record changes.') @@ -1058,7 +1062,7 @@ class Record(object): logging.info('Record was applied successfully.') return {'status': 'ok', 'msg': 'Record was applied successfully'} except Exception as e: - logging.error("Cannot apply record changes to domain %s. DETAIL: %s" % (e, domain)) + logging.error("Cannot apply record changes to domain {0}. DETAIL: {1}".format(e, domain)) return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'} def auto_ptr(self, domain, new_records, deleted_records): @@ -1127,12 +1131,18 @@ class Record(object): logging.error("Cannot remove record %s/%s/%s from domain %s" % (self.name, self.type, self.data, domain)) return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'} - def is_allowed(self): + def is_allowed_edit(self): """ - Check if record is allowed to edit/removed + Check if record is allowed to edit """ return self.type in app.config['RECORDS_ALLOW_EDIT'] + def is_allowed_delete(self): + """ + Check if record is allowed to removed + """ + return (self.type in app.config['RECORDS_ALLOW_EDIT'] and self.type != 'SOA') + def exists(self, domain): """ Check if record is present within domain records, and if it's present set self to found record @@ -1361,3 +1371,83 @@ class Setting(db.Model): logging.debug(traceback.format_exec()) db.session.rollback() return False + + +class DomainTemplate(db.Model): + __tablename__ = "domain_template" + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(255), index=True, unique=True) + description = db.Column(db.String(255)) + records = db.relationship('DomainTemplateRecord', back_populates='template', cascade="all, delete-orphan") + + def __repr__(self): + return '' % self.name + + def __init__(self, name=None, description=None): + self.id = None + self.name = name + self.description = description + + def replace_records(self, records): + try: + self.records = [] + for record in records: + self.records.append(record) + db.session.commit() + return {'status': 'ok', 'msg': 'Template records have been modified'} + except Exception as e: + logging.error('Cannot create template records Error: {0}'.format(e)) + db.session.rollback() + return {'status': 'error', 'msg': 'Can not create template records'} + + def create(self): + try: + db.session.add(self) + db.session.commit() + return {'status': 'ok', 'msg': 'Template has been created'} + except Exception as e: + logging.error('Can not update domain template table. Error: {0}'.format(e)) + db.session.rollback() + return {'status': 'error', 'msg': 'Can not update domain template table'} + + def delete_template(self): + try: + self.records = [] + db.session.delete(self) + db.session.commit() + return {'status': 'ok', 'msg': 'Template has been deleted'} + except Exception as e: + logging.error('Can not delete domain template. Error: {0}'.format(e)) + db.session.rollback() + return {'status': 'error', 'msg': 'Can not delete domain template'} + + +class DomainTemplateRecord(db.Model): + __tablename__ = "domain_template_record" + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(255)) + type = db.Column(db.String(64)) + ttl = db.Column(db.Integer) + data = db.Column(db.String(255)) + status = db.Column(db.Boolean) + template_id = db.Column(db.Integer, db.ForeignKey('domain_template.id')) + template = db.relationship('DomainTemplate', back_populates='records') + + def __repr__(self): + return '' % self.id + + def __init__(self, id=None, name=None, type=None, ttl=None, data=None, status=None): + self.id = id + self.name = name + self.type = type + self.ttl = ttl + self.data = data + self.status = status + + def apply(self): + try: + db.session.commit() + except Exception as e: + logging.error('Can not update domain template table. Error: {0}'.format(e)) + db.session.rollback() + return {'status': 'error', 'msg': 'Can not update domain template table'} diff --git a/app/templates/base.html b/app/templates/base.html index 06f239b..81eec24 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -127,6 +127,7 @@
  • New Domain
  • ADMINISTRATION
  • Admin Console
  • +
  • Domain Templates
  • Users
  • History
  • Settings
  • diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index f99b2dd..73d394b 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -203,6 +203,31 @@ var domain = $(this).prop('id'); getdnssec($SCRIPT_ROOT + '/domain/' + domain + '/dnssec'); }); + + $(document.body).on("click", ".button_template", function (e) { + var modal = $("#modal_template"); + var domain = $(this).prop('id'); + var form = " \ + \ + \ + \ + \ + "; + modal.find('.modal-body p').html(form); + modal.find('#button_save').click(function() { + var data = {}; + data['name'] = modal.find('#template_name').val(); + data['description'] = modal.find('#template_description').val(); + data['domain'] = modal.find('#domain').val(); + applyChanges(data, $SCRIPT_ROOT + "{{ url_for('create_template_from_zone') }}", true); + modal.modal('hide'); + }) + modal.find('#button_close').click(function() { + modal.modal('hide'); + }) + + modal.modal('show'); + }); {% endblock %} {% block modals %} @@ -252,4 +277,27 @@ + {% endblock %} diff --git a/app/templates/dashboard_domain.html b/app/templates/dashboard_domain.html index 47fe2bf..fa29260 100644 --- a/app/templates/dashboard_domain.html +++ b/app/templates/dashboard_domain.html @@ -27,14 +27,11 @@ {% endmacro %} {% macro actions(domain) %} - {% if current_user.role.name !='Administrator' %} - - - - {% else %} - @@ -42,5 +39,11 @@ Admin  + {% else %} + + + {% endif %} {% endmacro %} diff --git a/app/templates/domain.html b/app/templates/domain.html index 6becd9b..8a67257 100644 --- a/app/templates/domain.html +++ b/app/templates/domain.html @@ -70,25 +70,23 @@ {% if domain.type != 'Slave' %} - {% if record.is_allowed() %} + {% if record.is_allowed_edit() %} {% else %} {% endif %} - {% if record.is_allowed() %} + {% if record.is_allowed_delete() %} - {% else %} - {% endif %} {% else %} - + - - + + {% endif %} diff --git a/app/templates/domain_add.html b/app/templates/domain_add.html index 8f74ac9..96daec5 100644 --- a/app/templates/domain_add.html +++ b/app/templates/domain_add.html @@ -47,6 +47,15 @@ +
    + + +
    diff --git a/app/templates/template.html b/app/templates/template.html new file mode 100644 index 0000000..19c8efc --- /dev/null +++ b/app/templates/template.html @@ -0,0 +1,116 @@ +{% extends "base.html" %} +{% block title %}DNS Control Panel - Templates{% endblock %} + +{% block dashboard_stat %} + +
    +

    + Templates + List +

    + +
    +{% endblock %} +{% block content %} + +
    + {% with errors = get_flashed_messages(category_filter=["error"]) %} {% if errors %} +
    +
    +
    + +

    + Error! +

    +
    + x +
      + {%- for msg in errors %} +
    • {{ msg }}
    • {% endfor -%} +
    +
    +
    +
    +
    +{% endif %} {% endwith %} +
    +
    +
    +
    +

    Templates

    +
    + +
    + + + + + + + + + + + {% for template in templates %} + + + + + + + {% endfor %} + +
    NameDescriptionNumber of RecordsAction
    + {{ template.name }} + + {{ template.description }} + + {{ template.records|count }} + + + + + + + +
    +
    + +
    + +
    + +
    + +
    + +{% endblock %} +{% block extrascripts %} + +{% endblock %} +{% block modals %} +{% endblock %} diff --git a/app/templates/template_add.html b/app/templates/template_add.html new file mode 100644 index 0000000..772c204 --- /dev/null +++ b/app/templates/template_add.html @@ -0,0 +1,104 @@ +{% extends "base.html" %} +{% block title %}DNS Control Panel - Create Template{% endblock %} + +{% block dashboard_stat %} + +
    +

    + Template + Create +

    + +
    +{% endblock %} + +{% block content %} +
    +{% with errors = get_flashed_messages(category_filter=["error"]) %} {% +if errors %} +
    +
    +
    + +

    + Error! +

    +
    + x +
      + {%- for msg in errors %} +
    • {{ msg }}
    • {% endfor -%} +
    +
    +
    +
    +
    +{% endif %} {% endwith %} + +
    +
    +
    +
    +

    Create new template

    +
    + + +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +

    Help with creating a new template

    +
    +
    +
    +
    Template name
    +
    Enter your template name, this is the name of the template that + will be shown to users. The name should not have any spaces but + can have symbols.
    +
    Template description
    +
    Enter your template description, this is to help better + identify the template.
    +
    +
    +
    +
    +
    +
    +{% endblock %} +{% block extrascripts %} + +{% endblock %} diff --git a/app/templates/template_edit.html b/app/templates/template_edit.html new file mode 100644 index 0000000..3445eb0 --- /dev/null +++ b/app/templates/template_edit.html @@ -0,0 +1,415 @@ +{% extends "base.html" %} +{% block title %}DNS Control Panel - Edit Template{% endblock %} + +{% block dashboard_stat %} +
    +

    + Edit template {{ template }} +

    + +
    +{% endblock %} + +{% block content %} +
    +
    +
    +
    +
    +

    Manage Template Records for {{ template }}

    +
    +
    + + +
    +
    + + + + + + + + + + + + + + + {% for record in records %} + + + + + + + + + + + + {% endfor %} + +
    NameTypeStatusTTLDataEditDeleteID
    + {{ record.name }} + + {{ record.type }} + + {{ record.status }} + + {{ record.ttl }} + + {{ record.data }} + + + + + + {{ record.id }} +
    +
    +
    +
    +
    +
    +{% endblock %} +{% block extrascripts %} + +{% endblock %} +{% block modals %} + + + +{% endblock %} diff --git a/app/views.py b/app/views.py index 82448e4..fea9d4f 100644 --- a/app/views.py +++ b/app/views.py @@ -11,17 +11,21 @@ from io import BytesIO import jinja2 import qrcode as qrc import qrcode.image.svg as qrc_svg -from flask import g, request, make_response, jsonify, render_template, session, redirect, url_for, send_from_directory, abort +from flask import g, request, make_response, jsonify, render_template, session, redirect, url_for, send_from_directory, abort, flash from flask_login import login_user, logout_user, current_user, login_required from werkzeug import secure_filename from werkzeug.security import gen_salt -from .models import User, Domain, Record, Server, History, Anonymous, Setting, DomainSetting +from .models import User, Domain, Record, Server, History, Anonymous, Setting, DomainSetting, DomainTemplate, DomainTemplateRecord from app import app, login_manager, github, google from app.lib import utils +from app.lib.log import logger from app.decorators import admin_role_required, can_access_domain +# LOG CONFIG +logging = logger('MODEL', app.config['LOG_LEVEL'], app.config['LOG_FILE']).config() +# FILTERS jinja2.filters.FILTERS['display_record_name'] = utils.display_record_name jinja2.filters.FILTERS['display_master_name'] = utils.display_master_name jinja2.filters.FILTERS['display_second_to_time'] = utils.display_time @@ -436,10 +440,13 @@ def domain(domain_name): @login_required @admin_role_required def domain_add(): + templates = DomainTemplate.query.all() if request.method == 'POST': try: domain_name = request.form.getlist('domain_name')[0] domain_type = request.form.getlist('radio_type')[0] + domain_template = request.form.getlist('domain_template')[0] + logging.info("Selected template ==== {0}".format(domain_template)) soa_edit_api = request.form.getlist('radio_type_soa_edit_api')[0] if ' ' in domain_name or not domain_name or not domain_type: @@ -457,12 +464,28 @@ def domain_add(): if result['status'] == 'ok': history = History(msg='Add domain %s' % domain_name, detail=str({'domain_type': domain_type, 'domain_master_ips': domain_master_ips}), created_by=current_user.username) history.add() + if domain_template != '0': + template = DomainTemplate.query.filter(DomainTemplate.id == domain_template).first() + template_records = DomainTemplateRecord.query.filter(DomainTemplateRecord.template_id == domain_template).all() + record_data = [] + for template_record in template_records: + record_row = {'record_data': template_record.data, 'record_name': template_record.name, 'record_status': template_record.status, 'record_ttl': template_record.ttl, 'record_type': template_record.type} + record_data.append(record_row) + r = Record() + result = r.apply(domain_name, record_data) + if result['status'] == 'ok': + history = History(msg='Applying template %s to %s, created records successfully.' % (template.name, domain_name), detail=str(result), created_by=current_user.username) + history.add() + else: + history = History(msg='Applying template %s to %s, FAILED to created records.' % (template.name, domain_name), detail=str(result), created_by=current_user.username) + history.add() return redirect(url_for('dashboard')) else: return render_template('errors/400.html', msg=result['msg']), 400 except: + logging.error(traceback.print_exc()) return redirect(url_for('error', code=500)) - return render_template('domain_add.html') + return render_template('domain_add.html', templates=templates) @app.route('/admin/domain//delete', methods=['GET']) @@ -534,7 +557,7 @@ def record_apply(domain_name): else: return make_response(jsonify( result ), 400) except: - traceback.print_exc() + logging.error(traceback.print_exc()) return make_response(jsonify( {'status': 'error', 'msg': 'Error when applying new changes'} ), 500) @@ -557,7 +580,7 @@ def record_update(domain_name): else: return make_response(jsonify( {'status': 'error', 'msg': result['msg']} ), 500) except: - traceback.print_exc() + logging.error(traceback.print_exc()) return make_response(jsonify( {'status': 'error', 'msg': 'Error when applying new changes'} ), 500) @@ -571,7 +594,7 @@ def record_delete(domain_name, record_name, record_type): if result['status'] == 'error': print(result['msg']) except: - traceback.print_exc() + logging.error(traceback.print_exc()) return redirect(url_for('error', code=500)), 500 return redirect(url_for('domain', domain_name=domain_name)) @@ -621,10 +644,182 @@ def admin_setdomainsetting(domain_name): else: return make_response(jsonify( { 'status': 'error', 'msg': 'Action not supported.' } ), 400) except: - traceback.print_exc() + logging.error(traceback.print_exc()) return make_response(jsonify( { 'status': 'error', 'msg': 'There is something wrong, please contact Administrator.' } ), 400) +@app.route('/templates', methods=['GET', 'POST']) +@app.route('/templates/list', methods=['GET', 'POST']) +@login_required +@admin_role_required +def templates(): + templates = DomainTemplate.query.all() + return render_template('template.html', templates=templates) + + +@app.route('/template/create', methods=['GET', 'POST']) +@login_required +@admin_role_required +def create_template(): + if request.method == 'GET': + return render_template('template_add.html') + if request.method == 'POST': + try: + name = request.form.getlist('name')[0] + description = request.form.getlist('description')[0] + + if ' ' in name or not name or not type: + flash("Please correct your input", 'error') + return redirect(url_for('create_template')) + + if DomainTemplate.query.filter(DomainTemplate.name == name).first(): + flash("A template with the name %s already exists!" % name, 'error') + return redirect(url_for('create_template')) + t = DomainTemplate(name=name, description=description) + result = t.create() + if result['status'] == 'ok': + history = History(msg='Add domain template %s' % name, detail=str({'name': name, 'description': description}), created_by=current_user.username) + history.add() + return redirect(url_for('templates')) + else: + flash(result['msg'], 'error') + return redirect(url_for('create_template')) + except: + logging.error(traceback.print_exc()) + return redirect(url_for('error', code=500)) + return redirect(url_for('templates')) + + +@app.route('/template/createfromzone', methods=['POST']) +@login_required +@admin_role_required +def create_template_from_zone(): + try: + jdata = request.json + name = jdata['name'] + description = jdata['description'] + domain_name = jdata['domain'] + + if ' ' in name or not name or not type: + return make_response(jsonify({'status': 'error', 'msg': 'Please correct template name'}), 500) + + if DomainTemplate.query.filter(DomainTemplate.name == name).first(): + return make_response(jsonify({'status': 'error', 'msg': 'A template with the name %s already exists!' % name}), 500) + + t = DomainTemplate(name=name, description=description) + result = t.create() + if result['status'] == 'ok': + history = History(msg='Add domain template %s' % name, detail=str({'name': name, 'description': description}), created_by=current_user.username) + history.add() + + records = [] + r = Record() + domain = Domain.query.filter(Domain.name == domain_name).first() + if domain: + # query domain info from PowerDNS API + zone_info = r.get_record_data(domain.name) + if zone_info: + jrecords = zone_info['records'] + + if NEW_SCHEMA: + for jr in jrecords: + name = '@' if jr['name'] == domain_name else jr['name'] + if jr['type'] in app.config['RECORDS_ALLOW_EDIT']: + for subrecord in jr['records']: + + record = DomainTemplateRecord(name=name, type=jr['type'], status=True if subrecord['disabled'] else False, ttl=jr['ttl'], data=subrecord['content']) + records.append(record) + else: + for jr in jrecords: + if jr['type'] in app.config['RECORDS_ALLOW_EDIT']: + record = DomainTemplateRecord(name=name, type=jr['type'], status=True if jr['disabled'] else False, ttl=jr['ttl'], data=jr['content']) + records.append(record) + result_records = t.replace_records(records) + + if result_records['status'] == 'ok': + return make_response(jsonify({'status': 'ok', 'msg': result['msg']}), 200) + else: + result = t.delete_template() + return make_response(jsonify({'status': 'error', 'msg': result_records['msg']}), 500) + + else: + return make_response(jsonify({'status': 'error', 'msg': result['msg']}), 500) + except: + logging.error(traceback.print_exc()) + return make_response(jsonify({'status': 'error', 'msg': 'Error when applying new changes'}), 500) + + +@app.route('/template//edit', methods=['GET']) +@login_required +@admin_role_required +def edit_template(template): + try: + t = DomainTemplate.query.filter(DomainTemplate.name == template).first() + if t is not None: + records = [] + for jr in t.records: + if jr.type in app.config['RECORDS_ALLOW_EDIT']: + record = DomainTemplateRecord(name=jr.name, type=jr.type, status='Disabled' if jr.status else 'Active', ttl=jr.ttl, data=jr.data) + records.append(record) + + return render_template('template_edit.html', template=t.name, records=records, editable_records=app.config['RECORDS_ALLOW_EDIT']) + except: + logging.error(traceback.print_exc()) + return redirect(url_for('error', code=500)) + return redirect(url_for('templates')) + + +@app.route('/template//apply', methods=['POST'], strict_slashes=False) +@login_required +def apply_records(template): + try: + jdata = request.json + records = [] + + for j in jdata: + name = '@' if j['record_name'] in ['@', ''] else j['record_name'] + type = j['record_type'] + data = j['record_data'] + disabled = True if j['record_status'] == 'Disabled' else False + ttl = int(j['record_ttl']) if j['record_ttl'] else 3600 + + dtr = DomainTemplateRecord(name=name, type=type, data=data, status=disabled, ttl=ttl) + records.append(dtr) + + t = DomainTemplate.query.filter(DomainTemplate.name == template).first() + result = t.replace_records(records) + if result['status'] == 'ok': + history = History(msg='Apply domain template record changes to domain template %s' % template, detail=str(jdata), created_by=current_user.username) + history.add() + return make_response(jsonify(result), 200) + else: + return make_response(jsonify(result), 400) + except: + logging.error(traceback.print_exc()) + return make_response(jsonify({'status': 'error', 'msg': 'Error when applying new changes'}), 500) + + +@app.route('/template//delete', methods=['GET']) +@login_required +@admin_role_required +def delete_template(template): + try: + t = DomainTemplate.query.filter(DomainTemplate.name == template).first() + if t is not None: + result = t.delete_template() + if result['status'] == 'ok': + history = History(msg='Deleted domain template %s' % template, detail=str({'name': template}), created_by=current_user.username) + history.add() + return redirect(url_for('templates')) + else: + flash(result['msg'], 'error') + return redirect(url_for('templates')) + except: + logging.error(traceback.print_exc()) + return redirect(url_for('error', code=500)) + return redirect(url_for('templates')) + + @app.route('/admin', methods=['GET', 'POST']) @login_required @admin_role_required @@ -718,7 +913,7 @@ def admin_manageuser(): else: return make_response(jsonify( { 'status': 'error', 'msg': 'Action not supported.' } ), 400) except: - traceback.print_exc() + logging.error(traceback.print_exc()) return make_response(jsonify( { 'status': 'error', 'msg': 'There is something wrong, please contact Administrator.' } ), 400) @@ -883,7 +1078,7 @@ def dyndns_update(): r = Record() r.name = hostname # check if the user requested record exists within this domain - if r.exists(domain.name) and r.is_allowed: + if r.exists(domain.name) and r.is_allowed_edit(): if r.data == myip: # record content did not change, return 'nochg' history = History(msg="DynDNS update: attempted update of %s but record did not change" % hostname, created_by=current_user.username) @@ -898,7 +1093,7 @@ def dyndns_update(): return render_template('dyndns.html', response='good'), 200 else: return render_template('dyndns.html', response='911'), 200 - elif r.is_allowed: + elif r.is_allowed_edit(): ondemand_creation = DomainSetting.query.filter(DomainSetting.domain == domain).filter(DomainSetting.setting == 'create_via_dyndns').first() if (ondemand_creation != None) and (strtobool(ondemand_creation.value) == True): record = Record(name=hostname,type='A',data=myip,status=False,ttl=3600) diff --git a/create_db.py b/create_db.py index 2a70f96..952f04e 100755 --- a/create_db.py +++ b/create_db.py @@ -9,7 +9,7 @@ from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from app import db -from app.models import Role, Setting +from app.models import Role, Setting, DomainTemplate def start(): @@ -69,6 +69,23 @@ def init_settings(db, setting_names): for setting in settings: db.session.add(setting) + +def init_domain_templates(db, domain_template_names): + + # Get key name of data + name_of_domain_templates = map(lambda r: r.name, domain_template_names) + + # Query to get current data + rows = db.session.query(DomainTemplate).filter(DomainTemplate.name.in_(name_of_domain_templates)).all() + + # Check which data that need to insert + name_of_rows = map(lambda r: r.name, rows) + domain_templates = filter(lambda r: r.name not in name_of_rows, domain_template_names) + + # Insert data + for domain_template in domain_templates: + db.session.add(domain_template) + def init_records(): # Create initial user roles and turn off maintenance mode init_roles(db, [ @@ -84,7 +101,12 @@ def init_records(): Setting('default_domain_table_size', '10'), Setting('auto_ptr','False') ]) - + # TODO: add sample records to sample templates + init_domain_templates(db, [ + DomainTemplate('basic_template_1', 'Basic Template #1'), + DomainTemplate('basic_template_2', 'Basic Template #2'), + DomainTemplate('basic_template_3', 'Basic Template #3') + ]) db_commit = db.session.commit() commit_version_control(db_commit)