def medias(): if not request.args.get('filter'): query = Media.select().order_by(Media.modified) else: query = Media.filter(Media.type == request.args.get('filter')).order_by(Media.modified) paginator = Paginator( query=query, page=request.args.get('page'), per_page=12 ) return render_template('admin/medias.html', medias=paginator.items, pages=paginator.links, title=gettext('Library - Medias'))
def medias(): if not request.args.get('filter'): query = Media.select().order_by(Media.modified) else: query = Media.filter( Media.type == request.args.get('filter')).order_by(Media.modified) paginator = Paginator(query=query, page=request.args.get('page'), per_page=12) return render_template('admin/medias.html', medias=paginator.items, pages=paginator.links, title=gettext('Library - Medias'))
def ajax_get_media(): media = Media.get(Media.id == request.args.get('id').replace('media_', '')) result = {} result['name'] = media.name result['icon'] = media.icon result['guid'] = media.guid if media.type == 'image': result['var'] = media.data['var'] if media.type == 'oembed': result['html'] = media.html return jsonify(data=result)
def ajax_oembed(): data = request.form.get('data') return Media.add_from_web(data)
def ajax_oembed_add(): return Media.add_oembed(request.form)
def post_media(): return Media.upload(request.files['qqfile'], request.form)