Ejemplo n.º 1
0
def get_post_info(post_details, related):

	info = {}

	info['date']			= dateformat.format(post_details.date, settings.DATETIME_FORMAT)
	info['dislikes']		= post_details.dislikes

	if find_list(related, 'forum'):
		info['forum']	= get_forum_info(post_details.forum)
	else:
		info['forum']	= post_details.forum.short_name

	info['id']				= post_details.id
	info['isApproved']		= post_details.isApproved
	info['isDeleted']		= post_details.isDeleted
	info['isEdited']		= post_details.isEdited
	info['isHighlighted']	= post_details.isHighlighted
	info['isSpam']			= post_details.isSpam
	info['likes']			= post_details.likes
	info['message']			= post_details.message
	if post_details.parent != 0:
		info['parent']		= post_details.parent
		#logger.error("post par det")
		#logger.error(post.parent)
	info['points']			= post_details.points

	if find_list(related, 'thread'):
		info['thread']	= get_thread_info(post_details.thread, [])
	else:
		info['thread']	= post_details.thread.id

	if find_list(related, 'user'):
		info['user']	= get_user_info(post_details.user)
	else:
		info['user']	= post_details.user.email



	return info
Ejemplo n.º 2
0
def forum_listThreads(request):

	main_response = {'code':0}
	
	if request.method == 'GET':
		since = request.GET['since']
		order = request.GET['order']
		forum_name = request.GET['forum']
		related = request.GET.getlist('related')

		if order == 'desc':
			sort_order = '-date'
		else:
			sort_order = 'date'

		thread_list = []

		forum = Forum.objects.get(short_name = forum_name)
		thread_list = list(Thread.objects.values_list('id', flat=True).filter(forum=forum, date__gt=since).order_by(sort_order))

		out_list = []


		for out_thread_id in thread_list:
			out_thread = Thread.objects.get(id = out_thread_id)
			out_list.append(get_thread_info(out_thread, related))

		json_response = out_list



	main_response['response'] = json_response

	response = JsonResponse(main_response)

	return response