Esempio n. 1
0
class Lane_connector(elixir.Entity, Road_item_with_polyline,
                     Road_item_with_obstacle_points):
    elixir.using_options(tablename="lane_connectors")
    lanes = elixir.ManyToMany("Lane")
    database_polyline = elixir.Field(elixir.Binary)
    obstacle_points = elixir.Field(elixir.Binary)
    turning_radius = elixir.Field(elixir.Float)
Esempio n. 2
0
class Game(elixir.Entity):
    """ 
        The Game model. Contains all information about a game
        and allows querying. Many games can have one user.
    """

    name = elixir.Field(elixir.String(40), unique=True)
    description = elixir.Field(elixir.String(512))
    image = elixir.Field(elixir.String(512))

    author = elixir.ManyToOne("User")
    platforms = elixir.ManyToMany("Platform")
    ratings = elixir.ManyToMany("Rating")
    event = elixir.ManyToOne("Event")

    def __repr__(self):
        return "<Game '%s' by %s>" % (self.name, self.author.name)
Esempio n. 3
0
class Rating(elixir.Entity):
    """ 
        The Rating model. Contains the a rating value.
		This value can be applied to a game and a user.
		Allows for checking game ratings and ratings a user has given.
    """

    value = elixir.Field(elixir.Float(4))
    games = elixir.ManyToMany("Game")
    user = elixir.ManyToOne("User")

    def __repr__(self):
        return "<Rating %s>" % (self.value)
Esempio n. 4
0
class Platform(elixir.Entity):
    """ 
        The Platform model. Contains the platform name and a download link.
        Allows for querying the platforms of a game, and all games of a
        platform. Many games can have many platforms.
    """

    name = elixir.Field(elixir.String(40))
    download = elixir.Field(elixir.String(512))
    games = elixir.ManyToMany("Game")

    def __repr__(self):
        return "<Platform '%s' (%s)>" % (self.name, self.download)
Esempio n. 5
0
class InterestClusterNS(Tree, elixir.Entity):
    elixir.using_options(tablename='interest_cluster_nested_set')
    id = elixir.Field(types.Integer, primary_key=True)
    lft = elixir.Field(types.Integer, colname='lft')
    rgt = elixir.Field(types.Integer, colname='rgt')
    _interests = elixir.ManyToMany('Tag', tablename='node_interests')
    centralInterests = elixir.ManyToMany('Tag',
                                         tablename='node_central_interests')

    def __init__(self, *args, **kwargs):
        elixir.Entity.__init__(self, *args, **kwargs)
        Tree.__init__(self)

    def interests(self):
        if len(self.children) > 0:
            return reduce(lambda acc, child: acc + child.interests(),
                          self.children, [])
        else:
            return self._interests

    def subtree(self):
        nodes = InterestClusterNS.query.from_statement(TREE_QUERY)\
            .params(parentId=self.id).all()
        return preorder2Tree([self] + nodes)
Esempio n. 6
0
class User(elixir.Entity):
    """ 
        The User model. Contains all information about a user
        and allows querying. One user can have many games
    """

    name = elixir.Field(elixir.String(40), unique=True)
    password = elixir.Field(elixir.String(512))
    email = elixir.Field(elixir.String(50))

    participated = elixir.ManyToMany("Event")
    games = elixir.OneToMany("Game")
    ratings = elixir.OneToMany("Rating")

    def __repr__(self):
        return "<User '%s' (%s)>" % (self.name, self.email)
Esempio n. 7
0
class Link(elixir.Entity):
    elixir.using_options(tablename="links")
    intersections = elixir.ManyToMany("Intersection")
    road_segments = elixir.OneToMany("Road_segment")
    road = elixir.ManyToOne("Road")

    def forward_road_segments(self):
        return [
            road_segment for road_segment in self.road_segment
            if road_segment.is_forward
        ]

    def reverse_road_segments(self):
        return [
            road_segment for road_segment in self.road_segment
            if not road_segment.is_forward
        ]
Esempio n. 8
0
class Lane(elixir.Entity, Road_item_with_polyline,
           Road_item_with_obstacle_points):
    """A lane represents a lane, in particularly the polyline field represents the lane's center-
    line; vehicles should be travelling along this polyline unless the driver intends to change
    lanes."""
    elixir.using_options(tablename="lanes")
    # "max_traffic_rules" is just a placeholder, it is not a valid rule.  The traffic_rules is
    # a string of '0' and '1', one for each of the rules above, not including "max_traffic_rules".
    traffic_rules = elixir.Field(elixir.Text,
                                 required=True,
                                 default='0' * (len(traffic_flags) - 1))
    database_polyline = elixir.Field(elixir.Binary)
    database_obstacle_points = elixir.Field(elixir.Binary)
    # A road segment has one or more lanes.  In each road-segment the lanes are numbered from right
    # to left when we are facing in the forward traffic flow.  The lane_index is the 0-based number.
    road_segment = elixir.ManyToOne("Road_segment")
    lane_index = elixir.Field(elixir.SmallInteger)
    width = elixir.Field(elixir.Float)
    lane_connectors = elixir.ManyToMany("Lane_connector")
Esempio n. 9
0
class Event(elixir.Entity):
    """
        The Event model. Contains all information regarding an event.
        This includes from when to when it's happening, the submitted games,
        and which users participated. Includes the theme.

        Many events can have many users and many games.
    """

    start = elixir.Field(elixir.DateTime(512))
    end = elixir.Field(elixir.DateTime(512))

    name = elixir.Field(elixir.String(512))
    theme = elixir.Field(elixir.String(256))
    voting = elixir.Field(elixir.Boolean())

    games = elixir.OneToMany("Game")
    participants = elixir.ManyToMany("User")

    def __repr__(self):
        return "<Event '%s' (%s - %s)>" % (self.name, self.start, self.end)
Esempio n. 10
0
class Movie(elixir.Entity):
    title = elixir.Field(elixir.String)
    director = elixir.Field(elixir.String)
    genre = elixir.ManyToMany('Genre')
    cast = elixir.OneToMany('Cast')
Esempio n. 11
0
class Intersection(elixir.Entity):
    elixir.using_options(tablename="intersections")
    links = elixir.ManyToMany("Link")
Esempio n. 12
0
 class Movie(e.Entity):
     title = e.Field(e.Unicode(30), primary_key=True)
     year = e.Field(e.Integer, primary_key=True)
     description = e.Field(e.UnicodeText, deferred=True)
     director = e.ManyToOne('Director')
     genres = e.ManyToMany('Genre')
Esempio n. 13
0
    class Genre(e.Entity):
        name = e.Field(e.Unicode(15), primary_key=True)
        movies = e.ManyToMany('Movie')

        def __repr__(self):
            return '<Genre "%s">' % self.name