Beispiel #1
0
def get_releases_latest():
    """Return the latest release data
    From Data: count (int)
    Return: list of release dictionaries"""

    count = request.args.get("count", None)
    short = distutils.util.strtobool(request.args.get("short", "True"))

    try:
        count = int(count)
    except:
        count = 1

    entities = releases.Release.query.options(db.defer("_release_data")).filter(
        releases.Release.is_test_release == 0).order_by(
        releases.Release.id.desc()).limit(count)

    if not entities:
        entities = []
    elif current_user.admin:
        entities = [entity.to_small_dict() if short else entity.to_dict() for entity in entities]
    else:
        entities = [entity.to_small_dict() if short else entity.to_dict() for entity in entities]

    if len(entities) == 1:
        entities = entities[0]

    return Response(json.dumps(entities), mimetype="application/json")
Beispiel #2
0
    def as_list(self):
        """
        Return restricted list of columns for list queries
        """
        deferred_cols = ("subject", "sender_id", "recevier_id", "content")

        options = [db.defer(col) for col in deferred_cols]
        return self.options(*options)
Beispiel #3
0
    def as_list(self):
        """
        Return restricted list of columns for list queries
        """
        deferred_cols = ("subject", 
                         "sender_id",
                         "recevier_id",
                         "content")

        options = [db.defer(col) for col in deferred_cols]
        return self.options(*options)
Beispiel #4
0
    def as_list(self):
        """
        Return restricted list of columns for list queries
        """
        deferred_cols = ("description", "tags", "author.email",
                         "author.password", "author.activation_key",
                         "author.date_joined", "author.receive_email",
                         "author.email_alerts", "author.followers",
                         "author.following")

        options = [db.defer(col) for col in deferred_cols]
        return self.options(*options)
Beispiel #5
0
    def as_list(self):
        """
        Return restricted list of columns for list queries
        """
        deferred_cols = ("description", 
                         "tags",
                         "author.email",
                         "author.password",
                         "author.activation_key",
                         "author.date_joined",
                         "author.receive_email",
                         "author.email_alerts",
                         "author.followers",
                         "author.following")


        options = [db.defer(col) for col in deferred_cols]
        return self.options(*options)
Beispiel #6
0
def get_all_releases():
    """Return all releases in ThreatKB
    Return: list of release dictionaries"""
    entities = releases.Release.query.options(db.defer("_release_data")).filter_by().all()
    return Response(json.dumps([entity.to_small_dict() for entity in entities]), mimetype="application/json")