Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import sqlite3
|
| 3 |
from datetime import datetime
|
|
@@ -30,13 +31,25 @@ def init_db():
|
|
| 30 |
complaint_text TEXT,
|
| 31 |
status TEXT,
|
| 32 |
response TEXT,
|
| 33 |
-
timestamp TEXT
|
| 34 |
-
sender_comment TEXT
|
| 35 |
)''')
|
| 36 |
conn.commit()
|
| 37 |
conn.close()
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
init_db()
|
|
|
|
| 40 |
|
| 41 |
# إدارة حالة الجلسة
|
| 42 |
def init_session():
|
|
@@ -81,13 +94,11 @@ def sender_page():
|
|
| 81 |
conn = get_db_connection()
|
| 82 |
username = st.session_state.auth["username"]
|
| 83 |
|
| 84 |
-
# حساب عدد الشكاوى السابقة للمستخدم
|
| 85 |
user_complaint_count = conn.execute(
|
| 86 |
"SELECT COUNT(*) FROM complaints WHERE username = ?",
|
| 87 |
(username,)
|
| 88 |
).fetchone()[0]
|
| 89 |
|
| 90 |
-
# توليد معرف شكوى فريد
|
| 91 |
complaint_id = f"{username}_{user_complaint_count + 1:06d}"
|
| 92 |
|
| 93 |
if st.session_state.complaint_submitted:
|
|
@@ -119,7 +130,6 @@ def sender_page():
|
|
| 119 |
else:
|
| 120 |
st.warning("⚠️ لا يمكن إرسال شكوى فارغة")
|
| 121 |
|
| 122 |
-
# عرض الشكاوى السابقة
|
| 123 |
st.subheader("📋 الشكاوى السابقة")
|
| 124 |
complaints = conn.execute(
|
| 125 |
"SELECT * FROM complaints WHERE username = ? ORDER BY id DESC",
|
|
@@ -153,7 +163,6 @@ def sender_page():
|
|
| 153 |
# صفحة مستقبل الشكاوى
|
| 154 |
def receiver_page():
|
| 155 |
st.title("📬 إدارة الشكاوى")
|
| 156 |
-
|
| 157 |
conn = get_db_connection()
|
| 158 |
try:
|
| 159 |
pending_count = conn.execute(
|
|
|
|
| 1 |
+
|
| 2 |
import streamlit as st
|
| 3 |
import sqlite3
|
| 4 |
from datetime import datetime
|
|
|
|
| 31 |
complaint_text TEXT,
|
| 32 |
status TEXT,
|
| 33 |
response TEXT,
|
| 34 |
+
timestamp TEXT
|
|
|
|
| 35 |
)''')
|
| 36 |
conn.commit()
|
| 37 |
conn.close()
|
| 38 |
|
| 39 |
+
# التأكد من وجود عمود sender_comment
|
| 40 |
+
def ensure_sender_comment_column():
|
| 41 |
+
conn = get_db_connection()
|
| 42 |
+
cursor = conn.cursor()
|
| 43 |
+
cursor.execute("PRAGMA table_info(complaints)")
|
| 44 |
+
columns = [col[1] for col in cursor.fetchall()]
|
| 45 |
+
if "sender_comment" not in columns:
|
| 46 |
+
cursor.execute("ALTER TABLE complaints ADD COLUMN sender_comment TEXT")
|
| 47 |
+
conn.commit()
|
| 48 |
+
conn.close()
|
| 49 |
+
|
| 50 |
+
# استدعاء التهيئة
|
| 51 |
init_db()
|
| 52 |
+
ensure_sender_comment_column()
|
| 53 |
|
| 54 |
# إدارة حالة الجلسة
|
| 55 |
def init_session():
|
|
|
|
| 94 |
conn = get_db_connection()
|
| 95 |
username = st.session_state.auth["username"]
|
| 96 |
|
|
|
|
| 97 |
user_complaint_count = conn.execute(
|
| 98 |
"SELECT COUNT(*) FROM complaints WHERE username = ?",
|
| 99 |
(username,)
|
| 100 |
).fetchone()[0]
|
| 101 |
|
|
|
|
| 102 |
complaint_id = f"{username}_{user_complaint_count + 1:06d}"
|
| 103 |
|
| 104 |
if st.session_state.complaint_submitted:
|
|
|
|
| 130 |
else:
|
| 131 |
st.warning("⚠️ لا يمكن إرسال شكوى فارغة")
|
| 132 |
|
|
|
|
| 133 |
st.subheader("📋 الشكاوى السابقة")
|
| 134 |
complaints = conn.execute(
|
| 135 |
"SELECT * FROM complaints WHERE username = ? ORDER BY id DESC",
|
|
|
|
| 163 |
# صفحة مستقبل الشكاوى
|
| 164 |
def receiver_page():
|
| 165 |
st.title("📬 إدارة الشكاوى")
|
|
|
|
| 166 |
conn = get_db_connection()
|
| 167 |
try:
|
| 168 |
pending_count = conn.execute(
|