예제 #1
0
class Neuron(Node):
    element_type = "neuron"

    name = String(nullable=False)

    creation_time = DateTime(default=current_datetime, nullable=False)
    edition_time = DateTime(default=current_datetime, nullable=False)
예제 #2
0
class Proposal(Node):
    element_type = 'proposal'
    title = String(nullable=False)
    body = String(nullable=False)
    ups = Integer()
    downs = Integer()
    datetime_created = DateTime(default=current_datetime, nullable=False)
    datetime_modification = DateTime()
예제 #3
0
class Comment(Node):
    element_type = 'comment'
    title = String(nullable=False)
    body = String(nullable=False)
    ups = Integer()  # Redundant storage of upvotes
    downs = Integer()  # Redundant storage of downvotes
    datetime_created = DateTime(default=current_datetime, nullable=False)
    datetime_modification = DateTime()
예제 #4
0
class Product(BizBase, Node):
    "Product, categroy and product-instance. Will be detailed later on."
    element_type = 'Product'
    name = String(indexed=True)
    date_start = DateTime()
    date_activated = DateTime()
    date_end = DateTime()
    amount = Integer()
예제 #5
0
class Message(Node):

    element_type = "message"

    mid = String()  # Unique pseudo message ID
    hasImage = Null()  # With image? (1= Yes, 0=No)
    source = String()  #The application name of the client program
    text = String(nullable=False)  # body of the message
    created_at = DateTime(default=current_datetime,
                          nullable=False)  # Original posting time
    deleted_last_seen = DateTime(
    )  #The last seen time before this message was missing from the user timeline
    permission_denied = Null(
    )  # 'permission denied' status is marked when the message was found missing in the timeline and the API return message was 'permission denied' - See details in (Fu, Chan, Chau 2013)
예제 #6
0
class Votes(Relationship):
    label = 'votes'
    pro = Integer(nullable=False)  # -1: against , 1: pro , 0 : not voted
    cv = Integer(default=1, nullable=False)  # votecount
    delegated = Integer(default=0,
                        nullable=False)  # 0: not delegated , 1: delegated
    created = DateTime(default=current_datetime, nullable=False)
예제 #7
0
class Post(Node):
    __mode__ = STRICT
    element_type = "post"

    title = String(nullable=False)
    body = String(nullable=False)
    at = DateTime(default=current_datetime, nullable=False)
    root = Integer(default=0, nullable=False)

    x = Float(default=0, nullable=True)
    y = Float(default=0, nullable=True)

    tile_x = Integer(default=0, nullable=True)
    tile_y = Integer(default=0, nullable=True)

    @classmethod
    def get_proxy_class(cls):
        return PostProxy

    def parents(self):
        return sorted([element_to_model(e, Post) for e in self.inV("reply")],
                      key=lambda e: e.at,
                      reverse=True)

    def children(self):
        return sorted([element_to_model(e, Post) for e in self.outV("reply")],
                      key=lambda e: e.at,
                      reverse=True)

    def poster(self):
        return [element_to_model(e) for e in self.InV("posted")]

    def has_ancestor_any(self, needles):
        # TODO: Use aggregate/exclude to avoid searching the same parts of the
        # tree twice
        script = graph.scripts.get('has_ancestor_any')
        params = {
            'id': self.eid,
            'needle_ids': [needle.eid for needle in needles]
        }
        items = list(graph.gremlin.query(script, params))
        if len(items) > 0:
            return items[0]
        else:
            return None

    def save(self):
        self.tile_x = (self.x +
                       app.config['TILE_SIZE'] / 2) // app.config['TILE_SIZE']
        self.tile_y = (self.y +
                       app.config['TILE_SIZE'] / 2) // app.config['TILE_SIZE']
        super(Post, self).save()

    def __unicode__(self):
        result = unicode(self.eid)
        if self.title:
            result += " [%s]" % (unicode(self.title), )
        result += " posted on %s" % (unicode(self.at), )
        return result
예제 #8
0
class Person(Node):
    element_type = 'person'
    firstname = String(nullable=False)
    secondname = String(nullable=False)
    username = String(nullable=False)
    password = String(nullable=False)
    email = String(nullable=False)
    created = DateTime(default=current_datetime, nullable=False)
