mirror of
https://github.com/simon987/Simple-Incremental-Search-Tool.git
synced 2025-12-14 15:49:04 +00:00
Some work on users
This commit is contained in:
34
storage.py
34
storage.py
@@ -388,4 +388,36 @@ class LocalStorage:
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
conn.close()
|
||||
conn.close()
|
||||
|
||||
def set_access(self, username, dir_id, has_access):
|
||||
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
c = conn.cursor()
|
||||
|
||||
if has_access:
|
||||
try:
|
||||
c.execute("INSERT INTO User_canRead_Directory VALUES (?,?)", (username, dir_id))
|
||||
except sqlite3.IntegrityError:
|
||||
pass
|
||||
else:
|
||||
c.execute("DELETE FROM User_canRead_Directory WHERE username=? AND directory_id=?", (username, dir_id))
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
conn.close()
|
||||
|
||||
def get_access(self, username):
|
||||
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
c = conn.cursor()
|
||||
|
||||
c.execute("SELECT * FROM User_canRead_Directory WHERE username=?", (username,))
|
||||
|
||||
accesses = c.fetchall()
|
||||
access_list = []
|
||||
|
||||
for access in accesses:
|
||||
access_list.append(access[1])
|
||||
|
||||
return access_list
|
||||
Reference in New Issue
Block a user