def post(self): """ """ username=get_current_user(self) if '000'==username: type=self.request.get('type','') value=self.request.get('value',0) list=[] if type=='username': list=Note.all().filter('author =',str(value)) if type=='groupid': list=Note.all().filter('group =',int(value)).order('-isTop').order('-updateTime') if type=='noteid': list=Note.get_by_id([int(value)]) else: type=self.request.get('type','') value=self.request.get('value',0) list=[] if type=='username': list=Note.all().filter('author =',str(value)) if type=='groupid': list=Note.all().filter('group =',int(value)).order('-isTop').order('-updateTime') if not type and not value: groupids=[] for g in Group.all().filter('author =',username): groupids.append(g.key().id()) list=Note.all().filter('group in',groupids).filter('isDelete =',False).order('-updateTime') notelist=[] for note in list: note.groupobj=getGroup(note.group) notelist.append(note) self.render('templates/noteList.html',{'list':notelist,'isadmin':('000'==username and [True] or [False])[0]})
def get(self): groupid=self.request.get('groupid') tagmap={} for tag in Tag.all(): tagmap[str(tag.key().id())]=tag.name username=get_current_user(self) user=getorAddUser(username) if groupid: groupid=int(groupid) # group=Group.get_by_id(groupid) group=getGroup(groupid) if group.author==username: group.delete() nlist=[] rnlist=[] for n in Note.all().filter('group =',groupid): nlist.append(n) rnlist.append('r'+str(n.key().id())) db.delete(Replay.get_by_key_name(rnlist)) db.delete(nlist) if groupid in user.createGroup: user.createGroup.remove(groupid) user.put() if groupid in user.createGroupAdd: user.createGroupAdd.remove(groupid) user.put() groupidlist=user.createGroup+user.createGroupAdd list=Group.get_by_id(groupidlist) # list=Group.all().filter('author =',username) listgroup=[] ischange=False for i,group in enumerate(list): if not group: if groupidlist[i] in user.createGroup: user.createGroup.remove(groupidlist[i]) ischange=True if groupidlist[i] in user.createGroupAdd: user.createGroupAdd.remove(groupidlist[i]) ischange=True else: group.tagname=tagmap.get(str(group.tag),'') listgroup.append(group) if ischange: user.put() self.render('templates/removegroupList.html',{'list':listgroup})
def get(self): username=get_current_user(self) grouplist=[] noteid=self.request.get('Noteid',0) note={} imglist=[] if noteid: note=Note.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 groupid=self.request.get('GroupId') if note: groupid=note.group group=None if groupid: # group=Group.get_by_id(int(groupid)) group=getGroup(int(groupid)) if not group: if '000'==username: self.redirect('/GroupListM') return else: for g in Group.all().filter('author =',username): grouplist.append(g) msg=memcache.get(self.request.get('msgid','')) if not msg: msg='' self.render('templates/noteAdd.html',{'group':group,'grouplist':grouplist,'note':note,'imglist':imglist,'msg':msg})
# group=Group.get_by_id(groupid) group=getGroup(groupid) if group: if group.type==1: if username not in group.partner and username!=group.author: self.response.out.write('2') return elif group.type==2: if username!=group.author and username!=group.author: self.response.out.write('2') return if mod=='add': if group.notenum<group.notecount: note=Note() else: note=Note.all().filter('group =',groupid).filter('isTop =',False).order('isDelete').order('updateTime').fetch(1)[0] r=Replay.get_by_key_name('r'+str(note.key().id())) if r: r.content='' r.updateTime=noteupdate r.put() else: msg=u'修改帖子成功' note=Note.get_by_id(noteid) note.group=groupid note.author=username note.content=content note.title=title