예제 #9
0
class LivesIn(Relationship):
	"""LivesIn relationship"""
	
	#
	#Class members
	#
	label = "lives_in"
	
	#
	#Relationship properties
	#
	created = DateTime(default=current_datetime, nullable=False)
예제 #10
0
class Chooses(Relationship):
	"""Chooses relationship"""
	
	#
	#Class members
	#
	label = "chooses"
	
	#
	#Relationship properties
	#
	created = DateTime(default=current_datetime, nullable=False)
예제 #11
0
class Assigns(Relationship):
	"""Assigns relationship"""
	
	#
	#Class members
	#
	element_type = "assigns"
	
	#
	#Relationship properties
	#
	created = DateTime(default=current_datetime, nullable=False)
예제 #12
0
파일: models.py 프로젝트: bigali/ecommerce
class Order(Node):
    element_type = "Order"
    label = "Order"
    created = DateTime(default=current_datetime, nullable=False)

    def get_url(self):
        return url_for('api.get_order', id=self.eid, _external=True)

    def export_data(self):
        return {'self_url': self.get_url(), 'date': self.created}

    def get_node(self):
        return {'id': self.eid, 'label': self.created}
예제 #13
0
class User(Node, UserMixin):
    __mode__ = STRICT
    element_type = "user"

    username = String(nullable=False, unique=True)
    password = String(nullable=False)
    joined = DateTime(default=current_datetime, nullable=False)
    active = Integer(nullable=False)

    def get_id(self):
        return self.username

    def is_active(self):
        return self.active
예제 #14
0
class Friend(Relationship):

    label = "friend"
    created = DateTime(default=current_datetime, nullable=False)

    @staticmethod
    def create(node1, node2):
        g.friend.create(node1,node2)

    @staticmethod
    def get(id):
        return g.friend.get(id)

    def get_id(self):
        return self.eid
예제 #15
0
class Likes(Relationship):

    label = "likes"
    created = DateTime(default=current_datetime, nullable=False)

    @staticmethod
    def create(node1, node2):#Necesita 2 objetos de tipo NODE (User o Local)
        g.likes.create(node1,node2)

    @staticmethod
    def get(id):
        return g.likes.get(id)

    def get_id(self):
        return self.eid
예제 #16
0
class HasPeople(Relationship):
    label = 'hasPeople'
    datetime_created = DateTime(default=current_datetime, nullable=False)
예제 #17
0
class Votes(Relationship):
    label = 'votes'
    pro = Integer(nullable=False)  # 0: against ; 1: pro
    created = DateTime(default=current_datetime, nullable=False)
예제 #18
0
class Delegation(Node):
    element_type = "delegation"
    time = Integer()  # 0: including past;
    # 1: excluding past; up from now on.
    datetime_created = DateTime(default=current_datetime, nullable=False)
예제 #19
0
class IsLocated(Relationship):
    label = "isLocated"
    created = DateTime(default=current_datetime, nullable=False)
예제 #20
0
class ContainsGeoInfo(Relationship):
    label = "containsGeoInfo"
    created = DateTime(default=current_datetime, nullable=False)
    occurence = Integer()
예제 #21
0
class IssuesComment(Relationship):
    label = 'issuesComment'
    created = DateTime(default=current_datetime, nullable=False)
예제 #22
0
class Knows(Relationship):

    label = "knows"
    timestamp = DateTime(default=current_datetime)
예제 #23
0
class Knows(Relationship):
    autoindex = True
    label = "knows"
    created = DateTime(default=current_datetime, nullable=False)
예제 #24
0
class Instance(Node):
    element_type = 'instance'
    title = String(nullable=False)
    body = String(nullable=False)
    datetime_created = DateTime(default=current_datetime, nullable=False)
예제 #25
0
class Parlament(Node):
    element_type = 'parlament'
    title = String(nullable=False)
    body = String(nullable=False)
    datetime_created = DateTime(default=current_datetime, nullable=False)
예제 #26
0
class DelProp(Node):
    element_type = "delProp"
    datetime_created = DateTime(default=current_datetime, nullable=False)