Skip to content

Conversation

tchoumi313
Copy link
Contributor

@tchoumi313 tchoumi313 commented Sep 23, 2025

Adding the field ref_id to the folder models and making sure it shows up on both add/edit forms and detailsview of a folder

Summary by CodeRabbit

  • New Features

    • Folders now support an optional “Reference ID” field.
    • Add/Edit Folder form includes a Reference ID input.
    • Folder list view displays a new Reference ID column.
  • Chores

    • Updated ignore settings to exclude IDE files; no user-facing impact.

@tchoumi313 tchoumi313 self-assigned this Sep 23, 2025
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Adds a new optional ref_id field to the Folder model (backend), includes a corresponding migration, exposes the field in the Svelte Folder form, and updates folder list view columns to display ref_id. Also updates .gitignore to include .idea.

Changes

Cohort / File(s) Summary
Repo config
\.gitignore
Add .idea to ignore list; retain __pycache__ ignoring.
Backend model + migration
backend/iam/models.py, backend/iam/migrations/0015_folder_ref_id.py
Introduce Folder.ref_id: CharField(max_length=100, blank=True, null=True, verbose_name="reference ID") with corresponding Django migration.
Frontend form
frontend/src/lib/components/Forms/ModelForm/FolderForm.svelte
Import and render TextField for ref_id in the Folder form UI.
Frontend table config
frontend/src/lib/utils/table.ts
Update listViewFields.folders: add ref_id to head and body mappings; head: ['ref_id', 'name', 'description', 'parentDomain'], body: ['ref_id', 'name', 'description', 'parent_folder'].

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant F as FolderForm (Svelte)
  participant API as Backend API
  participant ORM as Django ORM

  rect rgba(200,230,255,0.3)
    note over U,F: Create/Update Folder with optional ref_id
    U->>F: Enter name/description/ref_id
    F->>API: POST /folders { name, description, ref_id?, ... }
    API->>ORM: save Folder(name, description, ref_id)
    ORM-->>API: Folder saved (id, ref_id, ...)
    API-->>F: 200 OK { folder }
    F-->>U: Show updated list with ref_id column
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • ab-smith

Poem

I nibbled the code and found a new ID,
A tiny ref_id sprouting like a seedling tree.
Forms now whisper, “Place it here,”
Tables gleam, a column clear.
With soft thumps, I hop with pride—
Folders tagged, neatly side by side. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the main change—adding the ref_id field to the Folder model—aligning with the pull request’s objectives and avoiding unnecessary detail.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-ref_id-to-folder

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.gitignore (1)

22-23: Normalize Python ignores for reliability and coverage

Use directory patterns and include bytecode files to avoid stray artifacts.

-__pycache__
-.idea
+__pycache__/
+**/__pycache__/
+*.py[cod]
+.idea
backend/iam/migrations/0015_folder_ref_id.py (1)

11-19: Migration matches model; add index if you index in the model

If you accept the db_index suggestion, reflect it here to avoid a follow‑up migration.

-            field=models.CharField(
-                blank=True, max_length=100, null=True, verbose_name="reference ID"
-            ),
+            field=models.CharField(
+                blank=True, max_length=100, null=True, db_index=True, verbose_name="reference ID"
+            ),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41aa1a2 and 29aeb59.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • backend/iam/migrations/0015_folder_ref_id.py (1 hunks)
  • backend/iam/models.py (1 hunks)
  • frontend/src/lib/components/Forms/ModelForm/FolderForm.svelte (2 hunks)
  • frontend/src/lib/utils/table.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
backend/iam/models.py (1)
backend/ebios_rm/models.py (1)
  • ref_id (900-901)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build_community_frontend
  • GitHub Check: build_enterprise_frontend
  • GitHub Check: test (3.12)
  • GitHub Check: enterprise-startup-docker-compose-test
  • GitHub Check: startup-docker-compose-test
  • GitHub Check: startup-functional-test (3.12)
  • GitHub Check: enterprise-startup-functional-test (3.12)
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
frontend/src/lib/components/Forms/ModelForm/FolderForm.svelte (2)

7-7: LGTM: Needed import added and used

Import is correct and utilized below.


33-34: Enforce ref_id maxlength=100 in UI

Mirror backend max_length=100 to avoid server-side validation failures — TextField forwards arbitrary props via {...rest}, and m.refId exists in frontend/messages/*.json.

-<TextField {form} field="ref_id" label={m.refId()} />
+<TextField {form} field="ref_id" label={m.refId()} maxLength={100} />
backend/iam/models.py (1)

105-107: Index ref_id for faster lists/search; consider serializer coverage

Folders are listed with ref_id and will likely be filtered/sorted. Add a DB index. Also ensure serializers expose ref_id so the UI column populates.

-    ref_id = models.CharField(
-        max_length=100, blank=True, null=True, verbose_name=_("reference ID")
-    )
+    ref_id = models.CharField(
+        max_length=100,
+        blank=True,
+        null=True,
+        db_index=True,
+        verbose_name=_("reference ID"),
+    )

Run to verify serializers expose ref_id (allowing for either explicit fields or __all__):

frontend/src/lib/utils/table.ts (1)

936-938: LGTM: Add ref_id to folder list columns

Consistent with backend and other list views that prioritize ref_id. Ensure API returns ref_id for folders.

@ab-smith ab-smith added the db-migration This branch contains migration files. Caution should be exercised when merging to avoid conflicts. label Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db-migration This branch contains migration files. Caution should be exercised when merging to avoid conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants