Edit of links and database versioning
This commit is contained in:
@@ -57,6 +57,24 @@ def list_public_links(username: str | None = None):
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
|
||||
def update_link(link_id: str, user_id: str, title: str, url: str, comment: str):
|
||||
cleaned_url = clean_url(url)
|
||||
with get_connection() as conn:
|
||||
cursor = conn.execute(
|
||||
'''
|
||||
UPDATE links
|
||||
SET title = ?, url = ?, comment = ?, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ? AND user_id = ?
|
||||
''',
|
||||
(title, cleaned_url, comment, link_id, user_id),
|
||||
)
|
||||
if cursor.rowcount == 0:
|
||||
return None
|
||||
conn.commit()
|
||||
row = conn.execute('SELECT * FROM links WHERE id = ?', (link_id,)).fetchone()
|
||||
return dict(row)
|
||||
|
||||
|
||||
def list_public_users():
|
||||
with get_connection() as conn:
|
||||
rows = conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user