def check_templates(): from ..page.models import Template from ..auth.models import User from flask import current_app templates = Template.query.all() template_dir = current_app.config['ROOT_PATH'] + '/' + 'templates' if not os.path.exists(template_dir): os.mkdir(template_dir) names = [t.name for t in templates] for t in os.listdir(template_dir): if not t in names: temp = Template() temp.name = t temp.filename = os.path.join(template_dir,t) temp.body = open(os.path.join(template_dir,t),'r').read() temp.save()
def check_templates(): from page.models import Template from auth.models import User from app import app from blog.models import Article from .utils import fix_unicode templates = Template.query.all() template_dir = app.config['ROOT_PATH'] + '/' + 'templates' if not os.path.exists(template_dir): os.mkdir(template_dir) names = [t.name for t in templates] for t in os.listdir(template_dir): if not t in names: temp = Template() temp.name = t temp.location = os.path.join(template_dir,t) temp.save()
def check_templates(): from page.models import Template from auth.models import User from app import app from blog.models import Article from .utils import fix_unicode templates = Template.query.all() template_dir = app.config['ROOT_PATH'] + '/' + 'templates' if not os.path.exists(template_dir): os.mkdir(template_dir) names = [t.name for t in templates] for t in os.listdir(template_dir): if not t in names: temp = Template() temp.name = t temp.location = os.path.join(template_dir, t) temp.save()