Beispiel #1
0
	def get(self):
		user = users.get_current_user()
		user_name=ShowEntry.get_user_name(user)

		bbs_list=[]

		if(user):
			user_id=user.user_id()
			
			bookmark_bbs_list=ApiBookmark.bookmark_get_bbs_list(self,user_id)
			rental_bbs_list=ApiUser.user_get_bbs_list(self,user_id)
			
			if(rental_bbs_list):
				bbs_list.extend(rental_bbs_list)
			if(bookmark_bbs_list):
				bbs_list.extend(bookmark_bbs_list)

			sample_bbs={
			"title":"サンプルお絵描き掲示板",
			"key":MappingId.mapping("sample")
			}
			bbs_list.append(sample_bbs)

		temp_key=self.request.get("temp_key")

		args=None
		if(temp_key):
			temp=db.get(temp_key)
			if(temp.args):
				args=temp.args

		target_bbs=self.get_target_bbs(args);
		if(target_bbs):
			bbs_list=target_bbs

		template_values={
		'host':"./",
		'is_iphone':CssDesign.is_iphone(self),
		'is_tablet':CssDesign.is_tablet(self),
		'is_english':CssDesign.is_english(self),
		'temp_key':temp_key,
		'redirect_url':self.request.path+"?temp_key="+temp_key,
		'user':user,
		'bbs_list':bbs_list,
		'args':args,
		'user_name':user_name
		}
		render=template_select.render("/html/upload_temp.html", template_values)
		self.response.out.write(render)
Beispiel #2
0
	def get(self):
		SetUtf8.set()
		
		#Query文字列を取得
		query=self.request.query_string;

		#RESULT
		result_dic={}
		request_no=0
		
		#APIリクエストに分解
		api_list=query.split(":")
		for api in api_list:
			#APIの引数を取得
			args=api.split("&")
			
			#引数をDictionaryに分解
			api_args={}
			for arg in args:
				params=arg.split("=")
				if(len(params)>=2):
					api_args[params[0]]=params[1]
			
			#呼び出しAPIのクラス名を決定
			if(api_args.has_key("class")):
				#ダミーリクエストハンドラーを作成
				req=HttpHandlerHook()
				req.request.args=api_args
				req.request.host=self.request.host

				#API呼び出し
				dic=None
				if(api_args["class"]=="api_bookmark"):
					dic=ApiBookmark.get_core(req)
				if(api_args["class"]=="api_user"):
					dic=ApiUser.get_core(req)
				if(api_args["class"]=="api_feed"):
					dic=ApiFeed.get_core(req)
				
				if(dic==None):
					logging.error("UnknownClass:"+api_args["class"])
				else:
					result_dic["request"+str(request_no)]=dic
					request_no=request_no+1
	
		ApiObject.write_json_core(self,result_dic)
