def get(self): datingNoteId=self.request.get('id') if datingNoteId: n=DaTingNote.get_by_id(int('id')) if n: n.delete() self.redirect('/daTingNoteList') return notelist=[] for note in DaTingNote.all(): note.groupobj=getGroup(note.group) notelist.append(note) self.render('templates/daTingNoteList.html',{'datingNoteList':notelist}) pass
def get(self): # username=get_current_user(self) grouplist=[] noteid=self.request.get('Noteid',0) note={} imglist=[] if noteid: note=DaTingNote.get_by_id(int(noteid)) if note: imgstrlist=re.findall('(?i)templink/([^/\s\?&]*)/',note.content) for img in imgstrlist: img=int(img) imglist.append(img) imglist=Img.get_by_id(imglist) news, number = re.subn('[\*TempLink/([^/]*/[^\]]*]','', note.content) note.content=news msg=memcache.get(self.request.get('msgid','')) if not msg: msg='' self.render('templates/daTingNoteAdd.html',{'note':note,'imglist':imglist,'msg':msg})
except Exception,e: logging.info(str(e)) self.response.out.write('1') return #判断用户是否具有发表帖子的权限 #? # group=Group.get_by_id(groupid) group=getGroup(groupid) if group: if mod=='add': note=DaTingNote() else: msg=u'修改帖子成功' note=DaTingNote.get_by_id(noteid) note.group=groupid note.author=username note.content=content note.title=title note.updateTime=noteupdate ##### ##### imgfield=self.request.POST.get('imgfile') if imgfield!=None and imgfield!='' and imgfield!=u'': if imgfield.type.lower() not in ['image/pjpeg','image/x-png','image/jpeg','image/png','image/gif','image/jpg']: msgid=str(uuid.uuid4()) memcache.set(msgid,u'图片格式不合格',3600) self.redirect('/CreateNoteM?Noteid='+str(noteid)+'&GroupId='+str(groupid)+'&msgid='+msgid)