def create(actor, filename, *args, **kwargs):
    permission_verify(actor, "blob", "create")

    upload_url = blobstore.create_upload_url(
        '/blob/uploaded?' + urllib.urlencode({'filename': filename}))
    log.debug("Created Upload URL: %s" % upload_url)
    return upload_url
Exemple #2
0
def issue_list(viewer):
    permission_verify(viewer, "issue", "read")
    result = []
    for issue in Issue.query().filter():
        issue.history = []
        result.append(viewer, to_model(issue, get_related_issues=False))

    return result
Exemple #3
0
def issue_list(viewer):
    permission_verify(viewer, "issue", "read")
    result = []
    for issue in Issue.query().filter():
        issue.history = []
        result.append(viewer, to_model(issue, get_related_issues=False))

    return result
Exemple #4
0
def asset_check_in(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "check_in_out")
    return checkout_to_model(
        actor,
        assets_private.check_in(actor,
                                asset_id=asset_id,
                                asset_key=asset_key,
                                **kwargs))
def get(actor, blob_id=None, blob_key=None, blob=None):
    permission_verify(actor, "blob", "read")

    result = blob or (blob_key or key(blob_id)).get()
    if result:
        return result
    else:
        raise NotFoundError()
def get(actor, blob_id=None, blob_key=None, blob=None):
    permission_verify(actor, "blob", "read")

    result = blob or (blob_key or key(blob_id)).get()
    if result:
        return result
    else:
        raise NotFoundError()
Exemple #7
0
def asset_create_or_update(actor, asset_id=None, asset_key=None, **kwargs):
    asset = assets_private.get(asset_id=asset_id, asset_key=asset_key)
    if asset:
        permission_verify(actor, "assets", "update")
        return asset_to_model(actor, assets_private.update(actor, asset=asset, **kwargs))
    else:
        permission_verify(actor, "assets", "create")
        return asset_to_model(actor, assets_private.create(actor, asset_id=asset_id, asset_key=asset_key, **kwargs))
Exemple #8
0
def issue_http_put(actor, issue_id, **kwargs):
    key = issue_key(issue_id)
    issue = key.get()
    if issue:
        permission_verify(actor, "issue", "update")
        return issue_update(actor, issue=issue, **kwargs)
    else:
        return issue_http_post(actor, key=key, issue_id=issue_id, **kwargs)
Exemple #9
0
def issue_http_put(actor, issue_id, **kwargs):
    key = issue_key(issue_id)
    issue = key.get()
    if issue:
        permission_verify(actor, "issue", "update")
        return issue_update(actor, issue=issue, **kwargs)
    else:
        return issue_http_post(actor, key=key, issue_id=issue_id, **kwargs)
Exemple #10
0
def asset_update(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "update")
    return asset_to_model(
        actor,
        assets_private.update(actor,
                              asset_id=asset_id,
                              asset_key=asset_key,
                              **kwargs))
Exemple #11
0
def issue_search(viewer, simple=None, query=None, complex=None):
    permission_verify(viewer, "issue", "read")

    if not complex:
        if query:
            complex = query_to_complex_search(query)
        else:
            # Status is open and assigned to me, or closing and verified by me.
            complex = { "boolean" : "or",
                        "sub"     : [ { "boolean" : "and",
                                        "sub"     : [ { "field"    : "status",
                                                        "operator" : "in",
                                                        "value"    : [ "triage", "assigned", "working" ] },
                                                      { "field"    : "assignees",
                                                        "operator" : "==",
                                                        "value"    : [ viewer ] } ] },
                                      { "boolean" : "and",
                                        "sub"     : [ { "field"    : "status",
                                                        "operator" : "in",
                                                        "value"    : [ "fixed", "rejected" ] },
                                                      { "field"    : "verifiers",
                                                        "operator" : "==",
                                                        "value"    : [ viewer ] } ] } ] }

    result = []
    ndb_query, first_sort = complex_search_to_ndb_query(complex)
    if permission_is_root(viewer):
        if ndb_query:
            dataset = Issue.query().filter(ndb_query)
        else:
            dataset = Issue.query().filter()
    else:
        privacy_query = ndb.OR(Issue.privacy == "public",
                               Issue.assignees == build_user_key(viewer),
                               Issue.reporters == build_user_key(viewer),
                               Issue.verifiers == build_user_key(viewer),
                               Issue.cc == build_user_key(viewer))
        if ndb_query:
            dataset = Issue.query().filter(ndb.AND(ndb_query, privacy_query))
        else:
            dataset = Issue.query().filter(privacy_query)

    if first_sort:
        dataset = dataset.order(first_sort)
    else:
        dataset = dataset.order(-Issue.score, -Issue.created)

    for issue in dataset:
        issue.history = []
        result.append(to_model(viewer, issue))

    return result
Exemple #12
0
def asset_create_or_update(actor, asset_id=None, asset_key=None, **kwargs):
    asset = assets_private.get(asset_id=asset_id, asset_key=asset_key)
    if asset:
        permission_verify(actor, "assets", "update")
        return asset_to_model(
            actor, assets_private.update(actor, asset=asset, **kwargs))
    else:
        permission_verify(actor, "assets", "create")
        return asset_to_model(
            actor,
            assets_private.create(actor,
                                  asset_id=asset_id,
                                  asset_key=asset_key,
                                  **kwargs))
Exemple #13
0
def asset_delete(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "delete")
    return assets_private.delete(actor, asset_id=asset_id, asset_key=asset_key)
