-
Notifications
You must be signed in to change notification settings - Fork 239
Per-Project Tree of Collab Notes #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
BlaiseOfGlory
wants to merge
19
commits into
GhostManager:master
from
BlaiseOfGlory:feature-collab-notes
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f6d6e4e
Add hierarchical collaborative notes for projects
BlaiseOfGlory f861047
Update package-lock.json and make Docker ports configurable
BlaiseOfGlory b9500d3
Add drag-and-drop reorganization for hierarchical notes
BlaiseOfGlory 4f822ab
Increase indentation for hierarchical collab notes
BlaiseOfGlory bf20336
Add multi-field support for collaborative notes with images
BlaiseOfGlory 5b64e6a
Fix scrambled tree items during drag-and-drop
BlaiseOfGlory 22ea786
Fix uploaded images not rendering in collab notes editor
BlaiseOfGlory f528761
Fix image URLs missing /media/ prefix when loading from database
BlaiseOfGlory 9dbfe5d
Fix modal positioning in CreateModal for collab notes
BlaiseOfGlory 8f48ebb
Add real-time tree sync for collaborative notes
BlaiseOfGlory b211a96
Add confirmation dialog for deleting note fields
BlaiseOfGlory 7170fa6
Fix real-time sync of field additions between users
BlaiseOfGlory db5e366
Fix AddFieldToolbar dark mode support
BlaiseOfGlory 759d8eb
Add image field placeholder for collab notes
BlaiseOfGlory f0fe990
Add delete confirmation modal for notes and folders
BlaiseOfGlory 7cab167
Fix field reorder sync and improve tree item styling
BlaiseOfGlory 67b2332
Add collab notes zip export feature
BlaiseOfGlory fb87929
Reduce collab notes debounce from 5s to 2s
BlaiseOfGlory c367ef3
Update package-lock.json
BlaiseOfGlory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Generated manually for ProjectCollabNote model | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("rolodex", "0059_merge_20251027_1706"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="ProjectCollabNote", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.BigAutoField( | ||
| auto_created=True, | ||
| primary_key=True, | ||
| serialize=False, | ||
| verbose_name="ID", | ||
| ), | ||
| ), | ||
| ( | ||
| "title", | ||
| models.CharField( | ||
| help_text="Title of the note or folder", | ||
| max_length=255, | ||
| verbose_name="Title", | ||
| ), | ||
| ), | ||
| ( | ||
| "node_type", | ||
| models.CharField( | ||
| choices=[("folder", "Folder"), ("note", "Note")], | ||
| default="note", | ||
| help_text="Whether this is a folder or a note", | ||
| max_length=10, | ||
| verbose_name="Type", | ||
| ), | ||
| ), | ||
| ( | ||
| "content", | ||
| models.TextField( | ||
| blank=True, | ||
| default="", | ||
| help_text="Rich text content (for notes only, empty for folders)", | ||
| verbose_name="Content", | ||
| ), | ||
| ), | ||
| ( | ||
| "position", | ||
| models.PositiveIntegerField( | ||
| default=0, | ||
| help_text="Order within parent (lower values first)", | ||
| verbose_name="Position", | ||
| ), | ||
| ), | ||
| ("created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("updated_at", models.DateTimeField(auto_now=True)), | ||
| ( | ||
| "parent", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| help_text="Parent folder (null for root-level items)", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="children", | ||
| to="rolodex.projectcollabnote", | ||
| ), | ||
| ), | ||
| ( | ||
| "project", | ||
| models.ForeignKey( | ||
| help_text="The project this note belongs to", | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="collab_notes", | ||
| to="rolodex.project", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Project collaborative note", | ||
| "verbose_name_plural": "Project collaborative notes", | ||
| "ordering": ["position", "title"], | ||
| }, | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name="projectcollabnote", | ||
| constraint=models.CheckConstraint( | ||
| check=models.Q(("node_type", "note")) | models.Q(("content", "")), | ||
| name="folder_has_no_content", | ||
| ), | ||
| ), | ||
| ] |
45 changes: 45 additions & 0 deletions
45
ghostwriter/rolodex/migrations/0061_migrate_collab_notes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Data migration: Migrate existing Project.collab_note content to ProjectCollabNote | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def migrate_existing_notes(apps, schema_editor): | ||
| """Migrate existing collab_note content to new hierarchical model.""" | ||
| Project = apps.get_model("rolodex", "Project") | ||
| ProjectCollabNote = apps.get_model("rolodex", "ProjectCollabNote") | ||
|
|
||
| for project in Project.objects.exclude(collab_note="").exclude(collab_note__isnull=True): | ||
| ProjectCollabNote.objects.create( | ||
| project=project, | ||
| parent=None, | ||
| title="Migrated Notes", | ||
| node_type="note", | ||
| content=project.collab_note, | ||
| position=0, | ||
| ) | ||
|
|
||
|
|
||
| def reverse_migration(apps, schema_editor): | ||
| """Reverse: copy first note back to collab_note field.""" | ||
| Project = apps.get_model("rolodex", "Project") | ||
| ProjectCollabNote = apps.get_model("rolodex", "ProjectCollabNote") | ||
|
|
||
| for project in Project.objects.all(): | ||
| first_note = ProjectCollabNote.objects.filter( | ||
| project=project, | ||
| node_type="note", | ||
| ).order_by("position", "title").first() | ||
| if first_note: | ||
| project.collab_note = first_note.content | ||
| project.save(update_fields=["collab_note"]) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("rolodex", "0060_projectcollabnote"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(migrate_existing_notes, reverse_migration), | ||
| ] |
30 changes: 30 additions & 0 deletions
30
ghostwriter/rolodex/migrations/0062_projectcollabnote_timestamps_defaults.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Add database-level defaults for timestamp columns | ||
| # This is needed because GraphQL/Hasura inserts bypass Django ORM | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("rolodex", "0061_migrate_collab_notes"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunSQL( | ||
| sql=""" | ||
| ALTER TABLE rolodex_projectcollabnote | ||
| ALTER COLUMN created_at SET DEFAULT CURRENT_TIMESTAMP; | ||
|
|
||
| ALTER TABLE rolodex_projectcollabnote | ||
| ALTER COLUMN updated_at SET DEFAULT CURRENT_TIMESTAMP; | ||
| """, | ||
| reverse_sql=""" | ||
| ALTER TABLE rolodex_projectcollabnote | ||
| ALTER COLUMN created_at DROP DEFAULT; | ||
|
|
||
| ALTER TABLE rolodex_projectcollabnote | ||
| ALTER COLUMN updated_at DROP DEFAULT; | ||
| """, | ||
| ), | ||
| ] |
113 changes: 113 additions & 0 deletions
113
ghostwriter/rolodex/migrations/0063_projectcollabnotefield_and_more.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Generated by Django 4.2.16 on 2026-01-16 21:05 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("rolodex", "0062_projectcollabnote_timestamps_defaults"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="ProjectCollabNoteField", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.BigAutoField( | ||
| auto_created=True, | ||
| primary_key=True, | ||
| serialize=False, | ||
| verbose_name="ID", | ||
| ), | ||
| ), | ||
| ( | ||
| "field_type", | ||
| models.CharField( | ||
| choices=[("rich_text", "Rich Text"), ("image", "Image")], | ||
| default="rich_text", | ||
| help_text="Type of content in this field", | ||
| max_length=10, | ||
| verbose_name="Field Type", | ||
| ), | ||
| ), | ||
| ( | ||
| "content", | ||
| models.TextField( | ||
| blank=True, | ||
| default="", | ||
| help_text="HTML content for rich text fields", | ||
| verbose_name="Content", | ||
| ), | ||
| ), | ||
| ( | ||
| "image_width", | ||
| models.IntegerField( | ||
| blank=True, | ||
| editable=False, | ||
| null=True, | ||
| verbose_name="Image Width", | ||
| ), | ||
| ), | ||
| ( | ||
| "image_height", | ||
| models.IntegerField( | ||
| blank=True, | ||
| editable=False, | ||
| null=True, | ||
| verbose_name="Image Height", | ||
| ), | ||
| ), | ||
| ( | ||
| "image", | ||
| models.ImageField( | ||
| blank=True, | ||
| height_field="image_height", | ||
| help_text="Image file for image fields", | ||
| null=True, | ||
| upload_to="collab_note_images/%Y/%m/%d/", | ||
| verbose_name="Image", | ||
| width_field="image_width", | ||
| ), | ||
| ), | ||
| ( | ||
| "position", | ||
| models.PositiveIntegerField( | ||
| default=0, | ||
| help_text="Order within note (lower values first)", | ||
| verbose_name="Position", | ||
| ), | ||
| ), | ||
| ("created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("updated_at", models.DateTimeField(auto_now=True)), | ||
| ( | ||
| "note", | ||
| models.ForeignKey( | ||
| help_text="The note this field belongs to", | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="fields", | ||
| to="rolodex.projectcollabnote", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Project collaborative note field", | ||
| "verbose_name_plural": "Project collaborative note fields", | ||
| "ordering": ["note", "position"], | ||
| }, | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name="projectcollabnotefield", | ||
| constraint=models.CheckConstraint( | ||
| check=models.Q( | ||
| models.Q(("field_type", "rich_text"), ("image", "")), | ||
| models.Q( | ||
| ("field_type", "image"), models.Q(("image", ""), _negated=True) | ||
| ), | ||
| _connector="OR", | ||
| ), | ||
| name="field_type_matches_content", | ||
| ), | ||
| ), | ||
| ] |
49 changes: 49 additions & 0 deletions
49
ghostwriter/rolodex/migrations/0064_migrate_note_content_to_fields.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Generated by Django 4.2.16 on 2026-01-16 21:05 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def migrate_note_content_to_fields(apps, schema_editor): | ||
| """ | ||
| Migrate existing content from ProjectCollabNote.content to a new | ||
| ProjectCollabNoteField for each note that has content. | ||
| """ | ||
| ProjectCollabNote = apps.get_model("rolodex", "ProjectCollabNote") | ||
| ProjectCollabNoteField = apps.get_model("rolodex", "ProjectCollabNoteField") | ||
|
|
||
| notes_with_content = ProjectCollabNote.objects.filter(node_type="note").exclude(content="") | ||
|
|
||
| for note in notes_with_content: | ||
| # Create a rich_text field with the existing content at position 0 | ||
| ProjectCollabNoteField.objects.create( | ||
| note=note, | ||
| field_type="rich_text", | ||
| content=note.content, | ||
| position=0, | ||
| ) | ||
|
|
||
|
|
||
| def reverse_migration(apps, schema_editor): | ||
| """ | ||
| Reverse migration: copy field content back to note.content. | ||
| Only copies the first rich_text field. | ||
| """ | ||
| ProjectCollabNote = apps.get_model("rolodex", "ProjectCollabNote") | ||
| ProjectCollabNoteField = apps.get_model("rolodex", "ProjectCollabNoteField") | ||
|
|
||
| for note in ProjectCollabNote.objects.filter(node_type="note"): | ||
| # Get the first rich_text field | ||
| first_field = note.fields.filter(field_type="rich_text").order_by("position").first() | ||
| if first_field: | ||
| note.content = first_field.content | ||
| note.save() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("rolodex", "0063_projectcollabnotefield_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(migrate_note_content_to_fields, reverse_migration), | ||
| ] |
20 changes: 20 additions & 0 deletions
20
ghostwriter/rolodex/migrations/0065_add_defaults_to_timestamps.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Generated migration to add database defaults for timestamps | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("rolodex", "0064_migrate_note_content_to_fields"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunSQL( | ||
| sql="ALTER TABLE rolodex_projectcollabnotefield ALTER COLUMN created_at SET DEFAULT NOW();", | ||
| reverse_sql="ALTER TABLE rolodex_projectcollabnotefield ALTER COLUMN created_at DROP DEFAULT;", | ||
| ), | ||
| migrations.RunSQL( | ||
| sql="ALTER TABLE rolodex_projectcollabnotefield ALTER COLUMN updated_at SET DEFAULT NOW();", | ||
| reverse_sql="ALTER TABLE rolodex_projectcollabnotefield ALTER COLUMN updated_at DROP DEFAULT;", | ||
| ), | ||
| ] | ||
|
Comment on lines
+1
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is raw sql needed here? Django should have an ORM option for this |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
user_can_editmethod toProjectSyncTreeinstead of special casing