Exemple #1
0
                pass


class Post(MarkdownContent):
    root_path_config = 'POSTS_DIR'
    rel_path = PostsModule.target_dir


class PostForm(Form):
    title = StringField('Title', validators=[DataRequired()])
    date = StringField('Date', validators=[DataRequired()])
    slug = HiddenField('slug')
    content = TextAreaField('Post content', validators=[DataRequired()])


blueprint.module_obj = PostsModule


@blueprint.route('/')
@register_menu(blueprint, '.posts.content', 'Content', order=1, mode='editor')
def list_posts():
    posts = PostsModule.list_posts()
    return render_template('admin/posts.html', posts=posts)


@blueprint.route('/post/<slug>')
@blueprint.route('/post/newpost')
def edit(slug=None):
    return render_template('admin/edit.html', form=PostForm(), slug=slug)

Exemple #2
0
wtforms_json.init()


class AdminModule(Module):
    display_name = 'General'
    admin_menu_tag = '.admin'
    admin_menu_order = 3
    blueprint = blueprint

    @staticmethod
    def build():
        generated = Module.render('base.html')
        with open(os.path.join(AdminModule.build_dest(), 'index.html'), 'w') as f:
            f.write(generated)

blueprint.module_obj = AdminModule


@blueprint.route('/')
def index():
    return render_template('admin/base.html')


@blueprint.route('/template')
@register_menu(blueprint, '.admin.template', 'Base Template', order=1, mode='designer')
def template():
    return render_template('admin/template.html', form=SimpleContentForm())


@blueprint.route('/template_json', methods=['POST', 'GET'])
def template_json():