def post(self): site = GetSite() browser = detect(self.request) template_values = {} template_values['site'] = site template_values['system_version'] = SYSTEM_VERSION template_values['page_title'] = site.title + u' › 新建记事' member = CheckAuth(self) l10n = GetMessages(self, member, site) template_values['l10n'] = l10n if member: template_values['member'] = member # Verification: content note_content = self.request.arguments['content'][0].strip() note_content_length = len(note_content) if note_content_length > 0: note = Note() #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.max') q = Counter.selectBy(name='note.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'note.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.total') q2 = Counter.selectBy(name='note.max') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'note.total' counter2.value = 1 note.num = counter.value note.title = note_content.split("\n")[0][0:60].strip() note.content = note_content note.body = "\n".join(note_content.split("\n")[1:]).strip() note.length = len(note_content) note.member_num = member.num note.member = member note.sync() counter.sync() counter2.sync() store.commit() #jon add self.redirect('/notes/' + str(note.num)) else: template_values['note_content'] = note_content if browser['ios']: path = os.path.join(os.path.dirname(__file__), 'tpl', 'mobile') else: path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop') t = self.get_template(path, 'notes_new.html') self.finish(t.render(template_values)) else: self.redirect('/signin')
def post(self): site = GetSite() browser = detect(self.request) template_values = {} template_values['site'] = site template_values['system_version'] = SYSTEM_VERSION template_values['page_title'] = site.title + u' › 新建记事' member = CheckAuth(self) l10n = GetMessages(self, member, site) template_values['l10n'] = l10n if member: template_values['member'] = member # Verification: content note_content = self.request.arguments['content'][0].strip() note_content_length = len(note_content) if note_content_length > 0: note = Note() #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.max') q = Counter.selectBy(name='note.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'note.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.total') q2 = Counter.selectBy(name='note.max') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'note.total' counter2.value = 1 note.num = counter.value note.title = note_content.split("\n")[0][0:60].strip() note.content = note_content note.body = "\n".join(note_content.split("\n")[1:]).strip() note.length = len(note_content) note.member_num = member.num note.member = member note.sync() counter.sync() counter2.sync() store.commit() #jon add self.redirect('/notes/' + str(note.num)) else: template_values['note_content'] = note_content if browser['ios']: path = os.path.join(os.path.dirname(__file__), 'tpl', 'mobile') else: path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop') t=self.get_template(path,'notes_new.html') self.finish(t.render(template_values)) else: self.redirect('/signin')
def post(self): site = GetSite() browser = detect(self.request) template_values = {} template_values["site"] = site template_values["system_version"] = SYSTEM_VERSION template_values["page_title"] = site.title + u" › 新建记事" member = CheckAuth(self) l10n = GetMessages(self, member, site) template_values["l10n"] = l10n if member: template_values["member"] = member # Verification: content note_content = self.request.get("content").strip() note_content_length = len(note_content) if note_content_length > 0: note = Note() q = db.GqlQuery("SELECT * FROM Counter WHERE name = :1", "note.max") if q.count() == 1: counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = "note.max" counter.value = 1 q2 = db.GqlQuery("SELECT * FROM Counter WHERE name = :1", "note.total") if q2.count() == 1: counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = "note.total" counter2.value = 1 note.num = counter.value note.title = note_content.split("\n")[0][0:60].strip() note.content = note_content note.body = "\n".join(note_content.split("\n")[1:]).strip() note.length = len(note_content) note.member_num = member.num note.member = member note.put() counter.put() counter2.put() self.redirect("/notes/" + str(note.num)) else: template_values["note_content"] = note_content if browser["ios"]: path = os.path.join(os.path.dirname(__file__), "tpl", "mobile", "notes_new.html") else: path = os.path.join(os.path.dirname(__file__), "tpl", "desktop", "notes_new.html") output = template.render(path, template_values) self.response.out.write(output) else: self.redirect("/signin")
def post(self): site = GetSite() template_values = {} template_values['site'] = site template_values['system_version'] = SYSTEM_VERSION template_values['page_title'] = site.title + u' › 新建记事' member = CheckAuth(self) l10n = GetMessages(self, member, site) template_values['l10n'] = l10n if member: template_values['member'] = member # Verification: content note_content = self.request.get('content').strip() note_content_length = len(note_content) if note_content_length > 0: note = Note() q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'note.max' counter.value = 1 q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'note.total' counter2.value = 1 note.num = counter.value note.title = note_content.split("\n")[0][0:60].strip() note.content = note_content note.body = "\n".join(note_content.split("\n")[1:]).strip() note.length = len(note_content) note.member_num = member.num note.member = member note.put() counter.put() counter2.put() self.redirect('/notes/' + str(note.num)) else: template_values['note_content'] = note_content path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_new.html') output = template.render(path, template_values) self.response.out.write(output) else: self.redirect('/signin')
def post(self): site = GetSite() user_agent = detect(self.request) template_values = {} template_values['site'] = site template_values['system_version'] = SYSTEM_VERSION template_values['page_title'] = site.title + u' › 新建记事' member = CheckAuth(self) l10n = GetMessages(self, member, site) template_values['l10n'] = l10n if member: template_values['member'] = member # Verification: content note_content = self.request.get('content').strip() note_content_length = len(note_content) if note_content_length > 0: note = Note() q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'note.max' counter.value = 1 q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'note.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'note.total' counter2.value = 1 note.num = counter.value note.title = note_content.split("\n")[0][0:60].strip() note.content = note_content note.body = "\n".join(note_content.split("\n")[1:]).strip() note.length = len(note_content) note.member_num = member.num note.member = member note.put() counter.put() counter2.put() self.redirect('/notes/' + str(note.num)) else: template_values['note_content'] = note_content path = os.path.join(os.path.dirname(__file__), 'tpl', 'desktop', 'notes_new.html') output = template.render(path, template_values) self.response.out.write(output) else: self.redirect('/signin')