Ejemplo n.º 1
0
    def get(self):
        pluginVersionDict = {}
        query=Plugin.all()
        appcode=self.request.get('appcode',None)
        if appcode:
            query.filter('appcode =',appcode)
        for plugin in query.order('-lastUpdateTime'):
            if plugin.isdel:
                pluginVersionDict[plugin.appcode] = {'isdel': plugin.isdel}
            else:
                pluginVersionDict[plugin.appcode] = {'plugin': plugin, 'isdel': plugin.isdel}
                pluginVersion = memcache.get('newpluginVersion' + plugin.appcode)
                if not pluginVersion:
                    pluginVersion = PluginVersion.all().filter('plugin =', plugin.key().id()).order(
                        '-versionnum').fetch(1)
                    if len(pluginVersion):
                        pluginVersion = pluginVersion[0]
                        memcache.set('newpluginVersion' + plugin.appcode, pluginVersion, 360000)
                if pluginVersion:
                    pluginVersionDict[plugin.appcode]['pluginVersion'] = pluginVersion
                    pluginVersionDict[plugin.appcode]['newversionnum'] = pluginVersion.versionnum
                if not pluginVersion.data and not pluginVersion.datakey:
                    del pluginVersionDict[appcode]

        # 输出 json 字符串 plugin 对象
        result={'pluginlist':jsonToStr(pluginVersionDict),"notice":[]}
        self.flush(result)
Ejemplo n.º 2
0
 def post(self):
     appcodes = self.request.get('appcodes', '').split(',')
     pluginVersionDict = {}
     for appcode in appcodes:
         versionnum = self.request.get(appcode, '')
         pluginVersionDict[appcode] = {'versionnum': versionnum, 'isdel': True}
         plugin = memcache.get('plugin' + appcode)
         if not plugin:
             plugin = Plugin.all().filter('appcode =', appcode).fetch(1)
             if len(plugin):
                 plugin = plugin[0]
                 memcache.set('plugin' + appcode, plugin, 360000)
         if plugin and plugin.isdel == False:
             pluginVersionDict[appcode]['isdel'] = False
             pluginVersion = memcache.get('newpluginVersion' + appcode)
             if not pluginVersion:
                 pluginVersion = PluginVersion.all().filter('plugin =', plugin.key().id()).order(
                     '-versionnum').fetch(1)
                 if len(pluginVersion):
                     pluginVersion = pluginVersion[0]
                     memcache.set('newpluginVersion' + appcode, pluginVersion, 360000)
             if pluginVersion:
                 pluginVersionDict[appcode]['plugin'] = plugin
                 pluginVersionDict[appcode]['pluginVersion'] = pluginVersion
                 pluginVersionDict[appcode]['newversionnum'] = pluginVersion.versionnum
             if not pluginVersion.data and not pluginVersion.datakey:
                 del pluginVersionDict[appcode]
     # 输出 json 字符串 plugin 对象
     if pluginVersionDict:
         msg=[{"msg":u"新收到%s条插件更新信息"%(len(pluginVersionDict.keys()),),"type":1}]
     else:
         msg=[]
     result={'pluginlist':jsonToStr(pluginVersionDict),"notice":[]}
     self.flush(result)
Ejemplo n.º 3
0
 def get(self):
     id = self.request.get('id', None)
     plugin = {}
     pluginVersion = {}
     if id:
         plugin = Plugin.get_by_id(int(id))
         pvl = PluginVersion.all().filter('plugin =', int(id)).order('-versionnum').fetch(1)
         if pvl:
             pluginVersion = pvl[0]
     self.render('template/plugin/pluginDetail.html', {'plugin': plugin, 'pluginVersion': pluginVersion})
Ejemplo n.º 4
0
 def post(self):
     appcode = self.request.get('appcode', None)
     for plugin in Plugin.all().filter('appcode =', appcode):
         for pv in PluginVersion.all().filter('plugin =',plugin.key().id()):
             if pv.datakey:
                 b=blobstore.BlobInfo.get(pv.datakey)
                 if b:
                     b.delete()
             upload_url = blobstore.create_upload_url('/upload?pluginversionid=%s'%(pv.key().id()))
             return self.flush({'status' : 200, 'upload_url' : upload_url})
     return self.flush({'status':500,'message':u'插件已经存在'})
Ejemplo n.º 5
0
 def get(self):
     id = self.request.get('id', None)
     if id:
         plugin = Plugin.get_by_id(int(id))
         for pv in PluginVersion.all().filter('plugin =', int(id)):
             if pv.imageids:
                 db.delete(Images.get_by_id(pv.imageids))
             pv.delete()
         plugin.delete()
         self.flush(getResult(id, True, u'删除成功。'))
     else:
         self.flush(getResult('', False, u'删除失败,未提供插件id。'))
