Beispiel #1
0
def js_items(req, **kwargs):
    # size of thumb could be set from request
    thumb_size = req.args.getfirst('thumb_size', '320x200', str)
    pager = Pager(limit=-1)
    items = []
    for item in Attachment.list(req, pager, **kwargs):
        item.webname = item.webname()
        item.resize_hash = item.resize_hash(thumb_size)
        items.append(item.__dict__)
    req.content_type = 'application/json'
    return json.dumps({'items': items})
Beispiel #2
0
def admin_attachments(req):
    check_login(req)
    check_right(req, R_ADMIN)

    pager = Pager(order='timestamp', sort='desc')
    pager.bind(req.args)

    kwargs = {}

    if 'obty' in req.args:
        kwargs['object_type'] = req.args.getfirst('obty', fce=uni) or None
        pager.set_params(obty=kwargs['object_type'])
    if 'obid' in req.args:
        kwargs['object_id'] = req.args.getfirst('obid', fce=int)
        pager.set_params(obid=kwargs['object_id'])

    rows = Attachment.list(req, pager, **kwargs)
    return generate_page(req, "admin/attachments.html",
                         pager=pager, rows=rows)