Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ build/
.react-router/
temp/
scripts/
temp_auto_push.bat
temp_interactive_push.bat
branch_structure.json
1 change: 1 addition & 0 deletions apps/admin/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;
14 changes: 6 additions & 8 deletions apps/api/plane/app/views/workspace/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ def get_queryset(self):

def create(self, request):
try:
(DISABLE_WORKSPACE_CREATION,) = get_configuration_value(
[
{
"key": "DISABLE_WORKSPACE_CREATION",
"default": os.environ.get("DISABLE_WORKSPACE_CREATION", "0"),
}
]
)
(DISABLE_WORKSPACE_CREATION,) = get_configuration_value([
{
"key": "DISABLE_WORKSPACE_CREATION",
"default": os.environ.get("DISABLE_WORKSPACE_CREATION", "0"),
}
])

if DISABLE_WORKSPACE_CREATION == "1":
return Response(
Expand Down
39 changes: 28 additions & 11 deletions apps/api/plane/bgtasks/workspace_seed_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create_project_and_member(workspace: Workspace, bot_user: User) -> Dict[int,
project_seed.pop("name", None)
project_seed.pop("identifier", None)

project = Project.objects.create(
project = Project(
**project_seed,
workspace=workspace,
name=workspace.name, # Use workspace name
Expand All @@ -105,6 +105,7 @@ def create_project_and_member(workspace: Workspace, bot_user: User) -> Dict[int,
module_view=True,
issue_views_view=True,
)
project.save(created_by_id=bot_user.id, disable_auto_set_user=True)

# Create project members
ProjectMember.objects.bulk_create(
Expand Down Expand Up @@ -191,13 +192,13 @@ def create_project_states(
state_id = state_seed.pop("id")
project_id = state_seed.pop("project_id")

state = State.objects.create(
state = State(
**state_seed,
project_id=project_map[project_id],
workspace=workspace,
created_by_id=bot_user.id,
)

state.save(created_by_id=bot_user.id, disable_auto_set_user=True)
state_map[state_id] = state.id
logger.info(f"Task: workspace_seed_task -> State {state_id} created")
return state_map
Expand All @@ -224,12 +225,13 @@ def create_project_labels(
for label_seed in label_seeds:
label_id = label_seed.pop("id")
project_id = label_seed.pop("project_id")
label = Label.objects.create(
label = Label(
**label_seed,
project_id=project_map[project_id],
workspace=workspace,
created_by_id=bot_user.id,
)
label.save(created_by_id=bot_user.id, disable_auto_set_user=True)
label_map[label_id] = label.id

logger.info(f"Task: workspace_seed_task -> Label {label_id} created")
Expand Down Expand Up @@ -276,13 +278,14 @@ def create_project_issues(
cycle_id = issue_seed.pop("cycle_id")
module_ids = issue_seed.pop("module_ids")

issue = Issue.objects.create(
issue = Issue(
**issue_seed,
state_id=states_map[state_id],
project_id=project_map[project_id],
workspace=workspace,
created_by_id=bot_user.id,
)
issue.save(created_by_id=bot_user.id, disable_auto_set_user=True)
Comment on lines +281 to +288

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 8 \
  'class BaseModel|class WorkspaceMember|def save|disable_auto_set_user|get_current_user' \
  apps/api/plane

rg -n -C 3 \
  'WorkspaceMember\.objects\.create|IssueSequence\.objects\.create|IssueActivity\.objects\.create|IssueLabel\.objects\.create|CycleIssue\.objects\.create|ModuleIssue\.objects\.create' \
  apps/api/plane/bgtasks/workspace_seed_task.py

Repository: makeplane/plane

Length of output: 50371


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workspace seed task relevant lines =="
sed -n '240,545p' apps/api/plane/bgtasks/workspace_seed_task.py

echo
echo "== BaseModel save =="
sed -n '1,45p' apps/api/plane/db/models/base.py

echo
echo "== WorkspaceMember model save inheritance =="
sed -n '188,212p' apps/api/plane/db/models/workspace.py

echo
echo "== Manager-based create occurrences in workspace_seed_task.py =="
rg -n -C 3 \
  '(IssueSequence|IssueActivity|IssueLabel|CycleIssue|ModuleIssue|WorkspaceMember)\.objects\.create' \
  apps/api/plane/bgtasks/workspace_seed_task.py

echo
echo "== Models save overrides relevant to create relationships =="
sed -n '145,215p' apps/api/plane/db/models/issue.py
sed -n '1,105p' apps/api/plane/db/models/label.py
sed -n '60,110p' apps/api/plane/db/models/cycle.py
sed -n '90,135p' apps/api/plane/db/models/module.py

Repository: makeplane/plane

Length of output: 23438


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate files matching IssueSequence/IssueActivity/IssueLabel models =="
fd -i 'issue.*\.py|label.*\.py|cycle.*\.py|module.*\.py|workspace.*\.py' apps/api/plane/db/models | sed -n '1,120p'

echo
echo "== class definitions and custom saves for related seed models =="
for f in apps/api/plane/db/models/issue.py apps/api/plane/db/models/label.py apps/api/plane/db/models/cycle.py apps/api/plane/db/models/module.py apps/api/plane/db/models/workspace.py; do
  echo "--- $f"
  rg -n -C 6 'class IssueSequence|class IssueActivity|class IssueLabel|class CycleIssue|class ModuleIssue|def save\(.*disable_auto_set_user|class .*BaseModel|class ProjectBaseModel' "$f"
done

echo
echo "== custom save usages in seed task =="
rg -n -C 2 '\.save\(created_by_id|disable_auto_set_user|objects\.create\(' apps/api/plane/bgtasks/workspace_seed_task.py

Repository: makeplane/plane

Length of output: 22254


Use the explicit audit-preserving save path for all seeded records.

WorkspaceMember.objects.create at lines 531-536 and the manager-level related issue record creation at lines 289-335 run BaseModel.save() without disable_auto_set_user=True. During seeded data creation, these models fall back to get_current_user() for created_by_id.

Construct the affected records and call save(created_by_id=bot_user.id, disable_auto_set_user=True) for WorkspaceMember, IssueSequence, IssueActivity, IssueLabel, CycleIssue, and ModuleIssue.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/plane/bgtasks/workspace_seed_task.py` around lines 281 - 288, Update
seeded record creation in the workspace seed task to use explicit
audit-preserving saves for WorkspaceMember, IssueSequence, IssueActivity,
IssueLabel, CycleIssue, and ModuleIssue. Construct each affected instance
instead of using manager-level create calls, then invoke save with bot_user.id
as created_by_id and disable_auto_set_user=True; preserve the existing field
values and relationships.

IssueSequence.objects.create(
issue=issue,
project_id=project_map[project_id],
Expand Down Expand Up @@ -351,7 +354,7 @@ def create_pages(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_us
for page_seed in page_seeds:
page_id = page_seed.pop("id")

page = Page.objects.create(
page = Page(
workspace_id=workspace.id,
is_global=False,
access=page_seed.get("access", Page.PUBLIC_ACCESS),
Expand All @@ -365,16 +368,18 @@ def create_pages(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_us
owned_by_id=bot_user.id,
)

page.save(created_by_id=bot_user.id, disable_auto_set_user=True)

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(
project_page = ProjectPage(
workspace_id=workspace.id,
project_id=project_map[page_seed.get("project_id")],
page_id=page.id,
created_by_id=bot_user.id,
updated_by_id=bot_user.id,
)

project_page.save(created_by_id=bot_user.id, disable_auto_set_user=True)
logger.info(f"Task: workspace_seed_task -> Project Page {page_id} created")
return

Expand Down Expand Up @@ -414,7 +419,7 @@ def create_cycles(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_u
start_date = timezone.now() + timedelta(days=14)
end_date = start_date + timedelta(days=14)

cycle = Cycle.objects.create(
cycle = Cycle(
**cycle_seed,
start_date=start_date,
end_date=end_date,
Expand All @@ -423,6 +428,7 @@ def create_cycles(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_u
created_by_id=bot_user.id,
owned_by_id=bot_user.id,
)
cycle.save(created_by_id=bot_user.id, disable_auto_set_user=True)

cycle_map[cycle_id] = cycle.id
logger.info(f"Task: workspace_seed_task -> Cycle {cycle_id} created")
Expand Down Expand Up @@ -450,14 +456,15 @@ def create_modules(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_
start_date = timezone.now() + timedelta(days=index * 2)
end_date = start_date + timedelta(days=14)

module = Module.objects.create(
module = Module(
**module_seed,
start_date=start_date,
target_date=end_date,
project_id=project_map[project_id],
workspace=workspace,
created_by_id=bot_user.id,
)
module.save(created_by_id=bot_user.id, disable_auto_set_user=True)
module_map[module_id] = module.id
logger.info(f"Task: workspace_seed_task -> Module {module_id} created")
return module_map
Expand All @@ -478,13 +485,15 @@ def create_views(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_us

for view_seed in view_seeds:
project_id = view_seed.pop("project_id")
IssueView.objects.create(
view_seed.pop("id")
issue_view = IssueView(
**view_seed,
project_id=project_map[project_id],
workspace=workspace,
created_by_id=bot_user.id,
owned_by_id=bot_user.id,
)
issue_view.save(created_by_id=bot_user.id, disable_auto_set_user=True)


@shared_task
Expand Down Expand Up @@ -518,6 +527,14 @@ def workspace_seed(workspace_id: uuid.UUID) -> None:
is_password_autoset=True,
)

# Add bot user to workspace as member
WorkspaceMember.objects.create(
workspace=workspace,
member=bot_user,
role=20,
company_role="",
)

# Create a project with the same name as workspace
project_map = create_project_and_member(workspace, bot_user)

Expand Down
1 change: 1 addition & 0 deletions apps/space/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;
1 change: 1 addition & 0 deletions apps/web/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;
1 change: 1 addition & 0 deletions packages/editor/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;
1 change: 1 addition & 0 deletions packages/propel/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;
1 change: 1 addition & 0 deletions packages/tailwind-config/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

export default {
plugins: {
// "tailwindcss/nesting": {},
Expand Down
1 change: 1 addition & 0 deletions packages/ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import postcssConfig from "@plane/tailwind-config/postcss.config.js";


export default postcssConfig;