Exemplo n.º 1
0
    def fetch(self):
        try:
            c, conn = connection()
            c.execute("SELECT * FROM issue WHERE issue_id='{}';".format(self.issueID))
            result_set = c.fetchall()
            conn.close()

            # Check the results
            if(len(result_set) == 1):
                for row in result_set:
                    self.title = row["title"]
                    self.description = row["description"]
                    self.status = row["status"]
                    self.instructionBox = row["instruction_box"]
                    self.instructions = row["instructions"]
                    self.active = row["active"]
                    self.createdDate = row["created_date"]
                    self.modifiedDate = row["modified_date"]

                return True
                    
            else:
                # There wasn't a row with that ID
                return False

        except Exception as e:
            return(e)
Exemplo n.º 2
0
    def get(self, user_id):
        try:
            c, conn = connection()
            c.execute(
                "SELECT system_user_id, email, username, password FROM techboard.system_user WHERE system_user_id={};"
                .format(int(ord(user_id))))
            result_set = c.fetchall()
            conn.close()

            # Check the results
            if (len(result_set) == 1):
                for row in result_set:
                    self.userID = row['system_user_id']
                    self.email = row['email']
                    self.username = row['username']
                    self.user_id = chr(row['system_user_id'])
                    self.is_authenticated = True
                    self.is_anonymous = True
                    self.is_active = True
                    return self
            else:
                # Something isn't right
                return None

        except Exception as e:
            return (self)
Exemplo n.º 3
0
    def makeUserFromCreds(self):
        try:
            c, conn = connection()
            c.execute(
                "SELECT system_user_id, email, username, password, salt FROM techboard.system_user WHERE username='******';"
                .format(str(self.username)))
            result_set = c.fetchall()
            conn.close()

            # Check the results
            if (len(result_set) == 1):
                for row in result_set:
                    self.userID = row['system_user_id']
                    self.username = row['username']
                    self.email = row['email']
                    self.user_id = chr(row['system_user_id'])
                    realPassword = row['password']
                    self.salt = row['salt']
                    hashedPassword = hashlib.sha512(
                        self.password + self.salt.encode('utf-8')).hexdigest()
                    if hashedPassword == realPassword:
                        self.is_authenticated = True
                        self.is_anonymous = True
                        self.is_active = True
                        return True
                    else:
                        return False
            else:
                # Something isn't right
                return False

        except Exception as e:
            return str(e)
Exemplo n.º 4
0
def showIssues():
    try:
        c, conn = connection()
        c.execute("SELECT * FROM techBoard.issue WHERE active = 1;")
        result_set = c.fetchall()
        conn.close()

        return render_template('public/issues.html', issues=result_set)

    except Exception as e:
        return str(e)
Exemplo n.º 5
0
    def update(self):
        try:
            c, conn = connection()
            sql = "UPDATE techboard.issue SET title=%s, description=%s, status=%s, instruction_box=%s, instructions=%s, active=%s WHERE issue_id = %s;"
            c.execute(sql,(self.title,self.description,self.status,self.instructionBox,self.instructions,self.active,self.issueID))
            conn.commit()
            conn.close()

            return True

        except Exception as e:
            return(e)
Exemplo n.º 6
0
 def createUser(self):
     try:
         c, conn = connection()
         c.execute(
             "INSERT INTO systemuser (email,lastname,firstname,password,salt) VALUES (%s,%s,%s,%s,%s);",
             (self.email, self.lastName, self.firstName, self.password,
              self.salt))
         conn.commit()
         conn.close()
         return "<p> Create Successfully </p>"
     except Exception as e:
         return str(e)
Exemplo n.º 7
0
    def store(self):
        try:
            c, conn = connection()
            preSql = "INSERT INTO techboard.issue (title, description, status, instruction_box, instructions, active) "
            valuesSql = "VALUES(%s,%s,%s,%s,%s,%s);"
            c.execute(preSql+valuesSql,(self.title,self.description,self.status,self.instructionBox,self.instructions,self.active))
            conn.commit()
            conn.close()

            return True

        except Exception as e:
            return(e)
Exemplo n.º 8
0
def manageIssues():
    try:
        c, conn = connection()
        c.execute(
            "SELECT * FROM techBoard.issue WHERE active = 1 OR CURRENT_DATE - modified_date <= 7 ORDER BY created_date DESC;"
        )
        result_set = c.fetchall()
        conn.close()

        return render_template('manage/manageIssues.html', issues=result_set)

    except Exception as e:
        return str(e)