[WEB-5059] feat: add page creation functionality to workspace seeding process (#7948)

* feat: add page creation functionality to workspace seeding process

- Implemented `create_pages` function to create pages for each project in the workspace based on data from `pages.json`.
- Integrated page creation into the `workspace_seed` task, ensuring pages are created alongside project issues.
- Added a new `pages.json` seed file containing initial page data and descriptions.

* fix: update page creation logic and seed data

- Set `is_global` to `False` for pages created in the `create_pages` function.
- Adjusted the project type check to be case-insensitive in the page creation logic.
- Added `id`, `project_id`, and `description_stripped` fields to the `pages.json` seed data for improved page initialization.
This commit is contained in:
Nikhil 2025-10-10 18:32:15 +05:30 committed by GitHub
parent 8cd29c5009
commit 151674687c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 0 deletions

View file

@ -25,6 +25,8 @@ from plane.db.models import (
IssueLabel,
IssueSequence,
IssueActivity,
Page,
ProjectPage,
)
logger = logging.getLogger("plane.worker")
@ -272,6 +274,47 @@ def create_project_issues(
return
def create_pages(workspace: Workspace, project_map: Dict[int, uuid.UUID]) -> None:
"""Creates pages for each project in the workspace.
Args:
workspace: The workspace containing the projects
project_map: Mapping of seed project IDs to actual project IDs
"""
page_seeds = read_seed_file("pages.json")
if not page_seeds:
return
for page_seed in page_seeds:
page_id = page_seed.pop("id")
page = Page.objects.create(
workspace_id=workspace.id,
is_global=False,
name=page_seed.get("name"),
description=page_seed.get("description", {}),
description_html=page_seed.get("description_html", "<p></p>"),
description_binary=page_seed.get("description_binary", None),
description_stripped=page_seed.get("description_stripped", None),
created_by_id=workspace.created_by_id,
updated_by_id=workspace.created_by_id,
owned_by_id=workspace.created_by_id,
)
logger.info(f"Task: workspace_seed_task -> Page {page_id} created")
if page_seed.get("project_id") and page_seed.get("type") == "project":
ProjectPage.objects.create(
workspace_id=workspace.id,
project_id=project_map[page_seed.get("project_id")],
page_id=page.id,
created_by_id=workspace.created_by_id,
updated_by_id=workspace.created_by_id,
)
logger.info(f"Task: workspace_seed_task -> Project Page {page_id} created")
return
@shared_task
def workspace_seed(workspace_id: uuid.UUID) -> None:
"""Seeds a new workspace with initial project data.
@ -302,6 +345,9 @@ def workspace_seed(workspace_id: uuid.UUID) -> None:
# create project issues
create_project_issues(workspace, project_map, state_map, label_map)
# create project pages
create_pages(workspace, project_map)
logger.info(f"Task: workspace_seed_task -> Workspace {workspace_id} seeded successfully")
return
except Exception as e:

File diff suppressed because one or more lines are too long