Ejemplo n.º 1
0
    def get(self):
        username=get_current_user(self)
        imglist=[]
        note=AdNote.get_by_key_name('u'+username)
#        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
        msg=memcache.get(self.request.get('msgid',''))
        if not msg:
            msg=''
        self.render('templates/adNoteShow.html',{'adnote':note,'username':username,'user':getorAddUser(username),'imglist':imglist,'msg':msg})
Ejemplo n.º 2
0
    def post(self):
        try:
            msgid=''
            username=get_current_user(self)
            note=AdNote.get_by_key_name('u'+username)
            if not note:
                note=AdNote(key_name='u'+username)
            else:
                img=Img.get_by_id(note.imgid)
                if img:
                    img.delete()

#            note.group=groupid
            note.author=username
            note.content=self.request.get('NoteContent','')
            note.title=self.request.get('NoteTitle','')

#            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('/PutAdNote?msgid='+msgid)
                    logging.info(imgfield.type)
                    return
#                    raise 'type error'
                imgfile=Img()
                imgfile.type=imgfield.type
                if imgfield.type.lower().find('gif')==-1:
                    imgfile.afile=db.Blob(images.resize(self.request.get("imgfile"), height=150))
                else:
                    imgfile.afile=self.request.get("imgfile")
#                imgfile.afile=db.Blob(images.resize(self.request.get("imgfile"), height=150))
                imgfile.put()
                note.imgid=imgfile.key().id()
                note.content+="[*TempLink/%s/%s*]" %(imgfile.key().id(),setting.APPCODE_ID)
            note.put()

        except Exception,e:
            logging.error(str(e))
            pass
Ejemplo n.º 3
0
    def get(self):
        username=get_current_user(self)
        lasttimestr=jingpaiDate()
        starttime=datetime.datetime.strptime(lasttimestr,'%Y%m%d')
        endtime=starttime+datetime.timedelta(hours =24*7)-+datetime.timedelta(minutes =1)
        pl=PaiMai.all().order('-__key__').fetch(1)
        pm=None
        if 1==len(pl):
            pm=pl[0]
            if lasttimestr!=pm.key().name()[1:]:
                pm=None
        adnote=None
        if pm:
            adnote=AdNote.get_by_key_name('u'+pm.user)
        msgid=self.request.get('msg')
        msg=None
        if msgid:
            msg=memcache.get(msgid)

        self.render('templates/jingpai.html',{'username':username,'starttime':starttime,'endtime':endtime,'paimai':pm,'adnote':adnote,'userpoint':getorAddUserPoint(username),'msg':msg})