示例#1
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)
示例#2
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
示例#3
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()
示例#4
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()
示例#5
0
class Persona(Node):
    element_type = 'persona'
    id = Integer(nullable=False)

    nombre_y_apellido = String(nullable=False)
    titulo = String()  # XXX puede ser una relacion
    prefijo = String()
    sufijo = String()
    cuit = Integer()
    dni = Integer()
    estado_civil = String()
    domicilio = String()
    boletines = String()
示例#6
0
class Person(Node):

    element_type = "person"

    name = String(nullable=False)
    age = Integer()
    is_adult = Bool()
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()
示例#8
0
class Contains(Relationship):
    label = "Contains"
    quantity = Integer(nullable=True)

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

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

    def get_edge(self):
        return {'from': self.inV(), 'to': self.inV()}
示例#9
0
class Budget(Node):
	"""A Budget node"""
	
	#
	#Class members
	#
	element_type = "budget"
	
	#
	#Node properties
	#
	price_level = Integer()
示例#10
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
class Repository(Node):

    element_type = "team"

    repository_url = String(nullable=False)
    repository_has_downloads = None (nullable=True)
    repository_created_at = String(nullable=False)
    repository_has_issues = None (nullable=True)
    repository_description = String(nullable=True)
    repository_forks = Integer(nullable=True)
    repository_fork = String(nullable=True)
    repository_has_wiki = None (nullable=True)
    repository_homepage = String(nullable=True)
    repository_size = Integer(nullable=True)
    repository_private = String(nullable=True)
    repository_name = String(nullable=True)
    repository_owner = String(nullable=True)
    repository_open_issues = Integer(nullable=True)
    repository_watchers = Integer(nullable=True)
    repository_pushed_at = String(nullable=True)
    repository_language = String(nullable=True)
    repository_organization = String(nullable=True)
    repository_integrate_branch = String(nullable=True)
    repository_master_branch = String(nullable=True)
示例#12
0
class User(Node):
	"""A user node"""
	#
	#Class members
	#
	element_type = "user"
	
	#
	#Node properties
	#
	name = String(nullable=True)
	age = Integer()
	gender = String(nullable=True)
	email = String(nullable=False)
	sportChosen = List()
	isAvailable = List()
class Address(BizBase, Node):
    element_type = 'Address'
    number = Integer()
    addition = String()

    @classmethod
    def new(cls,
            number,
            addition=None,
            city=None,
            zipcode=None,
            street=None,
            g=graph):
        """Create or retrieve new address. Number is mandatory, combination of city/street, 
        zipcode is mandatory, other params are optional."""
        c = City.new(name=city)
        z = Zipcode.new(code=zipcode)
        s = Street.new(name=street)
        a = g.Address.create(number=number, addition=addition)
        g.AddressCity.create(a, c)
        g.AddressZipcode.create(a, z)
        g.AddressStreet.create(a, s)
        return a
示例#14
0
class Dependencia(Node):
    element_type = 'dependencia'

    id = Integer(nullable=False)
    nombre = String(nullable=False)
示例#15
0
文件: thera.py 项目: whinis/Dramiel
class System(Node):
	element_type = "system"
	id = Integer()
	name = String(nullable=False)
	region = String(nullable=False)
	security = Float()
示例#16
0
class Votes(Relationship):
    label = 'votes'
    pro = Integer(nullable=False)  # 0: against ; 1: pro
    created = DateTime(default=current_datetime, nullable=False)
示例#17
0
class Person(Node):
    autoindex = True
    element_type = "person"
    name = String(nullable=False)
    age = Integer()
示例#18
0
class WebsiteHostsPage(Relationship):
    label = 'hosts'
    since = Integer()
    accessible = Boolean()
示例#19
0
class PersonaJuridica(Node):
    nombre = 'persona_juridica'

    id = Integer(nullable=False)
    cuit = Integer(nullable=False)
示例#20
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)
示例#21
0
class PartidoPolitico(Node):
    element_type = 'partido_politico'

    id = Integer(nullable=False)
    kind = String(nullable=False)
示例#22
0
class Coordinate(Node):
    element_type = "coordinate"
    lat = Integer()
    lon = Integer()
示例#23
0
class Tile(Node):
	element_type = 'tile'
	tile_type = String(nullable=False)
	production_number = Integer()
	x = Integer()
	y = Integer()
class Titan(Node):
    element_type = 'titan'

    name = String()
    age = Integer()
示例#25
0
class ContainsGeoInfo(Relationship):
    label = "containsGeoInfo"
    created = DateTime(default=current_datetime, nullable=False)
    occurence = Integer()
示例#26
0
class Puesto(Node):
    element_type = 'puesto'

    id = Integer(nullable=False)
    nombre = String(nullable=False)
示例#27
0
class Articulo(Node):
    element_type = 'articulo'

    id = Integer(nullable=False)
    texto = String(nullable=False)
示例#28
0
class Marked(Relationship):
    # user 1 -> 0..9 post
    __mode__ = STRICT
    label = "marked"

    color = Integer(nullable=False)