Пример #1
0
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'))
Пример #2
0
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'))
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
def ajax_oembed():
    data = request.form.get('data')
    return Media.add_from_web(data)
Пример #6
0
def ajax_oembed_add():
    return Media.add_oembed(request.form)
Пример #7
0
def post_media():
    return Media.upload(request.files['qqfile'], request.form)