def post(self, status_id): if len(status_id) < 8: raise tornado.web.HTTPError(404) status_id = decode(status_id) comments = self.get_argument("commenttext", None) user_id = self.current_user.id pubdate = time.strftime('%y-%m-%d %H:%M', time.localtime()) comment_id = self.db.execute( "insert into fd_Stacomm (user_id, " " status_id, comments, pubdate) values (%s,%s,%s,%s)", user_id, status_id, comments, pubdate) if comment_id: status_key = self.rd.keys('status*%s' % status_id)[0] prev_comments_num = self.rd.hget(status_key, 'comm') if not prev_comments_num: comments_num = 1 else: comments_num = int(prev_comments_num) + 1 self.rd.hset(status_key, 'comm', comments_num) self.write(''.join([ self.avatar('m', self.current_user.id, self.current_user.uuid_), ',', self.br( self.at( linkify( comments, extra_params="target='_blank' rel='nofollow'"))) ]))
def post(self): user = self.get_argument("user",None) actto = self.get_argument("actto",None) acttype = self.get_argument("acttype",None) user_id = get_id_by_name(self.db, self.rd, user) if len(actto) < 8 or not user_id or int(user_id) != self.current_user.id: raise tornado.web.HTTPError(405) acttype = int(acttype) actto = decode(actto) # don't remove in db now because data is not got wholy in redis,just mark it if acttype == 1: self.db.execute("update fd_Status set status_ = 1 where id = %s", actto) elif acttype == 2: self.db.execute("update fd_Note set status_ = 2 where id = %s", actto) elif acttype == 3: self.db.execute("update fd_Link set status_ = 2 where id = %s", actto) elif acttype == 4: doc_id = self.db.get("select doc_id,name,user_id from fd_Doc where id = %s", actto) if not doc_id: raise tornado.web.HTTPError(500) tld = doc_id.name.split(".").pop() prepath = "/data/static/usrdoc/%s/%s.%s" % (doc_id.user_id, doc_id.doc_id, tld) jpgpath = "/work/Dormforge/static/usrdoc/%s/%s.jpg" % (doc_id.user_id, doc_id.doc_id) swfpath = "/work/Dormforge/static/usrdoc/%s/%s.swf" % (doc_id.user_id, doc_id.doc_id) if os.path.exists(prepath) and os.path.exists(jpgpath) and os.path.exists(swfpath): os.remove(prepath) os.remove(jpgpath) os.remove(swfpath) self.db.execute("update fd_Doc set status_ = 2 where id = %s", actto) del_activity(self.rd, user_id, acttype, actto)
def get(self): template_values = {} pubtype = self.get_argument("pubtype",0) linkid = self.get_argument("id",None) if linkid and pubtype == 0: if len(linkid) < 8: raise tornado.web.HTTPError(404) link_id = decode(linkid) link = self.db.get("select url,title,summary,user_id,status_, " "tags from fd_Link where id = %s", link_id) if not link or link.user_id != self.current_user.id: raise tornado.web.HTTPError(404) template_values['url'] = link.url template_values['title'] = link.title template_values['summary'] = link.summary template_values['tags'] = link.tags template_values['id'] = linkid template_values['checked'] = "checked" if link.status_ == 1 else "" pubtype = 2 else: url = self.get_argument("url",None) title = self.get_argument("title",None) template_values['url'] = url template_values['title'] = title template_values['sugg'] = pubtype or self.current_user.sugg_link template_values['pubtype'] = pubtype self.render("editlink.html", template_values=template_values)
def get(self, note_id): template_values = {} if len(note_id) < 8: raise tornado.web.HTTPError(404) note_id = decode(note_id) notes = self.db.query( "select title,note,rev_num,rev_user_name as name,rev_user_domain as domain" ", revdate from fd_NoteHistory where note_id = %s and rev_status = 0" " order by rev_num desc", note_id) if not notes: raise tornado.web.HTTPError(404) for i in range(len(notes)): next_note = {} if i == len(notes)-1: next_note['title'] = '' next_note['note'] = '' else: next_note['title'] = notes[i+1].title next_note['note'] = notes[i+1].note notes[i].title = textdiff(xhtml_escape(next_note['title']), xhtml_escape(notes[i].title)) note1 = self.br(linkify(next_note['note'], extra_params="target='_blank' rel='nofollow'")) note2 = self.br(linkify(notes[i].note, extra_params="target='_blank' rel='nofollow'")) notes[i].note = self.at(textdiff(note1, note2)) notes[i]['rev'] = 0 if i == 0: notes[i]['rev'] = 1 template_values['notes'] = notes self.render("notehistory.html", template_values=template_values)
def get(self): noteid = self.get_argument("note_id",None) if not noteid or len(noteid) < 8: raise tornado.web.HTTPError(404) noteid = decode(noteid) note = self.db.get("select note from fd_Note where " "id = %s", noteid) if note: self.write(self.br(self.at(linkify(note.note, extra_params="target='_blank' rel='nofollow'")))) else: self.write("wrong")
def get(self): template_values = {} noteid = self.get_argument("id",None) if noteid: if len(noteid) < 8: raise tornado.web.HTTPError(404) note_id = decode(noteid) note = self.db.get("select id,title,note,user_id,status_ " "from fd_Note where id = %s", note_id) if not note or note.user_id != self.current_user.id: raise tornado.web.HTTPError(404) note.id = noteid template_values['note'] = note self.render("pubnote.html", template_values=template_values)
def post(self): statusid = self.get_argument("statusid",None) statuscontent = self.get_argument("status",None) user_id = self.current_user.id if statusid and statuscontent and statuscontent != "": statusid = decode(statusid) status_user = self.db.get("select user_id from fd_Status where id = %s", statusid) if not status_user or status_user.user_id != user_id: raise tornado.web.HTTPError(404) self.db.execute("update fd_Status set status = %s " "where id = %s", statuscontent, statusid) status_key = "status:%s:%s" % (user_id, statusid) actdict = {'status':statuscontent} if self.rd.hmset(status_key, actdict): self.redirect("/status/%s" % encode(statusid))
def get(self): template_values = {} statusid = self.get_argument("id",None) if not statusid: raise tornado.web.HTTPError(404) else: if len(statusid) < 8: raise tornado.web.HTTPError(404) status_id = decode(statusid) status = self.db.get("select status,user_id,status_ " "from fd_Status where id = %s", status_id) if not status or status.user_id != self.current_user.id: raise tornado.web.HTTPError(404) template_values['status'] = status.status template_values['id'] = statusid self.render("editstatus.html", template_values=template_values)
def post(self): noteid = self.get_argument("id",None) notetype = self.get_argument("notetype",None) notetitle = self.get_argument("notetitle",None) notecontent = self.get_argument("notecontent",None) #status_:{0:public,1:private,2:delted rednotecontent = notecontent if len(notecontent) > 150: rednotecontent = notecontent[:140] + " ..." status_ = int(notetype) user_id = self.current_user.id rev_user = get_namedomainuuid_by_id(self.db,self.rd,str(user_id)) pubdate = time.strftime('%y-%m-%d %H:%M', time.localtime()) if noteid: noteid = decode(noteid) note_user = self.db.get("select user_id from fd_Note where id = %s", noteid) if not note_user or note_user.user_id != user_id: raise tornado.web.HTTPError(404) self.db.execute("update fd_Note set title = %s, note = %s," "status_ = %s where id = %s", notetitle, notecontent, status_, noteid) rev_num = int(self.db.get("select max(rev_num) as rev_num from fd_NoteHistory where note_id = %s", noteid).rev_num) self.db.execute("insert into fd_NoteHistory(note_id,title,note,rev_num,rev_user_id," "rev_user_name,rev_user_domain,revdate) values (%s,%s,%s,%s,%s,%s,%s,%s)", noteid, notetitle, notecontent, rev_num+1, user_id, rev_user[0], rev_user[1], pubdate) note_key = "note:%s:%s" % (user_id, noteid) actdict = {'title':notetitle, 'content':rednotecontent, 'status':status_} if self.rd.hmset(note_key, actdict): self.write("right") else: self.write("wrong") else: redpubdate = pubdate[4:] if pubdate[3] == '0' else pubdate[3:] note_id = self.db.execute("insert into fd_Note (user_id, title, " "note, pubdate, status_) values (%s,%s,%s,%s,%s)", user_id, notetitle, notecontent, pubdate, status_) if note_id: self.db.execute("insert into fd_NoteHistory(note_id,title,note,rev_num,rev_user_id," "rev_user_name,rev_user_domain,revdate) values (%s,%s,%s,%s,%s,%s,%s,%s)", note_id, notetitle, notecontent, 1, user_id, rev_user[0], rev_user[1], pubdate) actdict = {'time':redpubdate, 'title':notetitle, 'content':rednotecontent, 'status':status_} addresult = add_activity(self.rd, user_id, note_id, 2, actdict) if addresult: self.write(encode(str(note_id))) #self.write("right") else: self.write("wrong")
def get(self, status_id): template_values = {} if len(status_id) < 8: raise tornado.web.HTTPError(404) status_id = decode(status_id) status = self.db.get("select p.name,p.domain,p.uuid_,p.id,s.status,s.pubdate,s.status_ " "from fd_People p, fd_Status s where s.user_id = p.id and " "s.id = %s", status_id) if not status or status.status_ == 1: raise tornado.web.HTTPError(404) template_values['activity'] = status comments = self.db.query("select p.name,p.domain,p.uuid_,p.id,c.comments, " "c.pubdate from fd_People p, fd_Stacomm c where p.id" "=c.user_id and status_id = %s", status_id) template_values['comments_length'] = len(comments) template_values['comments'] = comments self.render("status.html", template_values=template_values)
def post(self): statusid = self.get_argument("statusid", None) statuscontent = self.get_argument("status", None) user_id = self.current_user.id if statusid and statuscontent and statuscontent != "": statusid = decode(statusid) status_user = self.db.get( "select user_id from fd_Status where id = %s", statusid) if not status_user or status_user.user_id != user_id: raise tornado.web.HTTPError(404) self.db.execute( "update fd_Status set status = %s " "where id = %s", statuscontent, statusid) status_key = "status:%s:%s" % (user_id, statusid) actdict = {'status': statuscontent} if self.rd.hmset(status_key, actdict): self.redirect("/status/%s" % encode(statusid))
def get(self): template_values = {} statusid = self.get_argument("id", None) if not statusid: raise tornado.web.HTTPError(404) else: if len(statusid) < 8: raise tornado.web.HTTPError(404) status_id = decode(statusid) status = self.db.get( "select status,user_id,status_ " "from fd_Status where id = %s", status_id) if not status or status.user_id != self.current_user.id: raise tornado.web.HTTPError(404) template_values['status'] = status.status template_values['id'] = statusid self.render("editstatus.html", template_values=template_values)
def get(self, link_id): template_values = {} if len(link_id) < 8: raise tornado.web.HTTPError(404) link_id = decode(link_id) link = self.db.get("select p.name,p.domain,p.uuid_,p.id,l.url,l.title," "l.summary,l.pubdate,l.status_ " "from fd_People p, fd_Link l where l.user_id = p.id and " "l.id = %s", link_id) if not link or link.status_ == 1 and link.name != self.current_user.name: raise tornado.web.HTTPError(404) template_values['activity'] = link comments = self.db.query("select p.name,p.domain,p.uuid_,p.id,c.comments, " "c.pubdate from fd_People p, fd_Linkcomm c where p.id" "=c.user_id and link_id = %s", link_id) template_values['comments_length'] = len(comments) template_values['comments'] = comments self.render("link.html", template_values=template_values)
def get(self): template_values = {} doc_id = self.get_argument("id", None) if doc_id: if len(doc_id) < 8: raise tornado.web.HTTPError(404) docid = decode(doc_id) doc = self.db.get("select title,summary,tags,user_id,status_ " "from fd_Doc where id = %s", docid) if not doc or doc.user_id != self.current_user.id: raise tornado.web.HTTPError(404) template_values['title'] = doc.title template_values['summary'] = doc.summary template_values['tag'] = doc.tags if doc.status_ == 1: template_values['checked'] = 'checked' template_values['id'] = doc_id self.render("editdoc.html", template_values=template_values)
def get(self, note_id): template_values = {} if len(note_id) < 8: raise tornado.web.HTTPError(404) note_id = decode(note_id) note = self.db.get("select p.name,p.domain,n.title,n.note,n.status_ " ",n.pubdate from fd_People p, fd_Note n where n.user_id = p.id and " "n.id = %s", note_id) if not note or note.status_ == 2 or \ note.status_ == 1 and note.name != self.current_user.name: raise tornado.web.HTTPError(404) template_values['activity'] = note comments = self.db.query("select p.name,p.domain,p.uuid_,p.id,c.comments, " "c.pubdate from fd_People p, fd_Notecomm c where p.id" "=c.user_id and note_id = %s", note_id) template_values['comments_length'] = len(comments) template_values['comments'] = comments self.render("note.html", template_values=template_values)
def post(self, link_id): if len(link_id) < 8: raise tornado.web.HTTPError(404) link_id = decode(link_id) comments = self.get_argument("commenttext",None) user_id = self.current_user.id pubdate = time.strftime('%y-%m-%d %H:%M', time.localtime()) comment_id = self.db.execute("insert into fd_Linkcomm (user_id, " " link_id, comments, pubdate) values (%s,%s,%s,%s)", user_id, link_id, comments, pubdate) if comment_id: link_key = self.rd.keys('link*%s' % link_id)[0] prev_comments_num = self.rd.hget(link_key, 'comm') if not prev_comments_num: comments_num = 1 else: comments_num = int(prev_comments_num) + 1 self.rd.hset(link_key, 'comm', comments_num) self.write(''.join([self.avatar('m',self.current_user.id,self.current_user.uuid_), ',', self.br(self.at(linkify(comments, extra_params="target='_blank' rel='nofollow'")))]))
def get(self, status_id): template_values = {} if len(status_id) < 8: raise tornado.web.HTTPError(404) status_id = decode(status_id) status = self.db.get( "select p.name,p.domain,p.uuid_,p.id,s.status,s.pubdate,s.status_ " "from fd_People p, fd_Status s where s.user_id = p.id and " "s.id = %s", status_id) if not status or status.status_ == 1: raise tornado.web.HTTPError(404) template_values['activity'] = status comments = self.db.query( "select p.name,p.domain,p.uuid_,p.id,c.comments, " "c.pubdate from fd_People p, fd_Stacomm c where p.id" "=c.user_id and status_id = %s", status_id) template_values['comments_length'] = len(comments) template_values['comments'] = comments self.render("status.html", template_values=template_values)
def post(self, note_id): version = self.get_argument("version",None) if len(note_id) < 8 or not version: raise tornado.web.HTTPError(404) note_id = decode(note_id) user = self.db.get("select user_id from fd_Note where id = %s", note_id) #only owner and administrator can revert if user.user_id != self.current_user.id and self.current_user.actlevel != 0: return self.write("nopermit") self.db.execute("update fd_NoteHistory set rev_status = 1 where note_id = %s and rev_num > %s" , note_id, version) note = self.db.get("select title,note from fd_NoteHistory where note_id = %s and rev_num = %s" , note_id, version) self.db.execute("update fd_Note set title = %s, note = %s where id = %s", note.title, note.note, note_id) note_key = "note:%s:%s" % (user.user_id, note_id) rednotecontent = note.note if len(note.note) > 150: rednotecontent = note.note[:140] + " ..." actdict = {'title':note.title, 'content':rednotecontent} self.rd.hmset(note_key, actdict)
def get(self, doc_id): template_values = {} if len(doc_id) < 8: raise tornado.web.HTTPError(404) doc_id = decode(doc_id) doc = self.db.get("select p.id ,p.name,p.domain,d.title,d.summary,d.status_,d.doc_id " ",d.pubdate from fd_People p, fd_Doc d where d.user_id = p.id and " "d.id = %s", doc_id) if not doc or doc.status_ == 2 or \ doc.status_ == 1 and doc.name != self.current_user.name: raise tornado.web.HTTPError(404) template_values['activity'] = doc template_values['path'] = self.static_url("usrdoc/%s/%s.swf" % (doc.id, doc.doc_id)) template_values['epath'] = self.static_url("usrdoc/expressInstall.swf") comments = self.db.query("select p.name,p.domain,p.uuid_,p.id,c.comments, " "c.pubdate from fd_People p, fd_Doccomm c where p.id" "=c.user_id and doc_id = %s", doc_id) template_values['comments_length'] = len(comments) template_values['comments'] = comments self.render("doc.html", template_values=template_values)
def post(self): url = self.get_argument("linkurl",None) title = self.get_argument("linktitle",None) summary = self.get_argument("linksummary",None) tag = self.get_argument("linktag",None) oldtag = self.get_argument("oldtag",None) linktype = self.get_argument("linktype",None) pubtype = self.get_argument("pubtype",0) linkid = self.get_argument("linkid",None) pubtype = int(pubtype) if linkid: linkid = decode(linkid) link_user = self.db.get("select user_id from fd_Link where id = %s", linkid) if not link_user or link_user.user_id != self.current_user.id: raise tornado.web.HTTPError(404) if not url: raise tornado.web.HTTPError(500) url = url[7:] if url.startswith("http://") else url url = url[8:] if url.startswith("https://") else url if linkid: link_sql = ["update fd_Link set url = '{0}',".format(url.replace('%','%%'))] else: link_sql = ["insert into fd_Link set url = '{0}',".format(url.replace('%','%%'))] if title: link_sql.append("title = '{0}',".format(title.replace("'", "''").replace('%','%%'))) if summary: link_sql.append("summary = '{0}',".format(summary.replace("'", "''").replace('%','%%'))) if tag: tag = tag.strip().replace(' ',',') tag = tag.strip().replace(',',',') tags = tag.split(",") taglists = [] for t in tags: if t in taglists: continue taglists.append(t) newtag = " ".join(taglists) if not (pubtype == 2 and newtag == oldtag): link_sql.append("tags = '{0}',".format(newtag.replace("'", "''").replace('%','%%'))) pubdate = time.strftime('%y-%m-%d %H:%M', time.localtime()) redpubdate = pubdate[4:] if pubdate[3] == '0' else pubdate[3:] if pubtype == 2: link_sql.append("status_ = {0} where id = {1}".format(linktype,linkid)) else: link_sql.append("user_id = {0},pubdate = '{1}',status_ = {2}".format(self.current_user.id,pubdate,linktype)) fd_link_sql = "".join(link_sql) link_id = self.db.execute(fd_link_sql) if tag: if pubtype != 2 or pubtype == 2 and newtag != oldtag: for t in taglists: tag_id = self.db.get("select id from fd_Tag where tag = %s", t) if tag_id: tag_id = tag_id.id else: tag_id = self.db.execute("insert into fd_Tag (tag) values (%s)", t) if linkid: with_link_id = linkid elif link_id: with_link_id = link_id ltag_id = self.db.execute("insert into fd_Ltag (link_id,tag_id) values (%s,%s)", with_link_id, tag_id) if linkid: link_key = "link:%s:%s" % (self.current_user.id, linkid) actdict = {'url':url, 'status':linktype} if title: actdict['title'] = title if summary: actdict['summary'] = summary if self.rd.hmset(link_key, actdict): self.write("/") elif link_id: actdict = {'time':redpubdate, 'url':url, 'status':linktype} if title: actdict['title'] = title if summary: actdict['summary'] = summary addresult = add_activity(self.rd, self.current_user.id, link_id, 3, actdict) if addresult: self.write("http://" + url)
def post(self): template_values = {} title = self.get_argument("title", None) summary = self.get_argument("summary", None) tag = self.get_argument("tag", None) secret = self.get_argument("secret", None) endocid = self.get_argument("docid", None) oldtag = self.get_argument("oldtag", None) errors = 0 title_error = 0 title_error_messages = ['', u'请输入标题', ] if not endocid: name = self.get_argument("doc.name", None) content_type = self.get_argument("doc.content_type", None) path = self.get_argument("doc.path", None) md5 = self.get_argument("doc.md5", None) size = self.get_argument("doc.size", None) if not title or len(title) == 0: errors = errors + 1 title_error = 1 template_values['title_error'] = title_error template_values['title_error_message'] = title_error_messages[title_error] else: doc_error = 0 doc_error_messages = ['', u'请选择文档', u'暂时不支持该文档格式', u'文档不能大于20M', u"该文档已被上传过", ] if not endocid: if not (name and path and md5 and size): errors = errors + 1 doc_error = 1 else: if name.split(".").pop().lower() not in ["doc", "docx", "ppt", "pptx", "pdf", "xls"]: os.remove(path) errors = errors + 1 doc_error = 2 else: if int(size) > 1024*1024*20: os.remove(path) errors = errors + 1 doc_error = 3 else: predoc = self.db.get("select * from fd_Doc where md5 = %s and status_ = 0", md5) if predoc: os.remove(path) errors = errors + 1 doc_error = 4 else: usrpath = u"/data/static/usrdoc/%s/" % self.current_user.id staticpath = u"/work/Dormforge/static/usrdoc/%s/" % self.current_user.id if not os.path.exists(usrpath): os.makedirs(usrpath) if not os.path.exists(staticpath): os.makedirs(staticpath) docid = "".join([path.split("/").pop(), str(time.time()).split(".")[0]]) doctype = name.split(".").pop().lower() usrdoc = ''.join([usrpath, docid, '.', doctype]) shutil.move(path, usrdoc) if name.split(".").pop().lower() != 'pdf': usrpdf = ''.join([usrpath, docid, ".pdf"]) usrjpg = ''.join([staticpath, docid, ".jpg"]) usrswf = ''.join([staticpath, docid, ".swf"]) if os.path.exists("/opt/libreoffice3.5/program/python"): os.system("/opt/libreoffice3.5/program/python /work/Dormforge/util/DocumentConverter.py %s %s" % (usrdoc, usrpdf)) else: os.system("python /work/Dormforge/util/DocumentConverter.py %s %s" % (usrdoc, usrpdf)) os.system("convert -sample 150x150 %s[0] %s" % (usrpdf, usrjpg)) os.system("pdf2swf %s -o %s -f -T 9 -t -s storeallcharacters" % (usrpdf, usrswf)) os.remove(usrpdf) else: usrjpg = ''.join([staticpath, docid, ".jpg"]) usrswf = ''.join([staticpath, docid, ".swf"]) os.system("convert -sample 150x150 %s[0] %s" % (usrdoc, usrjpg)) os.system("pdf2swf %s -o %s -f -T 9 -t -s storeallcharacters" % (usrdoc, usrswf)) if doc_error != 0: template_values['doc_error'] = doc_error template_values['doc_error_message'] = doc_error_messages[doc_error] else: if endocid: doc_sql = ["update fd_Doc set "] else: if os.path.exists(usrjpg) and os.path.exists(usrswf): doc_sql = ["insert into fd_Doc set doc_id = '%s',name = '%s',content_type = '%s',md5 = '%s', docsize = %s," % (docid,name.replace("'", "''").replace("%", "%%"),content_type,md5,int(size))] doc_sql.append("title = '%s'," % title.replace("'", "''").replace("%", "%%")) if summary: doc_sql.append("summary = '%s'," % summary.replace("'", "''").replace("%", "%%")) if tag: tag = tag.strip().replace(' ',',') tag = tag.strip().replace(',',',') tags = tag.split(",") taglists = [] for t in tags: if t in taglists: continue taglists.append(t) newtag = " ".join(taglists) if not (endocid and newtag == oldtag): doc_sql.append("tags = '%s'," % newtag.replace("'", "''").replace("%", "%%")) pubdate = time.strftime('%y-%m-%d %H:%M', time.localtime()) redpubdate = pubdate[4:] if pubdate[3] == '0' else pubdate[3:] doctype = 0 if secret and secret == "on": doctype = 1 if endocid: doc_sql.append("status_ = %s where id = %s" % (doctype, decode(endocid))) else: doc_sql.append("user_id = %s,pubdate = '%s',status_ = %s" % (self.current_user.id,pubdate,doctype)) doc_id = self.db.execute("".join(doc_sql)) if tag: if (not endocid) or (endocid and newtag != oldtag): for t in taglists: tag_id = self.db.get("select id from fd_Doctag where tag = %s", t) if tag_id: tag_id = tag_id.id else: tag_id = self.db.execute("insert into fd_Doctag (tag) values (%s)", t) if endocid: with_doc_id = decode(endocid) elif doc_id: with_doc_id = doc_id dtag_id = self.db.execute("insert into fd_Dtag (doc_id,tag_id) values (%s,%s)", with_doc_id, tag_id) if endocid: doc_key = "doc:%s:%s" % (self.current_user.id, decode(endocid)) actdict = {'status':doctype} elif doc_id: actdict = {'time':redpubdate, 'docid':docid, 'status':doctype}#docid not doc_id if title: actdict['title'] = title if summary: actdict['summary'] = summary if endocid: if self.rd.hmset(doc_key, actdict): self.redirect("/doc/" + endocid) elif doc_id: addresult = add_activity(self.rd, self.current_user.id, doc_id, 4, actdict) if addresult: self.redirect("/doc/" + encode(str(doc_id))) if errors != 0: if title: template_values['title'] = title if summary: template_values['summary'] = summary if tag: template_values['tag'] = tag self.render("editdoc.html", template_values=template_values)