Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ from firebase_admin import credentials
|
|
| 10 |
from firebase_admin import firestore
|
| 11 |
import json
|
| 12 |
from datetime import datetime
|
|
|
|
| 13 |
|
| 14 |
from typing import List, Optional, Dict
|
| 15 |
from google.oauth2 import service_account
|
|
@@ -72,6 +73,9 @@ business_cards_ss = 344204272
|
|
| 72 |
contacts_ss = 1943060316
|
| 73 |
sms_ss = 799147214
|
| 74 |
|
|
|
|
|
|
|
|
|
|
| 75 |
class SheetUpdateRequest(BaseModel):
|
| 76 |
target_sheet_id: int
|
| 77 |
data: list
|
|
@@ -273,6 +277,43 @@ async def update_user_sheet(spreadsheet_id:str, sheet_id:int, sheet_name, data:
|
|
| 273 |
body=update_body
|
| 274 |
).execute()
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
async def copy_sms_sheet(phone_no: str, spreadsheet_id: str):
|
| 277 |
requests = [
|
| 278 |
{
|
|
|
|
| 10 |
from firebase_admin import firestore
|
| 11 |
import json
|
| 12 |
from datetime import datetime
|
| 13 |
+
import pytz
|
| 14 |
|
| 15 |
from typing import List, Optional, Dict
|
| 16 |
from google.oauth2 import service_account
|
|
|
|
| 73 |
contacts_ss = 1943060316
|
| 74 |
sms_ss = 799147214
|
| 75 |
|
| 76 |
+
kst = pytz.timezone('Asia/Seoul')
|
| 77 |
+
|
| 78 |
+
|
| 79 |
class SheetUpdateRequest(BaseModel):
|
| 80 |
target_sheet_id: int
|
| 81 |
data: list
|
|
|
|
| 277 |
body=update_body
|
| 278 |
).execute()
|
| 279 |
|
| 280 |
+
# Format the cells
|
| 281 |
+
for row_index, row in enumerate(data):
|
| 282 |
+
for col_index, cell_value in enumerate(row):
|
| 283 |
+
if cell_value.startswith('=HYPERLINK'):
|
| 284 |
+
color = {"red": 0, "green": 0, "blue": 1} # Blue for hyperlinks
|
| 285 |
+
else:
|
| 286 |
+
color = {"red": 0, "green": 0, "blue": 0} # Black for other text
|
| 287 |
+
|
| 288 |
+
requests = [
|
| 289 |
+
{
|
| 290 |
+
"repeatCell": {
|
| 291 |
+
"range": {
|
| 292 |
+
"sheetId": sheet_id,
|
| 293 |
+
"startRowIndex": row_index + 1,
|
| 294 |
+
"endRowIndex": row_index + 2,
|
| 295 |
+
"startColumnIndex": col_index,
|
| 296 |
+
"endColumnIndex": col_index + 1
|
| 297 |
+
},
|
| 298 |
+
"cell": {
|
| 299 |
+
"userEnteredFormat": {
|
| 300 |
+
"textFormat": {
|
| 301 |
+
"foregroundColor": color
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
},
|
| 305 |
+
"fields": "userEnteredFormat.textFormat.foregroundColor"
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
]
|
| 309 |
+
|
| 310 |
+
response = sheet_service.spreadsheets().batchUpdate(
|
| 311 |
+
spreadsheetId=spreadsheet_id,
|
| 312 |
+
body={
|
| 313 |
+
'requests': requests
|
| 314 |
+
}
|
| 315 |
+
).execute()
|
| 316 |
+
|
| 317 |
async def copy_sms_sheet(phone_no: str, spreadsheet_id: str):
|
| 318 |
requests = [
|
| 319 |
{
|