コード例 #1
0
ファイル: models.py プロジェクト: 1103785815/Flask-AppBuilder
 def photo_img(self):
     im = ImageManager()
     if self.photo:
         return Markup('<a href="' + url_for('ProductPubView.show',
                                             pk=str(self.id)) + '" class="thumbnail"><img src="' +
                       im.get_url(self.photo) + '" alt="Photo" class="img-rounded img-responsive"></a>')
     else:
         return Markup('<a href="' + url_for('ProductPubView.show',
                                             pk=str(self.id)) + '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
コード例 #2
0
 def photo_img_thumbnail(self):
     im = ImageManager()
     vn = self.ViewName()
     if self.photo:
         return Markup(
             '<a href="' + url_for(vn, pk=str(self.id)) +
             '" class="thumbnail"><img src="' +
             im.get_url_thumbnail(self.photo) +
             '" alt="Photo" class="img-rounded img-responsive"></a>')
     else:
         return Markup(
             '<a href="' + url_for(vn, pk=str(self.id)) +
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
         )
コード例 #3
0
 def vendor_img_thumbnail(self):
     im = ImageManager()
     if self.vendor_site_image:
         return Markup(
             '<a href="' +
             url_for('VendorSitesModelView.show', pk=str(self.id)) +
             '" class="thumbnail"><img src="' +
             im.get_url_thumbnail(self.vendor_site_image) +
             '" alt="Photo" class="img-rounded img-responsive"></a>')
     else:
         return Markup(
             '<a href="' +
             url_for('VendorSitesModelView.show', pk=str(self.id)) +
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
         )
コード例 #4
0
 def _image(self, name):
     im = ImageManager()
     imagen = getattr(self, name)
     if imagen:
         # url = url_for('ProductPubView.show', pk=str(self.id))
         # return Markup('<a href="' + url + '" class="thumbnail"><img src="' +
         #               im.get_url(imagen) + '" alt="Photo" class="img-rounded img-responsive"></a>')
         return Markup(
             '<center><img src="' + im.get_url(imagen) +
             '" alt="Photo" class="img-rounded img-responsive"></center>')
     else:
         # return Markup('<a href="' + url_for('ProductPubView.show', pk=str(self.id)) +
         #               '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
         #return Markup('<center><img src="//:0" alt="Photo" class="img-responsive"></center>')
         return ''
コード例 #5
0
    def show_images(self):

        thumbs = ImageManager()

        thumbs.relative_path = 'static/uploads/images/'

        SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
        # print SITE_ROOT
        paths = os.path.join(current_app.root_path, current_app.static_folder,
                             'uploads/images')
        print current_app.static_folder
        # print paths

        files = [
            thumbs.get_url(f) for f in os.listdir(config.IMG_UPLOAD_FOLDER)
            if os.path.isfile(os.path.join(config.IMG_UPLOAD_FOLDER, f))
        ]
        myfiles = self.appbuilder.get_session.query(Media).all()
        print self.appbuilder.static_url_path

        file_display = []

        for f in myfiles:

            fl = f.name

            # fpath = os.path.join(config.IMG_UPLOAD_FOLDER, fl)
            fpath = self.appbuilder.static_url_path + '/uploads/images/' + fl
            files, file_extension = os.path.splitext(fpath)
            th = files + '_thumb' + file_extension
            # size = os.path.getsize(os.path.join('/home/afidegnum/PycharmProjects/myfab/app/', f))
            # furl = os.path.getsize(os.path.join('/home/afidegnum/PycharmProjects/myfab/app/', f))
            json_display = {
                "deleteType": "DELETE",
                'name': fl,
                'url':
                self.appbuilder.static_url_path + '/uploads/images/' + fl,
                'thumbnailUrl': th,
                'deleteUrl': 'delete/' + fl,
                'size': 888
            }

            # file_saved = uploadfile(name=f, size=size)
            # file_saved.url = config.NEUTRAL_PATH + f
            file_display.append(json_display)

        return simplejson.dumps({"files": file_display})
コード例 #6
0
 def photo_img(self):
     im = ImageManager()
     if self.name:
         return Markup('<a href="' + url_for('DetectionModelView.show',pk=str(self.id)) +\
          '" class="thumbnail"><img src="' + "https://{}.blob.core.windows.net/{}/{}{}".format(
                                             os.getenv('STORAGE_ACCOUNT', ''), 
                                             os.getenv('STORAGE_CONTAINER', ''),
                                             self.name,
                                             os.getenv('SAS_STRING', '')) +\
           '" alt="Photo" class="img-responsive"></a>')
     else:
         return Markup('<a href="' + url_for('DetectionModelView.show',pk=str(self.id)) +\
          '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
コード例 #7
0
ファイル: views.py プロジェクト: afidegnum/myfab
 def upload_img(self):
     im = ImageManager()
     files = request.files['files']
     if files and im.is_file_allowed(files):
         sname = str(files)
         imgsize = im.resize(files, (200, 100, True))
         newname = im.generate_name(None, files)
         mpath = config.IMG_UPLOAD_FOLDER + newname
         newname = im.save_image(imgsize, mpath)
         print newname
     return 'success'
コード例 #8
0
	def photo_img_thumbnail(self):
		im = ImageManager()
コード例 #9
0
	def photo_img(self):
		im = ImageManager()
コード例 #10
0
    def add(self):
        ## post with json
        if request.is_json:
            name = request.json.get('name', None)
            login_qrcode_base64 = request.json.get('login_qrcode_base64', None)
            description = request.json.get('description', None)

            if name is None or login_qrcode_base64 is None:
                return self.response_400(message="Request payload is not JSON")

            s = self.datamodel.session
            #datamodel = SQLAInterface(Project)
            #datamodel.session = s

            #filters = datamodel.get_filters()
            #filters.add_filter('name', FilterEqual, name)
            #count, item = datamodel.query(filters=filters, page_size=1)
            #if count:
            #    item = item[0]
            #    pid = item.id
            #    datamodel = SQLAInterface(ProjectFiles)
            #    datamodel.session = s
            #    filters = datamodel.get_filters()
            #    filters.add_filter('project_id', FilterEqual, pid)
            #    count, child = datamodel.query(filters=filters, page_size=1)
            #    child = child[0]

            #else:
            #    item = datamodel.obj()
            #    item.name = name
            #    item.created_by_fk = 1
            #    item.changed_by_fk = 1

            #    datamodel.add(item)

            #    pid = item.id

            #    datamodel = SQLAInterface(ProjectFiles)
            #    datamodel.session = s
            #    child = datamodel.obj()

            datamodel = SQLAInterface(ProjectFiles, s)

            filters = datamodel.get_filters()
            filters.add_filter('name', FilterEqual, name)
            count, item = datamodel.query(filters=filters, page_size=1)
            if count:
                child = item[0]
            else:
                child = datamodel.obj()

            child.name = name
            #child.description = description # description now is line_id for user's
            child.login_qrcode_base64 = login_qrcode_base64
            datamodel.add(child)

        else:
            name = request.form.get('name')

            if not name:
                return self.response_400(message="Missing required parameter")

            if 'file' not in request.files:
                flash('No file part')
                return self.response_400(message="Missing file parameter")
            file = request.files['file']

            if file.filename == '':
                return self.response_400(message="no file select")
            #filename = secure_filename(file.filename)
            #file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            s = self.datamodel.session
            datamodel = SQLAInterface(Project)
            datamodel.session = s
            item = datamodel.obj()
            item.name = name
            item.created_by_fk = 1
            item.changed_by_fk = 1

            datamodel.add(item)
            pid = item.id

            im = ImageManager()
            filename = im.save_file(file, im.generate_name(file, file))

            datamodel = SQLAInterface(ProjectFiles)
            datamodel.session = s
            child = datamodel.obj()
            child.file = filename
            child.project = item
            child.description = request.form.get('description')
            datamodel.add(child)
        #datamodel._add_files(request, item)
        #log.warning("XX", item.id, "VV")

        return self.response(200, message=datamodel.message)
コード例 #11
0
ファイル: models.py プロジェクト: alxbetz/celltoxdb
    def dr_img(self):

        im = ImageManager()
        if self.plot_png:
            return Markup('<img src="' + im.get_url(self.plot_png) +\
              '" alt="Dose response plot" >')
コード例 #12
0
ファイル: quickfiles.py プロジェクト: arvin-chou/livechat
def receive_after_delete(mapper, connection, target):
    "listen for the 'after_delete' event"
    #log.error("target", target, target.file)
    if target.file:
        im = ImageManager()
        im.delete_file(target.file)