コード例 #1
0
ファイル: message.py プロジェクト: fozbek/devSeater
    def getDialogLastMessages(current_uid, other_uid, number):
        connection = Database.getConnection()
        cursor = connection.cursor(dictionary=True)
        try:
            query = """
      SELECT * FROM messages WHERE
      (
        (receiver_id = %s AND sender_id = %s AND isDeletedByReceiver = 0)
        OR 
        (receiver_id = %s AND sender_id = %s AND isDeletedBySender = 0) 
      ) 
      ORDER BY mid DESC LIMIT %s"""
            cursor.execute(
                query,
                (current_uid, other_uid, other_uid, current_uid, number))
            result = cursor.fetchall()

            #Marks as read
            query = """
      UPDATE messages SET isRead = 1
      WHERE
      receiver_id = %s AND sender_id = %s 
      """
            cursor.execute(query, (current_uid, other_uid))
            connection.commit()
        except Exception as e:
            print(e)
            return None

        finally:
            cursor.close()
            connection.close()
        return result
コード例 #2
0
ファイル: skill.py プロジェクト: fozbek/devSeater
  def addUserSkill(uid, skill):
    connection = Database.getConnection()
    cursor = connection.cursor(dictionary=True)

    try:
      if SkillModel.isThereThisSkill(skill):
        skid = SkillModel.getSkillByName(skill)["skid"]
      
      else:
        #Adding skill to the skills table
        query = "INSERT INTO skills(name) VALUES(%s)"
        cursor.execute(query, (skill,) )
        
        #Getting new added skill id
        skid = cursor.lastrowid

      #Adding user skill
      query = "INSERT INTO userSkills(uid, skid) VALUES(%s, %s)"
      cursor.execute(query, (uid, skid) )

      connection.commit()
    except Exception as e:
      print(e)
      return None
    finally:
      cursor.close()
      connection.close()
    return skid
コード例 #3
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def updateFullDescription(pid, fullDescription):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     query = "UPDATE projects SET full_description = %s WHERE pid = %s"
     cursor.execute(query, (fullDescription, pid))
     connection.commit()
     cursor.close()
     connection.close()