Beispiel #3
0
	def _user_page(self,user,user_id,page,request_page_mode,redirect_api,contents_only):
		illust_enable=False
		submit_illust_exist=True
		submit_moper_exist=True
		bookmark_illust_exist=True
		thread_list=None

		#プロフィール
		bookmark=None
		if(user_id):
			bookmark=ApiObject.get_bookmark_of_user_id(user_id)

		#イラストの存在を検出
		submit_illust_count=ApiUser.user_get_is_submit_thread_exist(self,user_id,bookmark)
		submit_moper_count=ApiUser.user_get_is_submit_moper_exist(self,user_id,bookmark)
		bookmark_illust_count=ApiBookmark.bookmark_get_is_bookmark_thread_exist(self,user_id,bookmark)
		if(bookmark_illust_count==0):
			bookmark_illust_exist=False
		if(submit_illust_count==0):
			submit_illust_exist=False
		if(submit_moper_count==0):
			submit_moper_exist=False

		#マイユーザか
		view_mode=1
		if(user):
			if(user_id==user.user_id()):
				view_mode=0

		#管理モード
		if(self.request.get("admin")):
			if(OwnerCheck.is_admin(user)):
				view_mode=0

		#タブ
		tab=Pinterest._decide_default_tab(self,bookmark_illust_exist,submit_illust_exist,submit_moper_exist,view_mode,bookmark,user,request_page_mode)

		#フィード数の消化
		new_feed_count=Pinterest._get_new_feed_count(user,view_mode,bookmark)
		new_my_feed_count=Pinterest._get_new_my_feed_count(user,view_mode,bookmark)
		if(tab=="feed"):
			bookmark=Pinterest._consume_feed(user,view_mode,bookmark)

		#プロフィールを編集
		edit_profile=Pinterest.get_profile_for_edit(bookmark,view_mode)

		#編集モードかどうか
		edit_mode=0
		if(self.request.get("edit")):
			edit_mode=int(self.request.get("edit"))

		bookmark_bbs_list=None
		rental_bbs_list=None
		bookmark_mute_bbs_list=None
		if(tab=="bbs"):
			thread_list=None
			illust_enable=False
			bookmark_bbs_list=ApiBookmark.bookmark_get_bbs_list(self,user_id)
			bookmark_mute_bbs_list=ApiBookmark.bookmark_get_mute_bbs_list(self,user_id)
			rental_bbs_list=ApiUser.user_get_bbs_list(self,user_id)
		
		timeline=None
		timeline_unit=0
		use_masonry=True
		is_timeline_enable=0
		infinite_scroll_selecter=".item"
		if(tab=="feed" or tab=="timeline"):
			thread_list=None
			is_timeline_enable=1
			illust_enable=False
			if(tab=="feed" and not view_mode):
				timeline=ApiUser.user_get_home_timeline(self,user_id)
			else:
				timeline=ApiUser.user_get_timeline(self,user_id)
			timeline_unit=len(timeline)
			use_masonry=False
			infinite_scroll_selecter=".feed"
	
		only_one_page=False
		if(tab=="bookmark"):
			thread_list=ApiBookmark.bookmark_get_thread_list(self,user_id,bookmark)
			if(bookmark_illust_count<=BbsConst.PINTEREST_MYPAGE_PAGE_UNIT):
				only_one_page=True
	
		if(tab=="submit" or tab=="moper"):
			#イラストが消去されている場合を考慮してスレッドが見つかるまでページを進める
			if(tab=="submit"):
				max_page_src=submit_illust_count
			else:
				max_page_src=submit_moper_count
			max_page=(max_page_src+BbsConst.PINTEREST_MYPAGE_PAGE_UNIT-1)/BbsConst.PINTEREST_MYPAGE_PAGE_UNIT
			thread_list=[]

			original_page=page
			while(page<=max_page):
				limit=BbsConst.PINTEREST_MYPAGE_PAGE_UNIT
				offset=limit*(page-1)
				illust_mode=BbsConst.ILLUSTMODE_ILLUST
				if(tab=="moper"):
					illust_mode=BbsConst.ILLUSTMODE_MOPER
				thread_list=ApiUser.user_get_thread_list_core(self,user_id,offset,limit,illust_mode)
				if(len(thread_list)>=1):
					break
				page=page+1

			if(max_page<=1):
				only_one_page=True

			submit_illust_list=thread_list

			if(len(thread_list)==0 and original_page==1):
				ApiUser.invalidate_thread_count(user_id)	#削除した場合に0になったことを考慮
			
		page_mode="user"
		view_user=ApiUser.user_get_user(self,user_id,bookmark)
		view_user_profile=ApiUser.user_get_profile(self,user_id,bookmark)
		tag_list=None

		next_query="user_id="+user_id+"&amp;tab="+tab+"&amp;edit="+str(edit_mode)
		if(only_one_page):
			next_query=None
		
		only_icon=True
		if(edit_mode):
			only_icon=False

		follow=ApiUser.user_get_follow(self,user_id,only_icon,bookmark)
		follower=ApiUser.user_get_follower(self,user_id,only_icon)
		following=Pinterest.is_following(user,user_id,view_mode)
		age=Pinterest.get_age(bookmark)

		mute_user_list=[]
		mute_bbs_list=[]
		if(bookmark):
			mute_user_list=bookmark.get_mute_user_list()
			mute_bbs_list=bookmark.get_mute_bbs_list()

		#詳細情報の存在
		detail_exist=False
		if(bookmark):
			if(bookmark.sex or age):
				detail_exist=True
			if(bookmark.birthday_month or bookmark.birthday_day or bookmark.birthday_year):
				detail_exist=True
			if(bookmark.homepage or bookmark.mail or bookmark.twitter_id):
				detail_exist=True

		#凍結
		if(bookmark and bookmark.frozen):
			thread_list=None

		#アイコンの規約違反
		violate_icon=False
		if(bookmark):
			if(bookmark.thumbnail_created==2):
				violate_icon=True

		is_flat=True
		is_english=CssDesign.is_english(self)

		template_values = {
			'user': user,
			'thread_list': thread_list,
			'redirect_url': self.request.path,
			'page': page,
			'next_page': page+1,
			'next_query': next_query,
			'page_mode': page_mode,
			'tag': None,
			'view_user': view_user,
			'view_user_profile': view_user_profile,
			'user_id': user_id,
			'follow': follow,
			'follower': follower,
			'muting': mute_user_list,
			'mute_user_list': mute_user_list,
			'mute_bbs_list': mute_bbs_list,
			'view_mode': view_mode,
			'edit_mode': edit_mode,
			'tab': tab,
			'bookmark': bookmark,
			'is_timeline_enable': is_timeline_enable,
			'following':following,
			'bookmark_bbs_list': bookmark_bbs_list,
			'bookmark_mute_bbs_list': bookmark_mute_bbs_list,
			'rental_bbs_list': rental_bbs_list,
			'illust_enable': illust_enable,
			'edit_profile': edit_profile,
			'redirect_url': self.request.path,
			'new_feed_count': new_feed_count,
			'new_my_feed_count': new_my_feed_count,
			'submit_illust_exist': submit_illust_exist,
			'submit_moper_exist': submit_moper_exist,
			'bookmark_illust_exist': bookmark_illust_exist,
			'regist_finish': (request_page_mode==Pinterest.PAGE_MODE_REGIST),
			'redirect_api': redirect_api,
			'age': age,
			'contents_only': contents_only,
			'search': None,
			'top_page': False,
			'detail_exist': detail_exist,
			'is_admin': OwnerCheck.is_admin(user),
			'use_masonry': use_masonry,
			'timeline': timeline,
			'timeline_unit': timeline_unit,
			'infinite_scroll_selecter': infinite_scroll_selecter,
			'flat_ui': is_flat,
			'violate_icon': violate_icon,
			'is_english': is_english
		}
		Pinterest._render_page(self,template_values)