Exemple #14
0
def issue_http_post(actor, **kwargs):
    permission_verify(actor, "issue", "create")

    return issue_create(actor, **kwargs)
Exemple #15
0
def asset_update(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "update")
    return asset_to_model(actor, assets_private.update(actor, asset_id=asset_id, asset_key=asset_key, **kwargs))
def create(actor, filename, *args, **kwargs):
    permission_verify(actor, "blob", "create")

    upload_url = blobstore.create_upload_url('/blob/uploaded?' + urllib.urlencode({'filename': filename}))
    log.debug("Created Upload URL: %s" % upload_url)
    return upload_url
Exemple #17
0
def asset_create(actor, *args, **kwargs):
    permission_verify(actor, "assets", "create")
    return asset_to_model(actor, assets_private.create(actor, *args, **kwargs))
def delete(actor, blob_id=None, blob_key=None, blob=None, **ignored):
    permission_verify(actor, "blob", "delete")
    blob = get(alias_id, alias_key, alias)
    blobstore.delete(blob.key.id())
    blob.delete()
def delete(actor, blob_id=None, blob_key=None, blob=None, **ignored):
    permission_verify(actor, "blob", "delete")
    blob = get(alias_id, alias_key, alias)
    blobstore.delete(blob.key.id())
    blob.delete()
Exemple #20
0
def asset_list(actor):
    permission_verify(actor, "assets", "read")
    return [
        asset_to_model(actor, asset) for asset in assets_private.list(actor)
    ]
Exemple #21
0
def asset_search(actor, **kwargs):
    permission_verify(actor, "assets", "read")
    return [
        asset_to_model(actor, asset)
        for asset in assets_private.search(actor, **kwargs)
    ]
Exemple #22
0
def issue_load(viewer, issue_id):
    permission_verify(viewer, "issue", "read")
    return to_model(viewer, issue_get(viewer, issue_id))
Exemple #23
0
def asset_load(actor, asset_id=None, asset_key=None):
    permission_verify(actor, "assets", "read")
    return asset_to_model(
        actor, assets_private.get(actor,
                                  asset_id=asset_id,
                                  asset_key=asset_key))
Exemple #24
0
def issue_search(viewer, simple=None, query=None, complex=None):
    permission_verify(viewer, "issue", "read")

    if not complex:
        if query:
            complex = query_to_complex_search(query)
        else:
            # Status is open and assigned to me, or closing and verified by me.
            complex = {
                "boolean":
                "or",
                "sub": [{
                    "boolean":
                    "and",
                    "sub": [{
                        "field": "status",
                        "operator": "in",
                        "value": ["triage", "assigned", "working"]
                    }, {
                        "field": "assignees",
                        "operator": "==",
                        "value": [viewer]
                    }]
                }, {
                    "boolean":
                    "and",
                    "sub": [{
                        "field": "status",
                        "operator": "in",
                        "value": ["fixed", "rejected"]
                    }, {
                        "field": "verifiers",
                        "operator": "==",
                        "value": [viewer]
                    }]
                }]
            }

    result = []
    ndb_query, first_sort = complex_search_to_ndb_query(complex)
    if permission_is_root(viewer):
        if ndb_query:
            dataset = Issue.query().filter(ndb_query)
        else:
            dataset = Issue.query().filter()
    else:
        privacy_query = ndb.OR(Issue.privacy == "public",
                               Issue.assignees == build_user_key(viewer),
                               Issue.reporters == build_user_key(viewer),
                               Issue.verifiers == build_user_key(viewer),
                               Issue.cc == build_user_key(viewer))
        if ndb_query:
            dataset = Issue.query().filter(ndb.AND(ndb_query, privacy_query))
        else:
            dataset = Issue.query().filter(privacy_query)

    if first_sort:
        dataset = dataset.order(first_sort)
    else:
        dataset = dataset.order(-Issue.score, -Issue.created)

    for issue in dataset:
        issue.history = []
        result.append(to_model(viewer, issue))

    return result
Exemple #25
0
def asset_list(actor):
    permission_verify(actor, "assets", "read")
    return [asset_to_model(actor, asset) for asset in assets_private.list(actor)]
Exemple #26
0
def asset_check_in(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "check_in_out")
    return checkout_to_model(actor, assets_private.check_in(actor, asset_id=asset_id, asset_key=asset_key, **kwargs))
Exemple #27
0
def asset_create(actor, *args, **kwargs):
    permission_verify(actor, "assets", "create")
    return asset_to_model(actor, assets_private.create(actor, *args, **kwargs))
Exemple #28
0
def issue_http_post(actor, **kwargs):
    permission_verify(actor, "issue", "create")

    return issue_create(actor, **kwargs)
Exemple #29
0
def asset_load(actor, asset_id=None, asset_key=None):
    permission_verify(actor, "assets", "read")
    return asset_to_model(actor, assets_private.get(actor, asset_id=asset_id, asset_key=asset_key))
Exemple #30
0
def asset_delete(actor, asset_id=None, asset_key=None, **kwargs):
    permission_verify(actor, "assets", "delete")
    return assets_private.delete(actor, asset_id=asset_id, asset_key=asset_key)
Exemple #31
0
def asset_search(actor, **kwargs):
    permission_verify(actor, "assets", "read")
    return [asset_to_model(actor, asset) for asset in assets_private.search(actor, **kwargs)]
Exemple #32
0
def issue_load(viewer, issue_id):
    permission_verify(viewer, "issue", "read")
    return to_model(viewer, issue_get(viewer, issue_id))