Exemple #1
0
 def terms_on_domain(self, *args, **kwargs):
     graph = dbutil.get_graph()
     domain = args[0]
     graph = dbutil.get_graph()
     u = graph.nodes.match("User", email=self.email)
     t = graph.nodes.match("Terms", domain=domain)
     ut = Relationship(u, "HAS", t)
     return graph.exists(ut)
Exemple #2
0
 def merge(*args, **kwargs):
     graph = dbutil.get_graph()
     user_instance = User(*args, **kwargs)
     tx = graph.begin()
     n = Node("User", **kwargs)
     tx.merge(n, primary_label='User', primary_key='email')
     tx.commit()
     user_instance.node = user_instance
     return user_instance
Exemple #3
0
 def log_event(self, *args, **kwargs):
     graph = dbutil.get_graph()
     tx = graph.begin()
     tag = kwargs['tag']
     u = graph.nodes.match("User", email=self.email)
     e = Node("Event", domain=domain, tag=tag)
     r = Relationship(u, "EMANATES", e)
     tx.create(e)
     tx.create(r)
     tx.commit()
Exemple #4
0
 def termify_domain(self, *args, **kwargs):
     domain = kwargs['domain']
     ip = kwargs['ip']
     graph = dbutil.get_graph()
     tx = graph.begin()
     u = graph.nodes.match("User", email=self.email)
     if (u.email in official_invites):
         t = Node("Terms", domain=domain, ip=ip)
         tx.create(Relationship(u, "AGREES", t))
         tx.commit()
         return True
     else:
         return False
Exemple #5
0
 def activation_on_domain(self, *args, **kwargs):
     graph = dbutil.get_graph()
     tx = graph.begin()
     u = graph.nodes.match("User", email=self.email).first()
     a = graph.nodes.match("Activation", domain=xweb.get_domain()).first()
     if (u and a):
         rlt = Relationship(u, a)
         records = graph.run(
             "MATCH ( u:User { email:$email} )-[r]-( a:Activation ) RETURN r",
             email=self.email,
             domain=xweb.get_domain())
         recs = records.data()
         recslen = len(recs)
         if (len(recs) > 0):
             return True
         else:
             return False
     else:
         return False
Exemple #6
0
 def apps_on_domain(self, *args, **kwargs):
     graph = dbutil.get_graph()
     apps = []
     domain = args[0] if args[0] else self.domain
     if self.logged_in() and self.activation_on_domain(domain):
         records = graph.run(
             "MATCH ( a:App )--( d:Domain { url:$url} ) RETURN a",
             email=self.email,
             url=domain)
         apps += [dict(x['a']) for x in records.data()]
     elif self.logged_in() and not self.activation_on_domain(domain):
         records = graph.run(
             "MATCH ( a:App ) WHERE a.identifier='logout' XOR a.type='contingency'  RETURN a"
         )
         apps += [dict(x['a']) for x in records.data()]
     else:
         records = graph.run("MATCH ( a:App { type:'auth'} ) RETURN a",
                             email=self.email)
         apps += [dict(x['a']) for x in records.data()]
     return apps