Ejemplo n.º 1
0
	def _create_thread_object_core(req,thread,bbs,only_image_thread):
		if(not thread or not bbs):
			return None
		if(not thread.cached_image_key and only_image_thread):
			return None
		if(bbs.del_flag):
			return None

		disable_news=0
		violate_terms=0
		if(bbs.disable_news):
			disable_news=1
		if(bbs.violate_terms):
			disable_news=1
		if(thread.violate_terms):
			disable_news=1
			violate_terms=1
		if(thread.violate_photo):
			disable_news=1

		#4分未満の画像でアップロードでもない場合は新着に非表示
		#アップロード時は-1、iPhone時は0が入る
		#if(thread.draw_time and thread.draw_time!=-1 and thread.draw_time<240):
		#	disable_news=1

		adult=0
		if(thread.adult):
			adult=thread.adult

		if(bbs.short and bbs.short=="mopersample" and thread.illust_mode!=BbsConst.ILLUSTMODE_MOPER):
			disable_news=1;

		if(req):
			url_header="http://"+req.request.host
		else:
			url_header="."

		thumbnail_url=""
		thumbnail2_url=""
		if(thread.cached_image_key):
			thumbnail_url=url_header+"/thumbnail/"+str(thread.cached_image_key)
			thumbnail2_url=url_header+"/thumbnail2/"+str(thread.cached_image_key)
			if(thread.illust_mode==BbsConst.ILLUSTMODE_MOPER):
				thumbnail_url+=".gif"
				thumbnail2_url=thumbnail_url
			else:
				thumbnail_url+=".jpg"
				thumbnail2_url+=".jpg"

			#サムネイルの作成に失敗している場合は再作成を促す
			if(thread.thumbnail2_version!=BbsConst.THUMBNAIL2_VERSION):
				memcache.delete(BbsConst.OBJECT_CACHE_HEADER+str(thread.key()))

		if(bbs.del_flag):
			thumbnail_url=""
			thumbnail2_url=""

		create_date=TimeProgress.get_date_str(thread.create_date)

		thread_url=url_header+"/"
		if(bbs.short):
			thread_url+=bbs.short+"/"
		else:
			thread_url+="usr/"+str(bbs.key())+"/"
		if(thread.short):
			thread_url+=thread.short+".html"
		else:
			thread_url+=str(thread.key())+".html"

		image_url=""
		if(thread.cached_image_key):
			image_url=url_header+"/img/"+str(thread.cached_image_key)+".jpg"
		#if(bbs.dont_permit_app or 
		if(bbs.del_flag):	#アプリでの画像データの参照を禁止
			image_url=""

		app=0
		if(thread.applause):
			app=thread.applause
		if(bbs.disable_applause):
			app=0

		comment_cnt=0
		if(thread.comment_cnt):
			comment_cnt=thread.comment_cnt

		summary=ApiObject.truncate_html(thread.summary)

		user_id=""
		if(thread.user_id):
			user_id=thread.user_id

		tag_list=[]
		if(thread.tag_list):
			tag_list=thread.tag_list

		event_id=""
		if(thread.event_id):
			event_id=thread.event_id

		bookmark_cnt=0
		if(thread.bookmark_count):
			bookmark_cnt=thread.bookmark_count

		bbs_title=bbs.bbs_name
		bbs_url=ApiObject._get_bbs_url(req,bbs)
		bbs_key=""
		if(bbs):
			bbs_key=str(bbs.key())

		one_dic={"title":thread.title,"summary":summary,"author":thread.author,
		"user_id":user_id,"thumbnail_url":thumbnail_url,"thumbnail2_url":thumbnail2_url,
		"image_url":image_url,"create_date":create_date,"thread_url":thread_url,
		"applause":app,"bookmark":bookmark_cnt,"comment":comment_cnt,"key":str(thread.key()),
		"disable_news":disable_news,"tag":tag_list,"width":thread.width,"height":thread.height,
		"version":thread.thumbnail2_version,"violate_terms":violate_terms,"create_date_original":thread.create_date,
		"bbs_title":bbs_title,"bbs_url":bbs_url,"bbs_key":bbs_key,"adult":adult,"event_id":event_id}
		
		return one_dic