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)
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)
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)
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)
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'))
def article(id): article = read.blog_article_find(id, None)[0] return render_template('/tutorial/article.html', article=article, id=id)
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())
def blog_qpredict(id): questions = Qpredict.Qpredict(service.blog_qpredict(id)) return render_template('/blog/qpredict.html', **locals())
def blog_newsfeed(): if 'username' not in session.keys(): return redirect('/auth/login/') articles = service.blog_newsfeed() return render_template('/blog/newsfeed.html', **locals())
def blog_profile(id): user, articles, subscribed, own = service.blog_profile(id) return render_template('/blog/profile.html', **locals())
def blog_classify(): if request.method == 'POST': id = request.form['id'] return service.blog_classify(id)
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)