def topic(tid, page): if not check_login(): return redirect(url_for("general.logout")) userid = session['userid'] #Fetch topic PER_PAGE = 40 nt = nordict.Nordict() path = "public/forums/topic/{0}".format(tid) getvar = {'offset': (page-1)*PER_PAGE, 'limit': PER_PAGE, 'combineTopic': "true", 'registerRead': 'true'} call = nt.call_api(session['token'], path, getvar=getvar).json() #Pagination from nordicnew import Pagination count = call['data']['topic']['replies'] pagination = Pagination(page, PER_PAGE, count) return render_template('forum/topic.html', topictitle = call['data']['topic']['subject'], locked = call['data']['topic']['locked'], posts = call['data']['posts'], replies = call['data']['topic']['replies'], page = page, tid = tid, userid = userid, pagination = pagination )
def index(page): if not check_login(): return redirect(url_for("general.logout")) from nordicnew import Pagination PER_PAGE = 40 count = 10000 pagination = Pagination(page, PER_PAGE, count) topiclimit = 40 path = "public/forums/topics/last" getvar = {'offset': (page-1)*PER_PAGE, 'limit': PER_PAGE} call = nt.call_api(session['token'], path, getvar=getvar).json() pmpath = "/public/privatemessages/inbox/new" pmamount = nt.call_api(session['token'], pmpath).json() #POLL poll = get_combined_poll() news = get_latest_news() #Render template return render_template('general/index.html', topics=call['data'], page = page, topiclimit = topiclimit, poll=poll, news=news, username=session['username'], pagination=pagination, pmamount=pmamount['amount'] )
def forum(fid, page): if not check_login(): return redirect(url_for("general.logout")) from nordicnew import Pagination PER_PAGE = 40 #API Call nt = nordict.Nordict() path = "public/forums/{0}".format(fid) getvar = {'offset': (page-1)*PER_PAGE, 'limit': PER_PAGE} call = nt.call_api(session['token'], path, getvar=getvar).json() count = 10000 pagination = Pagination(page, PER_PAGE, count) topiclimit = 40 #Render template return render_template('forum/forumlist.html', topics=call['data'], page = page, pagination = pagination, topiclimit = 40, subforum = call['data'][0]['forumname'] )
def index(): if not check_login(): return redirect(url_for("general.logout")) nt = nordict.Nordict() path = "public/forums" call = nt.call_api(session['token'], path).json() #Render template return render_template('forum/forum.html', forums = call['data'] )
def get_user(userid): if not check_login(): return "False" token = session['token'] nt = nordict.Nordict() path = "public/user/{0}".format(userid) call = nt.call_api(session['token'], path) return render_template('ajax/user.html', data=call.json()['data'])
def ajax_post(pid, formatted): if not check_login(): return "False" token = session['token'] nt = nordict.Nordict() path = "public/forums/post/{0}".format(pid) call = nt.call_api(token, path).json() if formatted: return render_template('ajax/singlepost.html', post = call['data']) else: return call['data']['body']
def ajax_poll_vote(): if not check_login(): return "False" token = session['token'] nt = nordict.Nordict() pollid = request.form['pollid'] option = request.form['poll'] postvar = {'option': option} path = "public/polls/{0}/answer".format(pollid) call = nt.call_api(token, path, postvar).json() return "True"
def ajax_edit(pid): if not check_login(): return "False" token = session['token'] nt = nordict.Nordict() message = request.form['message'] postvar = {'message': message} path = "public/forums/post/{0}/edit".format(pid) call = nt.call_api(token, path, postvar).json() from postmarkup import render_bbcode return render_bbcode(call['data']['body'])
def reply(): if not check_login(): return "False" token = session['token'] tid = request.form['tid'] message = request.form['editor'] nt = nordict.Nordict() path = "public/forums/topic/{0}".format(tid) postvar = {'topicid': tid, 'message': message} try: call = nt.call_api(token, path, postvar=postvar) return call.text except: return "False"
def create(): if not check_login(): return redirect(url_for("general.logout")) if request.method == 'GET': nt = nordict.Nordict() path = "public/forums" call = nt.call_api(session['token'], path).json() return render_template('forum/create.html', forums=call['data']) else: token = session['token'] nt = nordict.Nordict() forumid = request.form['forumid'] subject = request.form['subject'] message = request.form['message'] path = "public/forums/{0}".format(forumid) postvar = {'subject': subject, 'message': message} call = nt.call_api(token, path, postvar=postvar).json() return redirect(url_for('forum.topic', tid=call['data']['topicid'], page=1))