Exemplo n.º 1
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data, username=form.username.data, password=form.password.data)
        StoryService.add_user(user)
        flash(u"注册成功,请登录")
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Exemplo n.º 2
0
def add_story():
    form = StoryForm(request.form)
    if request.method == 'POST' and form.validate_on_submit():

        story = Story(form.title.data, form.content.data)
        try:
            StoryService.add_story(_story=story,
                                   _nick_name=current_user.username,
                                   _category=form.category.data,
                                   _author=current_user.username)
            flash("add success")
            return redirect(url_for('index'))
        except Exception, e:
            return jsonify({"errorMessage": e.message})
Exemplo n.º 3
0
def delete_story(story_id):
    return jsonify(StoryService.delete_story(story_id))
Exemplo n.º 4
0
def show_storys():
    page = request.args.get('page', 1, type=int)
    pagination = StoryService.get_storys(page)
    storys = pagination.items
    return render_template('story_detail.html', storys=storys, pagination=pagination)
Exemplo n.º 5
0
def get_story(story_id):
    return jsonify(StoryService.get_story(story_id))