コード例 #1
0
    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]})
コード例 #2
0
    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})
コード例 #3
0
                    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

            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)