def check_id_available(main,app_id): if(app_id=="" or MappingId.key_format_check(app_id)): main.response.out.write(Alert.alert_msg("アプリIDは半角英数である必要があります。",main.request.host)) return False query=AppCode.all().filter("app_id =",app_id) if(query.count()==0): return True main.response.out.write(Alert.alert_msg("このアプリIDは既に使われています。",main.request.host)) return False
def _update(self,event,user,validate_all,is_create): event.title=self.request.get("title") event.summary=self.request.get("summary") if(is_create): event.summary=EscapeComment.escape_br(event.summary) event.summary=EscapeComment.auto_link(event.summary) event.id=self.request.get("id") if(event.id==""): Alert.alert_msg_with_write(self,"IDを入力する必要があります。") return False if(MappingId.key_format_check(event.id)): Alert.alert_msg_with_write(self,"IDは半角英数で16文字以下である必要があります。") return False try: event.start_date=datetime.datetime.strptime(self.request.get("start_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC()) event.end_date=datetime.datetime.strptime(self.request.get("end_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC()) except: Alert.alert_msg_with_write(self,"日付の変換に失敗しました。") return False if(event.end_date <= event.start_date): Alert.alert_msg_with_write(self,"終了日の方が開始日より早くなっています。") return False event_list=Event.all().filter("start_date <=",event.end_date).order("-start_date").fetch(limit=1) #既存のDBが重複していないと仮定すると最新の1つだけチェックすればよい for e in event_list: if(e.id==event.id): continue err=False if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) <= event.start_date): if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.start_date): err=True if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) < event.end_date): if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.end_date): err=True if(err): mes ="今回のイベント "+str(event.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(event.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>"; mes+="他のイベント "+str(e.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(e.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>"; Alert.alert_msg_with_write(self,"日程が他のイベントと重複しています。<br/>"+mes) return False if(event.end_date - event.start_date > datetime.timedelta(days=BbsConst.EVENT_MAX_DAYS)): Alert.alert_msg_with_write(self,"日程が2週間を超えています。") return False if(validate_all): if(event.title=="" or event.id==""): Alert.alert_msg_with_write(self,"タイトルとIDを入力して下さい。") return False if(is_create): event.user_id=user.user_id() if(is_create or event.user_id==user.user_id()): event.author=self.request.get("author") return True
def get(self): SetUtf8.set() is_english=CssDesign.is_english(self) short=self.request.get('id') if(MappingId.key_format_check(short)): txt="IDは半角英数である必要があります。" if(is_english): txt="ID must be 16 characters or less" Alert.alert_msg_with_write(self,txt) return if(MappingId.check_capability(short,"")==0): txt="ID:"+short+"は既に登録されていて利用できません。" if(is_english): txt="ID:"+short+" is not available" Alert.alert_msg_with_write(self,txt) return txt="ID:"+short+"は利用可能です。" if(is_english): txt="ID:"+short+" is available" Alert.alert_msg_with_write(self,txt)
def post(self): if(self.request.get('bbs_title')==""): Alert.alert_msg_with_write(self,"タイトルを入力して下さい。"); return if(self.request.get('bbs_summary')==""): Alert.alert_msg_with_write(self,"概要を入力して下さい。"); return user = users.get_current_user() summary = self.request.get('bbs_summary') if(int(self.request.get('official'))==1): Alert.alert_msg_with_write(self,"オフィシャル掲示板は廃止されました。"); return if (not user): if(int(self.request.get('official'))==0): self.redirect(str(users.create_login_url(""))) return #summary = cgi.escape(summary) compiled_line = re.compile("\r\n|\r|\n") summary = compiled_line.sub(r'<br>', summary) short=self.request.get('short') if(MappingId.key_format_check(short)): Alert.alert_msg_with_write(self,"IDは半角英数である必要があります。") return if(MappingId.check_capability(short,"")==0): Alert.alert_msg_with_write(self,"ID:"+short+"は既に登録されています。") return if(short==""): Alert.alert_msg_with_write(self,"IDを入力する必要があります。") return new_bbs = Bbs() new_bbs.official=int(self.request.get('official')) new_bbs.illust_n=0 new_bbs.bbs_name = cgi.escape(self.request.get('bbs_title')) new_bbs.summary = summary new_bbs.owner = user new_bbs.user_id = user.user_id() new_bbs.bg_color="ffffff" new_bbs.font_color="333333" new_bbs.background_image="" new_bbs.bottom_image="" new_bbs.button_color="999999" new_bbs.button_active_color="777777" new_bbs.bbs_mode=int(self.request.get('mode')) new_bbs.my_homepage="" new_bbs.del_flag=0 new_bbs.enable_continue_draw=0 new_bbs.enable_moper=0 new_bbs.enable_full_flat=1 new_bbs.short=short new_bbs.delete_when_upload_success=1 new_bbs.applause_n=0 new_bbs.illust_n=0 new_bbs.comment_n=0 new_bbs.page_illust_n=5 new_bbs.page_comment_n=10 new_bbs.disable_applause=0 new_bbs.default_order=0 new_bbs.enable_illust_reply=1 new_bbs.enable_illust_reply_continue=0 new_bbs.disable_normal_reply=0 new_bbs.illust_reply_width=400 new_bbs.illust_reply_height=200 new_bbs.side_color="ffffff" new_bbs.side_font_color="333333" new_bbs.side_background_image="" new_bbs.comment_rule_enable=0 new_bbs.comment_rule="" new_bbs.default_canvas_size=0 new_bbs.default_canvas_width=0 new_bbs.default_canvas_height=0 new_bbs.disable_counter=0 new_bbs.disable_draw_time=0 new_bbs.disable_portal_menu=0 new_bbs.in_frame_mode=0; new_bbs.spoit_mode=0; new_bbs.disable_news=0; new_bbs.twitter_id="" new_bbs.twitter_enable=0 new_bbs.twitter_bg_color="ffffff" new_bbs.twitter_font_color="333333" new_bbs.twitter_shell_color="ffffff" new_bbs.twitter_height=300 new_bbs.design_template_no=1 new_bbs.content_bg_color="ffffff" new_bbs.content_font_color="333333" new_bbs.content_width=800 new_bbs.enable_full_comment=1 new_bbs.freearea="" new_bbs.amazon="" new_bbs.freearea_title="" new_bbs.amazon_title="" new_bbs.create_date=datetime.datetime.today() if(memcache.get(BbsConst.OBJECT_NEW_BBS_CREATING_HEADER+short)): Alert.alert_msg_with_write(self,"二重投稿を検知しました。戻ってリロードして下さい。") return memcache.set(BbsConst.OBJECT_NEW_BBS_CREATING_HEADER+short,"creating",BbsConst.NEW_BBS_CACHE_TIME) counter=Counter() counter.init_cnt() counter.put() new_bbs.counter=counter.key() SyncPut.put_sync(new_bbs) self.redirect(str(self.request.get('redirect')))
def post(self): bbs_key=self.request.get("bbs_key") short=self.request.get('short') if(MappingId.key_format_check(short)): Alert.alert_msg_with_write(self,"IDは半角英数である必要があります。") return if(MappingId.check_capability(short,bbs_key)==0): Alert.alert_msg_with_write(self,"ID:"+short+"は既に登録されています。") return bbs=db.get(bbs_key); user = users.get_current_user() if(OwnerCheck.check(bbs,user) and not OwnerCheck.is_admin(user)): Alert.alert_msg_with_write(self,"デザインの編集を行う権限がありません。") return summary = self.request.get('bbs_summary') bg_color=self.format_color(self.request.get('bg_color')) font_color=self.format_color(self.request.get('font_color')) hr_color=self.format_color(self.request.get('hr_color')) content_bg_color=self.format_color(self.request.get('content_bg_color')) content_font_color=self.format_color(self.request.get('content_font_color')) menu_bg_color=self.format_color(self.request.get('menu_bg_color')) menu_font_color=self.format_color(self.request.get('menu_font_color')) side_color=self.format_color(self.request.get('side_color')) side_font_color=self.format_color(self.request.get('side_font_color')) twitter_bg_color=self.format_color(self.request.get('twitter_bg_color')) twitter_font_color=self.format_color(self.request.get('twitter_font_color')) twitter_shell_color=self.format_color(self.request.get('twitter_shell_color')) if(menu_bg_color=="None"): menu_bg_color="ffffff"; if(menu_font_color=="None"): menu_font_color="333333"; if(content_bg_color=="None"): content_bg_color="ffffff"; if(content_font_color=="None"): content_font_color="333333"; if(hr_color=="None"): hr_color="b5ae9d"; if(side_color=="None"): side_color="ffffff"; if(side_font_color=="None"): side_font_color="333333"; if(twitter_bg_color=="None"): twitter_bg_color="ffffff"; if(twitter_font_color=="None"): twitter_font_color="333333"; if(twitter_shell_color=="None"): twitter_shell_color="ffffff"; if re.match('[0-9a-fA-F]{1,6}', bg_color) == None: error_str="bg_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', font_color) == None: error_str="font_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', hr_color) == None: error_str="hr_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', twitter_bg_color) == None: error_str="twitter_bg_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', twitter_font_color) == None: error_str="twitter_font_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', side_color) == None: error_str="side_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', side_font_color) == None: error_str="side_font_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', content_bg_color) == None: error_str="content_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', content_font_color) == None: error_str="content_font_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', menu_bg_color) == None: error_str="menu_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if re.match('[0-9a-fA-F]{1,6}', menu_font_color) == None: error_str="menu_font_color is invalid" self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str)) return if self.request.get('title'): bbs.bbs_name=self.request.get('title') bbs.my_homepage=self.request.get('my_homepage') bbs.background_image=self.request.get('background_image') bbs.side_background_image=self.request.get('side_background_image') bbs.bottom_image=self.request.get('bottom_image') if(bbs.background_image=="None"): bbs.background_image="" if(bbs.side_background_image=="None"): bbs.side_background_image="" if(bbs.bottom_image=="None"): bbs.bottom_image="" bbs.short=short if(bbs.short=="None"): bbs.short="" MappingId.invalidate(short) try: if(self.request.get('default_canvas_width')=="None"): bbs.default_canvas_width=0 else: bbs.default_canvas_width=int(self.request.get('default_canvas_width')) if(self.request.get('default_canvas_height')=="None"): bbs.default_canvas_height=0 else: bbs.default_canvas_height=int(self.request.get('default_canvas_height')) except: bbs.default_canvas_width=0 bbs.default_canvas_height=0 if(self.request.get('content_width')=="None"): bbs.content_width=800 else: try: bbs.content_width=int(self.request.get('content_width')) except: bbs.content_width=800 if(bbs.content_width<800): bbs.content_width=800 if(bbs.content_width>1280): bbs.content_width=1280 try: if(self.request.get('illust_reply_width')=="None"): bbs.illust_reply_width=400 else: bbs.illust_reply_width=int(self.request.get('illust_reply_width')) if(self.request.get('illust_reply_height')=="None"): bbs.illust_reply_height=200 else: bbs.illust_reply_height=int(self.request.get('illust_reply_height')) except: bbs.illust_reply_width=400 bbs.illust_reply_height=200 try: bbs.recent_comment_n=int(self.request.get('recent_comment_n')) except: bbs.recent_comment_n=8 try: bbs.recent_thread_n=int(self.request.get('recent_thread_n')) except: bbs.recent_thread_n=8 try: bbs.font_size=int(self.request.get('font_size')) except: bbs.font_size=0 bbs.disable_counter=int(self.request.get('disable_counter')) bbs.disable_draw_time=int(self.request.get('disable_draw_time')) #bbs.disable_portal_menu=int(self.request.get('disable_portal_menu')) bbs.disable_news=int(self.request.get('disable_news')) bbs.violate_terms=int(self.request.get('violate_terms')) bbs.disable_comment=int(self.request.get('disable_comment')) bbs.disable_tag=int(self.request.get('disable_tag')) bbs.default_order=int(self.request.get('order')) bbs.default_comment_order=int(self.request.get('comment_order')) bbs.comment_hidden_button=int(self.request.get('comment_hidden_button')) bbs.disable_author=int(self.request.get('disable_author')) bbs.disable_title=int(self.request.get('disable_title')) bbs.show_remote_addr_id=int(self.request.get('show_remote_addr_id')) bbs.tweet_disable=int(self.request.get('tweet_disable')) bbs.twitter_enable=int(self.request.get('twitter_enable')) bbs.twitter_id=self.request.get('twitter_id') height=self.request.get('twitter_height') if(height=="None" or height==""): height="300" bbs.twitter_height=int(height) bbs.in_frame_mode=int(self.request.get('in_frame_mode')) bbs.button_color=self.format_color(self.request.get('button_color')) bbs.button_font_color=self.format_color(self.request.get('button_font_color')) bbs.button_border_color=self.format_color(self.request.get('button_border_color')) bbs.button_active_color=self.format_color(self.request.get('button_active_color')) if(bbs.button_color=="None"): bbs.button_color="" if(bbs.button_active_color=="None"): bbs.button_active_color="" if(bbs.button_border_color=="None"): bbs.button_border_color="" if(bbs.button_font_color=="None"): bbs.button_font_color="" bbs.button_color_enable=int(self.request.get("button_color_enable")) amazon=self.request.get('amazon') amazon_title=self.request.get('amazon_title') freearea=self.request.get('freearea') freearea_title=self.request.get('freearea_title') comment_rule=self.request.get('comment_rule') if(amazon=="None"): amazon="" if(amazon_title=="None"): amazon_title="" if(freearea=="None"): freearea="" if(freearea_title=="None"): freearea_title="" if(comment_rule=="None"): comment_rule="" #summary = cgi.escape(summary) compiled_line = re.compile("\r\n|\r|\n") summary = compiled_line.sub(r'<br/>', summary) freearea = compiled_line.sub(r'<br/>', freearea) amazon = compiled_line.sub(r'<br/>', amazon) comment_rule = compiled_line.sub(r'<br/>', comment_rule) bbs.summary = summary bbs.amazon = amazon bbs.freearea = freearea bbs.comment_rule = comment_rule bbs.amazon_title = amazon_title bbs.freearea_title = freearea_title bbs.script_head = self.request.get("script_head") bbs.bg_color=bg_color bbs.font_color=font_color bbs.hr_color=hr_color bbs.content_bg_color=content_bg_color bbs.content_font_color=content_font_color bbs.menu_bg_color=menu_bg_color bbs.menu_font_color=menu_font_color bbs.twitter_bg_color=twitter_bg_color bbs.twitter_font_color=twitter_font_color bbs.twitter_shell_color=twitter_shell_color bbs.side_color=side_color bbs.side_font_color=side_font_color bbs.disable_content_image=int(self.request.get("disable_content_image")) try: bbs.design_template_no=int(self.request.get("design_template_no")) except: css=self.request.get("design_template_no") bbs.design_template_no=BbsConst.CSS_CUSTOM #css=self.request.get("css") if(not UpdateBbs.set_css(self,css,bbs)): return bbs.bbs_mode=int(self.request.get("mode")) bbs.comment_rule_enable=int(self.request.get("comment_rule_enable")) bbs.category_list=self.request.get("category_list") bbs.disable_category_sort=int(self.request.get("disable_category_sort")) bbs.deny_host_list=self.request.get("deny_host_list") bbs.enable_continue_draw=int(self.request.get("enable_continue_draw")) bbs.enable_illust_reply=int(self.request.get("enable_illust_reply")) bbs.enable_illust_reply_continue=int(self.request.get("enable_illust_reply_continue")) bbs.disable_normal_reply=int(self.request.get("disable_normal_reply")) bbs.enable_moper=int(self.request.get("enable_moper")) bbs.enable_full_flat=int(self.request.get("enable_full_flat")) bbs.enable_full_comment=int(self.request.get("enable_full_comment")) bbs.disable_applause=int(self.request.get("disable_applause")) bbs.disable_analyze=int(self.request.get("disable_analyze")) bbs.comment_login_require=int(self.request.get("comment_login_require")) bbs.disable_create_new_thread=int(self.request.get("disable_create_new_thread")) bbs.disable_create_new_illust=int(self.request.get("disable_create_new_illust")) bbs.dont_count_owner=int(self.request.get("dont_count_owner")) bbs.date_format=int(self.request.get("date_format")) bbs.move_account=self.request.get("move_account") bbs.show_only_movie=int(self.request.get("show_only_movie")) #bbs.dont_permit_app=int(self.request.get("dont_permit_app")) bbs.delete_when_upload_success=int(self.request.get("delete_when_upload_success")) bbs.disable_import_image=int(self.request.get("disable_import_image")) bbs.tool_bg_color=self.request.get("tool_bg_color") if(bbs.tool_bg_color=="None"): bbs.tool_bg_color=None try: bbs.page_illust_n=int(self.request.get("page_illust_n")) except: bbs.page_illust_n=5 try: bbs.page_comment_n=int(self.request.get("page_comment_n")) except: bbs.page_comment_n=10 if(bbs.page_illust_n<1) :bbs.page_illust_n=1 if(bbs.page_illust_n>10) :bbs.page_illust_n=10 if(bbs.page_comment_n<1) :bbs.page_comment_n=1 if(bbs.page_comment_n>50) :bbs.page_comment_n=50 bbs.put() RecentCommentCache.invalidate(bbs); #feed update ApiFeed.invalidate_cache() if(bbs.move_account): self.redirect(str('./move_account?bbs_key='+self.request.get("bbs_key"))) else: self.redirect(str('./bbs_index?bbs_key='+self.request.get("bbs_key")))