コード例 #4
0
ファイル: seater.py プロジェクト: fozbek/devSeater
 def rejectSeaterAspiration(uid, sid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE seaterAspirations SET isRejected = 1 WHERE  uid = %s AND sid = %s"
         cursor.execute(query, (uid, sid))
         connection.commit()
     except Exception as e:
         print(e)
     cursor.close()
     connection.close()
コード例 #5
0
ファイル: projectPost.py プロジェクト: fozbek/devSeater
 def updateProjectPostComment(ppcid, comment):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE projectPostComments SET comment = %s WHERE ppcid = %s"
         cursor.execute(query, (comment, ppcid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #6
0
ファイル: seater.py プロジェクト: fozbek/devSeater
 def cancelAspirationToTheSeater(uid, sid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "DELETE FROM seaterAspirations WHERE uid = %s AND sid = %s"
         cursor.execute(query, (uid, sid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #7
0
ファイル: seater.py プロジェクト: fozbek/devSeater
 def aspireSeater(uid, sid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "INSERT INTO seaterAspirations(sid, uid) VALUES(%s, %s)"
         cursor.execute(query, (sid, uid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #8
0
ファイル: seater.py プロジェクト: fozbek/devSeater
 def assignUser(uid, sid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE seaters SET uid = %s WHERE sid = %s"
         cursor.execute(query, (uid, sid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #9
0
ファイル: seater.py プロジェクト: fozbek/devSeater
 def removeSeater(sid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "DELETE FROM seaters WHERE sid = %s"
         cursor.execute(query, (sid, ))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #10
0
 def follow(followerId, followedId):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "INSERT INTO followers(flwrid, flwdid) VALUES(%s, %s)"
     cursor.execute(query, (followerId, followedId))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #11
0
 def unFollow(followerId, followedId):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "DELETE FROM followers WHERE flwrid = %s AND flwdid = %s"
     cursor.execute(query, (followerId, followedId))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #12
0
 def verifyEmail(email):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "UPDATE users SET isEmailVerified = 1 WHERE email = %s"
     cursor.execute(query, (email,) )
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #13
0
 def updateBio(uid, bio):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "UPDATE users SET bio = %s WHERE uid = %s"
     cursor.execute(query, (bio, uid))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #14
0
 def updateEmail(uid, email):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "UPDATE users SET email = %s, isEmailVerified = 0 WHERE uid = %s"
     cursor.execute(query, (email, uid))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #15
0
ファイル: projectPost.py プロジェクト: fozbek/devSeater
 def addProjectPost(uid, pid, post):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "INSERT INTO projectPosts(uid, pid, post) VALUES(%s, %s, %s)"
         cursor.execute(query, (uid, pid, post))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #16
0
ファイル: projectPost.py プロジェクト: fozbek/devSeater
 def unlikeProjectPostComment(uid, ppcid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "DELETE FROM projectPostCommentLikes WHERE uid = %s AND ppcid = %s"
         cursor.execute(query, (uid, ppcid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #17
0
 def updateFullname(uid, fullname):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "UPDATE users SET full_name = %s WHERE uid = %s"
     cursor.execute(query, (fullname, uid))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #18
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def updateProjectLink(plid, name, link):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE projectLinks SET name = %s, link = %s WHERE plid = %s"
         cursor.execute(query, (name, link, plid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #19
0
ファイル: skill.py プロジェクト: fozbek/devSeater
 def removeUserSkill(uid, skid):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "DELETE FROM userSkills WHERE uid = %s AND skid = %s"
     cursor.execute(query, (uid, skid) )
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #20
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def updateShortDescription(pid, shortDescription):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE projects SET short_description = %s WHERE pid = %s"
         cursor.execute(query, (shortDescription, pid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #21
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def removeProjectLink(plid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "DELETE FROM projectLinks WHERE plid = %s"
         cursor.execute(query, (plid, ))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #22
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def updateProjectName(pid, name):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "UPDATE projects SET project_name = %s WHERE pid = %s"
         cursor.execute(query, (name, pid))
         connection.commit()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
コード例 #23
0
 def removeContactMessage(cmid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "DELETE FROM contactMessages WHERE cmid = %s"
         cursor.execute(query, (cmid, ))
         connection.commit()
     except Exception as e:
         print(e)
         return
     finally:
         cursor.close()
         connection.close()
コード例 #24
0
 def addUser(user):
   user["password"] = sha256_crypt.encrypt(user["password"])
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "INSERT INTO users(email, username, password, full_name) VALUES(%s, %s, %s, %s)"
     cursor.execute(query, (user["email"], user["username"], user["password"], user["full_name"]) )
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #25
0
ファイル: skill.py プロジェクト: fozbek/devSeater
 def removeSeaterSkill(sid, skillName):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = """DELETE FROM seaterSkills WHERE sid = %s AND skid = 
               (SELECT skid FROM skills WHERE name = %s)"""
     cursor.execute(query, (sid, skillName) )
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #26
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def isThereThisProjectName(name):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "SELECT * FROM projects WHERE project_name = %s)"
         result = cursor.execute(query, (name, ))
         result = cursor.fetchone()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
     return (result != None)
コード例 #27
0
ファイル: project.py プロジェクト: fozbek/devSeater
 def isProjectAdmin(uid, pid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "SELECT * FROM projectAdmins WHERE uid = %s AND pid = %s"
         result = cursor.execute(query, (uid, pid))
         result = cursor.fetchone()
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
     return (result != None)
コード例 #28
0
ファイル: projectPost.py プロジェクト: fozbek/devSeater
 def getProjectPostCommentNumber(ppid):
     connection = Database.getConnection()
     cursor = connection.cursor(dictionary=True)
     try:
         query = "SELECT COUNT(*) AS number FROM projectPostComments WHERE ppid = %s"
         cursor.execute(query, (ppid, ))
         result = cursor.fetchone()["number"]
     except Exception as e:
         print(e)
     finally:
         cursor.close()
         connection.close()
     return result
コード例 #29
0
 def updatePassword(uid, password):
   password = sha256_crypt.encrypt(password)
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "UPDATE users SET password = %s WHERE uid = %s"
     cursor.execute(query, (password, uid))
     connection.commit()
   except Exception as e:
     print(e)
   finally:
     cursor.close()
     connection.close()
コード例 #30
0
ファイル: skill.py プロジェクト: fozbek/devSeater
 def getSkillByName(name):
   connection = Database.getConnection()
   cursor = connection.cursor(dictionary=True)
   try:
     query = "SELECT * FROM skills WHERE name = %s"
     result = cursor.execute(query, (name,) )
     result = cursor.fetchone()
   except Exception as e:
     print(e)
     return None
   finally:
     cursor.close()
     connection.close()
   return result