示例#1
0
def _errors(db, lang, params):
    results = query._gets(db, params)
    out = OrderedDict()

    if not params.full:
        out["description"] = ["lat", "lon", "error_id", "item"]
    else:
        out["description"] = ["lat", "lon", "error_id", "item", "source", "class", "elems", "subclass", "subtitle", "title", "level", "update", "username"]
    out["errors"] = []

    translate = utils.translator(lang)

    for res in results:
        lat       = res["lat"]
        lon       = res["lon"]
        error_id  = res["id"]
        item      = res["item"] or 0

        if not params.full:
            out["errors"].append([str(lat), str(lon), str(error_id), str(item)])
        else:
            source    = res["source"]
            classs    = res["class"]
            elems     = res["elems"]
            subclass  = res["subclass"]
            subtitle  = translate.select(res["subtitle"])
            title     = translate.select(res["title"])
            level     = res["level"]
            update    = res["timestamp"]
            username  = res["username"] or ""
            out["errors"].append([str(lat), str(lon), str(error_id), str(item), str(source), str(classs), str(elems), str(subclass), subtitle, title, str(level), str(update), username])

    return out
示例#2
0
def user(db, lang, username=None, format=None):
    params = query._params()
    if username:
        params.users = utils.pg_escape(username.decode("utf-8")).split(",")
    params.limit = 500
    params.full = True
    username = "******".join(params.users)

    if not params.users:
        return template('byuser/index', translate=utils.translator(lang))

    errors = query._gets(db, params)
    count = len(errors)
    if request.path.startswith("/api") or format == "json":
        out = OrderedDict()
        for res in errors:
            res["timestamp"] = str(res["timestamp"])
            res["lat"] = float(res["lat"])
            res["lon"] = float(res["lon"])
        out["issues"] = map(dict, errors)
        return out

    elif format == 'rss':
        response.content_type = "application/rss+xml"
        return template('byuser/byuser.rss', username=username, users=params.users, count=count, errors=errors, translate=utils.translator(lang), website=utils.website)

    else:
        return template('byuser/byuser', username=username, users=params.users, count=count, errors=errors, translate=utils.translator(lang), website=utils.website, main_website=utils.main_website, remote_url_read=utils.remote_url_read, html_escape=html_escape)
示例#3
0
def user(db, lang, username=None, format=None):
    params = query._params()
    if username:
        params.users = utils.pg_escape(username.decode("utf-8")).split(",")
    params.limit = 500
    params.full = True
    username = "******".join(params.users)

    if not params.users:
        return template('byuser/index')

    errors = query._gets(db, params)
    count = len(errors)
    if request.path.startswith("/api") or format == "json":
        out = OrderedDict()
        out["description"] = [
            "id", "item", "lat", "lon", "source", "class", "elems", "subclass",
            "subtitle", "comment", "title", "level", "timestamp", "menu",
            "username", "date"
        ]
        for res in errors:
            res["timestamp"] = str(res["timestamp"])
            res["date"] = str(res["date"])
        out["byusers"] = errors
        return out

    elif format == 'rss':
        response.content_type = "application/rss+xml"
        return template('byuser/byuser.rss',
                        username=username,
                        users=params.users,
                        count=count,
                        errors=errors,
                        translate=utils.translator(lang),
                        website=utils.website)

    else:
        return template('byuser/byuser',
                        username=username,
                        users=params.users,
                        count=count,
                        errors=errors,
                        translate=utils.translator(lang),
                        website=utils.website,
                        main_website=utils.main_website,
                        remote_url_read=utils.remote_url_read,
                        html_escape=html_escape)
示例#4
0
def users(db):
    out = OrderedDict()
    out["description"] = ["username", "count"]
    out["users"] = _users(db)
    return out