Beispiel #1
0
 def get_by_lower_email(workspace_id, email):
     query = """SELECT * FROM "user"
                             WHERE workspace_id = %i
                                 AND lower(email) = lower(%s)
                             LIMIT 1""" % (workspace_id,
                                           escape_pg_string(email))
     r = Session.execute(query)
     rr = r.fetchone()
     Session.rollback()
     return rr
Beispiel #2
0
Datei: user.py Projekt: tmbx/kas
 def get_by_lower_email(workspace_id, email):
     query = """SELECT * FROM "user"
                             WHERE workspace_id = %i
                                 AND lower(email) = lower(%s)
                             LIMIT 1""" % (
         workspace_id,
         escape_pg_string(email),
     )
     r = Session.execute(query)
     rr = r.fetchone()
     Session.rollback()
     return rr
Beispiel #3
0
 def requested_in_last_seconds(workspace_id, user_id, max_seconds):
     query = """SELECT * FROM wsrequest
                             WHERE workspace_id=%i
                                 AND user_id=%i
                                 AND (date_part('epoch', now()) - req_date) < %i
                                 ORDER BY req_date DESC
                                 LIMIT 1""" \
                             % ( workspace_id, user_id, max_seconds)
     log.debug("requested_in_last_seconds(): query='%s'." % ( query ) )
     r = Session.execute(query)
     rr = r.fetchone()
     Session.rollback()
     if rr:
         return True
     return False
Beispiel #4
0
 def requested_in_last_seconds(workspace_id, user_id, max_seconds):
     query = """SELECT * FROM wsrequest
                             WHERE workspace_id=%i
                                 AND user_id=%i
                                 AND (date_part('epoch', now()) - req_date) < %i
                                 ORDER BY req_date DESC
                                 LIMIT 1""" \
                             % ( workspace_id, user_id, max_seconds)
     log.debug("requested_in_last_seconds(): query='%s'." % (query))
     r = Session.execute(query)
     rr = r.fetchone()
     Session.rollback()
     if rr:
         return True
     return False
Beispiel #5
0
 def accepted_lately(workspace_id, user_id):
     max_seconds = 600
     query = """SELECT * FROM chatrequest 
                             WHERE workspace_id=%i 
                                 AND user_id=%i 
                                 AND accepted=True
                                 AND (date_part('epoch', now()) - accepted_date) < %i
                                 ORDER BY accepted_date DESC
                                 LIMIT 1""" \
                             % ( workspace_id, user_id, max_seconds)
     log.debug("accepted_in_last_seconds(): query='%s'." % ( query ) )
     r = Session.execute(query)
     rr = r.fetchone()
     Session.rollback()
     if rr:
         return True
     return False