示例#1
0
文件: forum.py 项目: simontoft/newnt
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
	)
示例#2
0
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']
	)
示例#3
0
文件: forum.py 项目: simontoft/newnt
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']
	)
示例#4
0
文件: forum.py 项目: simontoft/newnt
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']
	)
示例#5
0
文件: ajax.py 项目: simontoft/newnt
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'])
示例#6
0
文件: ajax.py 项目: simontoft/newnt
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']
示例#7
0
文件: ajax.py 项目: simontoft/newnt
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"
示例#8
0
文件: ajax.py 项目: simontoft/newnt
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'])
示例#9
0
文件: ajax.py 项目: simontoft/newnt
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"
示例#10
0
文件: forum.py 项目: simontoft/newnt
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))