예제 #1
0
def articles():
    articles = read.blog_article_find(None, None)

    if articles is not None:
        return render_template('/tutorial/articles.html', articles=articles)
    else:
        msg = 'No Articles Found'
        return render_template('/tutorial/articles.html', msg=msg)
예제 #2
0
def dashboard():
    articles = read.blog_article_find(None, session['username'])

    if articles is not None:
        return render_template('/tutorial/dashboard.html', articles=articles)
    else:
        msg = 'You Do Not Have Any Articles'
        return render_template('/tutorial/dashboard.html', msg=msg)
예제 #3
0
def edit_article(id):
    articles = db.article.find_one({"_id": ObjectId(id)})
    #articles = read.blog_article_find(id, None)
    form = ArticleForm(request.form)

    form.title.data = articles['title']
    form.body.data = articles['body']

    if request.method == 'POST' and form.validate():
        title = request.form['title']
        body = request.form['body']
        articles['title'] = title
        articles['body'] = body
        read.blog_article_save(articles)

        flash('Article Updated', 'success')
        return redirect(url_for('blog_write.dashboard'))
    return render_template('/tutorial/edit_article.html', form=form)
예제 #4
0
def add_article():
    form = ArticleForm(request.form)
    if request.method == 'POST' and form.validate():
        concrete_strategy = BlogArticleConcreteStrategy()
        articles = Context(concrete_strategy)
        articles.context_interface()
        articles.setTitle(form.title.data)
        articles.setBody(form.body.data)
        articles.setAuthor(session['username'])

        # title = form.title.data
        # body = form.body.data
        # author = session['username']

        #article_id = db.article.insert({"title": articles.getTitle(), "author": articles.getAuthor(), "body": articles.getBody(), "date": str(now)})
        article_id = read.blog_artcile_insert(articles)
        article_id = str(article_id)
        flash('Article Created', 'success')
        Writer.Writer(session['username']).notify_observer(article_id)
        return redirect('/article/' + article_id + '/')

    return render_template('/tutorial/add_article.html', form=form)
예제 #5
0
def delete_article(id):
    #db.article.remove({"_id": ObjectId(id)})
    read.blog_article_remove(id)
    flash('Article Deleted', 'success')
    return redirect(url_for('blog_write.dashboard'))
예제 #6
0
def article(id):
    article = read.blog_article_find(id, None)[0]
    return render_template('/tutorial/article.html', article=article, id=id)
예제 #7
0
def blog_search():
    if request.method == 'POST':
        data, articles = service.blog_search(True, request.form)
    else:
        data, articles = service.blog_search(False, None)
    return render_template('/blog/search.html', **locals())
예제 #8
0
def blog_qpredict(id):
    questions = Qpredict.Qpredict(service.blog_qpredict(id))
    return render_template('/blog/qpredict.html', **locals())
예제 #9
0
def blog_newsfeed():
    if 'username' not in session.keys():
        return redirect('/auth/login/')
    articles = service.blog_newsfeed()
    return render_template('/blog/newsfeed.html', **locals())
예제 #10
0
def blog_profile(id):
    user, articles, subscribed, own = service.blog_profile(id)
    return render_template('/blog/profile.html', **locals())
예제 #11
0
파일: Read.py 프로젝트: zaoad/CS-classroom
def blog_classify():
    if request.method == 'POST':
        id = request.form['id']
        return service.blog_classify(id)
예제 #12
0
def article(id):
    #articles = db.article.find({"_id": ObjectId(id)})
    article = read.blog_article_find(id, None)[0]
    print(articles)
    return render_template('/tutorial/article.html', article=article, id=id)