Ejemplo n.º 6
0
    def post(self):
        pluginid = self.request.get('pluginid', '')
        needBigData=False
        id = self.request.get('id', '')
        versioncode = self.request.get('versioncode', '')
        versionnum = self.request.get('versionnum', '')
        updateDesc = self.request.get('updateDesc', '')
        if id:
            pluginVersion = PluginVersion.get_by_id(int(id))
        else:
            pluginVersion = PluginVersion()
            pluginVersion.plugin = int(pluginid)
        pluginVersion.versioncode = versioncode
        pluginVersion.versionnum = int(versionnum)
        pluginVersion.updateDesc = updateDesc

        appdata = self.request.POST.get('data')
        if appdata != '' and appdata != u'' and appdata != None:
            pluginVersion.data = db.Blob(appdata.file.read())
            pluginVersion.size = appdata.bufsize
        else:
            needBigData=True
        for i in range(1, 11):
            imgfilename = 'image' + str(i)
            imgfield = self.request.POST.get(imgfilename)
            if imgfield != '' and imgfield != u'' and imgfield != None:
                if imgfield.type.lower() not in ['image/pjpeg', 'image/x-png', 'image/jpeg', 'image/png', 'image/gif',
                                                 'image/jpg']:
                    continue
                imgfile = Images()
                imgfile.filename = imgfield.filename
                imgfile.filetype = imgfield.type
                imgfile.data = db.Blob(imgfield.file.read())
                imgfile.size = imgfield.bufsize
                imgfile.put()
                pluginVersion.imageids.append(imgfile.key().id())
        pluginVersion.put()
        plugin = {}
        pluginVersionList = []
        if pluginid:
            plugin = Plugin.get_by_id(int(pluginid))
            pluginVersionList = PluginVersion.all().filter('plugin =', int(pluginid)).order('-versionnum')

        data={'plugin': plugin, 'pluginVersion': pluginVersion, 'pluginVersionList': pluginVersionList, 'id': id,
                     'pluginid': pluginid, 'result': 'succeed', 'msg': u'操作成功。','needBigData':needBigData}
        if needBigData:
            upload_url = blobstore.create_upload_url('/upload?pluginversionid=%s'%(pluginVersion.key().id()))
            data['upload_url']=upload_url
            data['msg']= u'请上传APK文件。'
            self.render('template/plugin/pluginUpload2.html',data)
        else:
            self.render('template/plugin/pluginUpload.html',data )
Ejemplo n.º 7
0
    def get(self):
        id = self.request.get('id', None)
        pluginid = self.request.get('pluginid', None)
        plugin = {}
        pluginVersionList = []
        if pluginid:
            plugin = Plugin.get_by_id(int(pluginid))
            pluginVersionList = PluginVersion.all().filter('plugin =', int(pluginid)).order('-versionnum')

        pluginVersion = {}
        if id:
            pluginVersion = PluginVersion.get_by_id(int(id))
            if not pluginid or pluginVersion.plugin != int(pluginid):
                plugin = Plugin.get_by_id(pluginVersion.plugin)

        self.render('template/plugin/pluginUpload.html',
                    {'plugin': plugin, 'pluginVersion': pluginVersion, 'pluginVersionList': pluginVersionList, 'id': id,
                     'pluginid': pluginid})
Ejemplo n.º 8
0
    def get(self):
        pluginid = self.request.get('pluginid', '')
        id = self.request.get('id', '')
        pluginVersionList=[]
        if pluginid:
            plugin = Plugin.get_by_id(int(pluginid))
            pluginVersionList = PluginVersion.all().filter('plugin =', int(pluginid)).order('-versionnum')

        pluginVersion = {}
        if id:
            pluginVersion = PluginVersion.get_by_id(int(id))
            if not pluginid or pluginVersion.plugin != int(pluginid):
                plugin = Plugin.get_by_id(pluginVersion.plugin)
        data={'plugin': plugin, 'pluginVersion': pluginVersion, 'pluginVersionList': pluginVersionList, 'id': id,
                     'pluginid': pluginid}
        upload_url = blobstore.create_upload_url('/upload?pluginversionid=%s'%(pluginVersion.key().id()))
        data['upload_url']=upload_url
        self.render('template/plugin/pluginUpload2.html',data)
Ejemplo n.º 9
0
 def get(self):
     pid = self.request.get('pluginid', None)
     if pid:
         p = Plugin.get_by_id(int(pid))
     pvid = self.request.get('id', None)
     if not pvid:
         pvlist = PluginVersion.all().filter('plugin =', int(pid)).order('-versionnum').fetch(1)
         if len(pvlist):
             pvid = pvlist[0].key().id()
     if pvid:
         pv = PluginVersion.get_by_id(int(pvid))
         if pv:
             if pv.datakey:
                 self.redirect('/serve/%s' % pv.datakey)
                 return
             self.response.headers['Content-Type'] = 'application/octet-stream'
             self.response.headers['Content-Length'] = pv.size
             self.response.out.write(pv.data)
             return
     self.error(404)
Ejemplo n.º 10
0
def jsonStrNotice(noticelist):
    nlist=[]
    for notice in noticelist:
        n={'title':notice.title, 'id':notice.key().id(),'content':[], 'isdel':notice.isdel, 'type':notice.type, 'lastUpdateTime':notice.lastUpdateTime.strftime('%Y-%m-%d %H:%M'), 'startdate':notice.startdate.strftime('%Y-%m-%d %H:%M'),'enddate':notice.enddate.strftime('%Y-%m-%d %H:%M')}
        if notice.type==1:
            for c in notice.content:
                n['content'].append(json.loads(c))
        if notice.type==2 and notice.plugin:
            plugin=Plugin.get_by_id(notice.plugin)
            n['pluginappcode']=plugin.appcode
            n['content'].append({'content':plugin.desc, 'type':'text'})

            pluginVersionList=PluginVersion.all().filter('plugin =',plugin.key().id()).order('-versionnum').fetch(1)
            if len(pluginVersionList):
                pluginVersion=pluginVersionList[0]
                n['content'].append({'content':pluginVersion.updateDesc, 'type':'text'})
                n['pluginimg']=notice.pluginimg
                for imgid in pluginVersion.imageids:
                    n['content'].append({'type': 'img', 'imgid': imgid, 'url': '%s/download?image_id=%s' % (WEBURL, imgid)})
        nlist.append(n)
    return nlist