Spaces:
Building
Building
Update admin_routes.py
Browse files- admin_routes.py +31 -11
admin_routes.py
CHANGED
@@ -70,11 +70,21 @@ class EnvironmentUpdate(BaseModel):
|
|
70 |
class ProjectCreate(BaseModel):
|
71 |
name: str
|
72 |
caption: Optional[str] = ""
|
73 |
-
icon: Optional[str] = "folder"
|
74 |
-
description: Optional[str] = ""
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
class ProjectUpdate(BaseModel):
|
77 |
caption: str
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
last_update_date: str
|
79 |
|
80 |
class VersionCreate(BaseModel):
|
@@ -415,17 +425,21 @@ async def create_project(
|
|
415 |
):
|
416 |
cfg = load_config()
|
417 |
|
418 |
-
#
|
419 |
project_id = cfg["config"].get("project_id_counter", 0) + 1
|
420 |
cfg["config"]["project_id_counter"] = project_id
|
421 |
|
422 |
-
#
|
423 |
new_project = {
|
424 |
"id": project_id,
|
425 |
"name": project_data.name,
|
426 |
"caption": project_data.caption,
|
427 |
-
"icon": project_data.icon
|
428 |
-
"description": project_data.description
|
|
|
|
|
|
|
|
|
429 |
"enabled": False,
|
430 |
"deleted": False,
|
431 |
"created_date": datetime.utcnow().isoformat(),
|
@@ -433,10 +447,10 @@ async def create_project(
|
|
433 |
"last_update_date": datetime.utcnow().isoformat(),
|
434 |
"last_update_user": username,
|
435 |
|
436 |
-
#
|
437 |
"version_id_counter": 1,
|
438 |
|
439 |
-
#
|
440 |
"versions": [{
|
441 |
"id": 1,
|
442 |
"no": 1,
|
@@ -475,7 +489,7 @@ async def create_project(
|
|
475 |
"project", project_id, new_project["name"])
|
476 |
save_config(cfg)
|
477 |
|
478 |
-
return new_project
|
479 |
|
480 |
@router.put("/projects/{project_id}")
|
481 |
async def update_project(
|
@@ -495,8 +509,14 @@ async def update_project(
|
|
495 |
if project.get("last_update_date") != update.last_update_date:
|
496 |
raise HTTPException(status_code=409, detail="Project was modified by another user")
|
497 |
|
498 |
-
# Update
|
499 |
project["caption"] = update.caption
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
project["last_update_date"] = get_timestamp()
|
501 |
project["last_update_user"] = username
|
502 |
|
|
|
70 |
class ProjectCreate(BaseModel):
|
71 |
name: str
|
72 |
caption: Optional[str] = ""
|
73 |
+
icon: Optional[str] = "folder"
|
74 |
+
description: Optional[str] = ""
|
75 |
+
default_language: str = "Turkish"
|
76 |
+
supported_languages: List[str] = Field(default_factory=lambda: ["tr"])
|
77 |
+
timezone: str = "Europe/Istanbul"
|
78 |
+
region: str = "tr-TR"
|
79 |
+
|
80 |
class ProjectUpdate(BaseModel):
|
81 |
caption: str
|
82 |
+
icon: Optional[str] = "folder"
|
83 |
+
description: Optional[str] = ""
|
84 |
+
default_language: str = "Turkish"
|
85 |
+
supported_languages: List[str] = Field(default_factory=lambda: ["tr"])
|
86 |
+
timezone: str = "Europe/Istanbul"
|
87 |
+
region: str = "tr-TR"
|
88 |
last_update_date: str
|
89 |
|
90 |
class VersionCreate(BaseModel):
|
|
|
425 |
):
|
426 |
cfg = load_config()
|
427 |
|
428 |
+
# Yeni proje ID'si
|
429 |
project_id = cfg["config"].get("project_id_counter", 0) + 1
|
430 |
cfg["config"]["project_id_counter"] = project_id
|
431 |
|
432 |
+
# Proje gövdesi - yeni alanlarla
|
433 |
new_project = {
|
434 |
"id": project_id,
|
435 |
"name": project_data.name,
|
436 |
"caption": project_data.caption,
|
437 |
+
"icon": project_data.icon,
|
438 |
+
"description": project_data.description,
|
439 |
+
"default_language": project_data.default_language,
|
440 |
+
"supported_languages": project_data.supported_languages,
|
441 |
+
"timezone": project_data.timezone,
|
442 |
+
"region": project_data.region,
|
443 |
"enabled": False,
|
444 |
"deleted": False,
|
445 |
"created_date": datetime.utcnow().isoformat(),
|
|
|
447 |
"last_update_date": datetime.utcnow().isoformat(),
|
448 |
"last_update_user": username,
|
449 |
|
450 |
+
# Versiyon sayaçları
|
451 |
"version_id_counter": 1,
|
452 |
|
453 |
+
# İlk versiyon
|
454 |
"versions": [{
|
455 |
"id": 1,
|
456 |
"no": 1,
|
|
|
489 |
"project", project_id, new_project["name"])
|
490 |
save_config(cfg)
|
491 |
|
492 |
+
return new_project
|
493 |
|
494 |
@router.put("/projects/{project_id}")
|
495 |
async def update_project(
|
|
|
509 |
if project.get("last_update_date") != update.last_update_date:
|
510 |
raise HTTPException(status_code=409, detail="Project was modified by another user")
|
511 |
|
512 |
+
# Update - yeni alanlarla
|
513 |
project["caption"] = update.caption
|
514 |
+
project["icon"] = update.icon
|
515 |
+
project["description"] = update.description
|
516 |
+
project["default_language"] = update.default_language
|
517 |
+
project["supported_languages"] = update.supported_languages
|
518 |
+
project["timezone"] = update.timezone
|
519 |
+
project["region"] = update.region
|
520 |
project["last_update_date"] = get_timestamp()
|
521 |
project["last_update_user"] = username
|
522 |
|