コード例 #1
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def user_updateProfile():
	con = dbConnector.connect()
	params = request.json

	try:
		helpers.check_params(params, ["about", "user", "name"])
		response = user.updateProfile(con=con, about=params["about"], user=params["user"], name=params["name"])
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	con.close()
	return json.dumps({"code": 0, "response": response})
コード例 #2
0
ファイル: thread.py プロジェクト: MysterySuperhero/subd_tp
def unsubscribe_thread():
	con = dbConnector.connect()

	params = request.json

	try:
		helpers.check_params(params, ["user", "thread"])
		response = thread.unsubscribe(con=con, user=params["user"], thread=params["thread"])
	except Exception, e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
コード例 #3
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def user_unfollow():
	con = dbConnector.connect()
	params = request.json

	try:
		helpers.check_params(params, ["follower", "followee"])
		response = user.unfollow(con=con, follower_email=params["follower"], followee_email=params["followee"])
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})

	con.close()
	return json.dumps({"code": 0, "response": response})
コード例 #4
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def user_details():

	con = dbConnector.connect()
	params = helpers.json_from_get(request)

	try:
		helpers.check_params(params, ["user"])
		userr = user.details(con, params["user"])
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	
	con.close()
	return json.dumps({"code": 0, "response": userr})
コード例 #5
0
ファイル: post.py プロジェクト: MysterySuperhero/subd_tp
def post_vote():
	con = dbConnector.connect()
	params = request.json
	try:
		helpers.check_params(params, ["post", "vote"])
		response = post.vote(con=con, post=params["post"], vote=params["vote"])
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
コード例 #6
0
ファイル: post.py プロジェクト: MysterySuperhero/subd_tp
def post_restore():
	con = dbConnector.connect()
	params = request.json
	try:
		helpers.check_params(params, ["post"])
		response = post.restore_remove(con=con, post=params["post"], isDeleted=0)
		thread.inc_posts(con, params["post"])
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
コード例 #7
0
ファイル: thread.py プロジェクト: MysterySuperhero/subd_tp
def vote_thread():
	con = dbConnector.connect()
	params = request.json

	try:
		helpers.check_params(params, ["vote", "thread"])
		response = thread.vote(con=con, vote=params["vote"], thread=params["thread"])
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 1,
		"response": response})
コード例 #8
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def user_listFollowers():

	con = dbConnector.connect()

	params = helpers.json_from_get(request)

	optional = helpers.get_optional_params(params, ["limit", "order", "since_id"])

	try:
		helpers.check_params(params, ["user"])
		response = user.listFollowers(con, params["user"], optional)
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	con.close()
	return json.dumps({"code": 0, "response": response})
コード例 #9
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def user_listPosts():

	con = dbConnector.connect()

	params = helpers.json_from_get(request)

	optional = helpers.get_optional_params(params, ["limit", "order", "since"])

	try:
		helpers.check_params(params, ["user"])
		response = post.posts_list(con=con, entity="user", params=optional, identifier=params["user"], related=[])
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	con.close()
	return json.dumps({"code": 0, "response": response})
コード例 #10
0
ファイル: post.py プロジェクト: MysterySuperhero/subd_tp
def post_details():
	con = dbConnector.connect()
	params = helpers.json_from_get(request)
	required_data = ["post"]
	related = helpers.related_exists(params)
	try:
		helpers.check_params(params, required_data)
		response = post.details(con, params["post"], related)
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
コード例 #11
0
ファイル: thread.py プロジェクト: MysterySuperhero/subd_tp
def remove_thread():
	con = dbConnector.connect()

	params = request.json

	try:
		helpers.check_params(params, ["thread"])
		response = thread.restore_remove(con, params["thread"], isDeleted=1)
	except Exception as e:
		con.close()
		return ({
			"code": 1,
			"response": (e.message)})

	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
コード例 #12
0
ファイル: user.py プロジェクト: MysterySuperhero/subd_tp
def create_user():

	con = dbConnector.connect()
	params = request.json

	optional = helpers.get_optional_params(params, values=["isAnonymous"])

	try:
		helpers.check_params(params, ["username", "about", "name", "email"])
		userr = user.create(con, params["username"], params["about"], params["name"], params["email"], optional)
	except Exception as e:
		if e.message == "5":
			con.close();
			return json.dumps({"code": 5, "response": (e.message)})
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	con.close()
	return json.dumps({"code": 0, "response": userr})
コード例 #13
0
ファイル: thread.py プロジェクト: MysterySuperhero/subd_tp
def create_thread():
	con = dbConnector.connect();
	params = request.json

	optional = helpers.get_optional_params(params, ["isDeleted"])

	try:
		helpers.check_params(params, ["forum", "title", "isClosed", "user", "date", "message", "slug"])

		response = thread.create(con, params["forum"], params["title"], params["isClosed"], params["user"],
		                         params["date"], params["message"], params["slug"], optional);

	except Exception as e:
		con.close();
		return json.dumps({
			"code": 3,
			"response": (e.message)})

	con.close();
	return json.dumps({
		"code": 0,
		"response": response});
コード例 #14
0
ファイル: post.py プロジェクト: MysterySuperhero/subd_tp
def post_create():
	con = dbConnector.connect()

	params = request.json

	optional = helpers.get_optional_params(
		params,
		["parent",
		 "isApproved",
		 "isHighlighted",
		 "isEdited",
		 "isSpam",
		 "isDeleted"]
	)

	try:
		helpers.check_params(
			params,
			["date",
			 "thread",
			 "message",
			 "user",
			 "forum"]
		)

		response = post.create(con, params["date"], params["thread"], params["message"], params["user"],
		                       params["forum"], optional)

	except Exception as e:
		con.close()
		return json.dumps({
			"code": 3,
			"response": (e.message)})

	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
コード例 #15
0
ファイル: thread.py プロジェクト: MysterySuperhero/subd_tp
def details_thread():
	con = dbConnector.connect()
	params = helpers.json_from_get(request)
	required_data = ["thread"]
	related = helpers.related_exists(params)

	if 'thread' in related:
		con.close()
		return json.dumps({
			"code": 3,
			"response": "error"})
	try:
		helpers.check_params(params, required_data)
		response = thread.details(con, params["thread"], related)
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})