-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[WEB-4716] chore: created new description model #7597
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
182 changes: 182 additions & 0 deletions
182
apps/api/plane/db/migrations/0101_description_descriptionversion.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,182 @@ | ||
| # Generated by Django 4.2.21 on 2025-08-19 11:52 | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
| import uuid | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("db", "0100_profile_has_marketing_email_consent_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="Description", | ||
| fields=[ | ||
| ( | ||
| "created_at", | ||
| models.DateTimeField(auto_now_add=True, verbose_name="Created At"), | ||
| ), | ||
| ( | ||
| "updated_at", | ||
| models.DateTimeField( | ||
| auto_now=True, verbose_name="Last Modified At" | ||
| ), | ||
| ), | ||
| ( | ||
| "deleted_at", | ||
| models.DateTimeField( | ||
| blank=True, null=True, verbose_name="Deleted At" | ||
| ), | ||
| ), | ||
| ( | ||
| "id", | ||
| models.UUIDField( | ||
| db_index=True, | ||
| default=uuid.uuid4, | ||
| editable=False, | ||
| primary_key=True, | ||
| serialize=False, | ||
| unique=True, | ||
| ), | ||
| ), | ||
| ("description_json", models.JSONField(blank=True, default=dict)), | ||
| ("description_html", models.TextField(blank=True, default="<p></p>")), | ||
| ("description_binary", models.BinaryField(null=True)), | ||
| ("description_stripped", models.TextField(blank=True, null=True)), | ||
| ( | ||
| "created_by", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="%(class)s_created_by", | ||
| to=settings.AUTH_USER_MODEL, | ||
| verbose_name="Created By", | ||
| ), | ||
| ), | ||
| ( | ||
| "project", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="project_%(class)s", | ||
| to="db.project", | ||
| ), | ||
| ), | ||
| ( | ||
| "updated_by", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="%(class)s_updated_by", | ||
| to=settings.AUTH_USER_MODEL, | ||
| verbose_name="Last Modified By", | ||
| ), | ||
| ), | ||
| ( | ||
| "workspace", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="workspace_%(class)s", | ||
| to="db.workspace", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Description", | ||
| "verbose_name_plural": "Descriptions", | ||
| "db_table": "descriptions", | ||
| "ordering": ("-created_at",), | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name="DescriptionVersion", | ||
| fields=[ | ||
| ( | ||
| "created_at", | ||
| models.DateTimeField(auto_now_add=True, verbose_name="Created At"), | ||
| ), | ||
| ( | ||
| "updated_at", | ||
| models.DateTimeField( | ||
| auto_now=True, verbose_name="Last Modified At" | ||
| ), | ||
| ), | ||
| ( | ||
| "deleted_at", | ||
| models.DateTimeField( | ||
| blank=True, null=True, verbose_name="Deleted At" | ||
| ), | ||
| ), | ||
| ( | ||
| "id", | ||
| models.UUIDField( | ||
| db_index=True, | ||
| default=uuid.uuid4, | ||
| editable=False, | ||
| primary_key=True, | ||
| serialize=False, | ||
| unique=True, | ||
| ), | ||
| ), | ||
| ("description_json", models.JSONField(blank=True, default=dict)), | ||
| ("description_html", models.TextField(blank=True, default="<p></p>")), | ||
| ("description_binary", models.BinaryField(null=True)), | ||
| ("description_stripped", models.TextField(blank=True, null=True)), | ||
| ( | ||
| "created_by", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="%(class)s_created_by", | ||
| to=settings.AUTH_USER_MODEL, | ||
| verbose_name="Created By", | ||
| ), | ||
| ), | ||
| ( | ||
| "description", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="versions", | ||
| to="db.description", | ||
| ), | ||
| ), | ||
| ( | ||
| "project", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="project_%(class)s", | ||
| to="db.project", | ||
| ), | ||
| ), | ||
| ( | ||
| "updated_by", | ||
| models.ForeignKey( | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="%(class)s_updated_by", | ||
| to=settings.AUTH_USER_MODEL, | ||
| verbose_name="Last Modified By", | ||
| ), | ||
| ), | ||
| ( | ||
| "workspace", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="workspace_%(class)s", | ||
| to="db.workspace", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Description Version", | ||
| "verbose_name_plural": "Description Versions", | ||
| "db_table": "description_versions", | ||
| "ordering": ("-created_at",), | ||
| }, | ||
| ), | ||
| ] |
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,56 @@ | ||
| from django.db import models | ||
| from django.utils.html import strip_tags | ||
| from .workspace import WorkspaceBaseModel | ||
|
|
||
|
|
||
| class Description(WorkspaceBaseModel): | ||
|
|
||
|
|
||
| description_json = models.JSONField(default=dict, blank=True) | ||
| description_html = models.TextField(blank=True, default="<p></p>") | ||
| description_binary = models.BinaryField(null=True) | ||
| description_stripped = models.TextField(blank=True, null=True) | ||
|
|
||
| class Meta: | ||
| verbose_name = "Description" | ||
| verbose_name_plural = "Descriptions" | ||
| db_table = "descriptions" | ||
| ordering = ("-created_at",) | ||
|
|
||
| def save(self, *args, **kwargs): | ||
| # Strip the html tags using html parser | ||
| self.description_stripped = ( | ||
| None | ||
| if (self.description_html == "" or self.description_html is None) | ||
NarayanBavisetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else strip_tags(self.description_html) | ||
| ) | ||
| super(Description, self).save(*args, **kwargs) | ||
sriramveeraghanta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
NarayanBavisetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| class DescriptionVersion(WorkspaceBaseModel): | ||
NarayanBavisetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| DescriptionVersion is a model used to store historical versions of a Description. | ||
| """ | ||
|
|
||
| description = models.ForeignKey( | ||
| "db.Description", on_delete=models.CASCADE, related_name="versions" | ||
| ) | ||
| description_json = models.JSONField(default=dict, blank=True) | ||
| description_html = models.TextField(blank=True, default="<p></p>") | ||
| description_binary = models.BinaryField(null=True) | ||
| description_stripped = models.TextField(blank=True, null=True) | ||
|
|
||
| class Meta: | ||
| verbose_name = "Description Version" | ||
| verbose_name_plural = "Description Versions" | ||
| db_table = "description_versions" | ||
| ordering = ("-created_at",) | ||
|
|
||
| def save(self, *args, **kwargs): | ||
| # Strip the html tags using html parser | ||
| self.description_stripped = ( | ||
| None | ||
| if (self.description_html == "" or self.description_html is None) | ||
| else strip_tags(self.description_html) | ||
| ) | ||
| super(DescriptionVersion, self).save(*args, **kwargs) | ||
NarayanBavisetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.