示例#1
0
def app_translation_serve_list():
    """
    Serves a list of translated apps, so that a cache can be updated.
    Aims to be SHINDIG-compatible, though it doesn't implement this feature yet.

    This is the new version (for the new ownership system). It is somewhat inefficient
    and the current etag scheme doesn't make much sense anymore.
    """

    # Get a list of distinct XMLs.
    specs = _db_get_diff_specs()

    output = {}

    for spec in specs:
        # For each spec we get the ownerships.
        ownerships = _db_get_ownerships(spec)

        bundles = []

        for ownership in ownerships:
            lang = ownership.value
            bm = BundleManager.create_from_existing_app(ownership.app.data)
            keys = [key for key in bm._bundles.keys() if BundleManager.fullcode_to_partialcode(key) == lang]

            etag = str(ownership.app.modification_date)
            bundles.append({"keys": keys, "etag": etag})

        output[spec] = {"bundles": bundles}

    response = make_response(json.dumps(output, indent=True))
    response.mimetype = "application/json"
    return response