[WEB-5845] chore: changing description field to description json (#8230)
* chore: migrating description to description json * chore: replace description with description_json * chore: updated migration file * chore: updated the migration file * chore: added description key in external endpoint * chore: updated the migration file * chore: updated the typo --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
This commit is contained in:
parent
6c8779c8d3
commit
2a29ab8d4a
26 changed files with 85 additions and 54 deletions
|
|
@ -13,11 +13,14 @@ class IssueForIntakeSerializer(BaseSerializer):
|
|||
content validation and priority assignment for triage workflows.
|
||||
"""
|
||||
|
||||
description = serializers.JSONField(source="description_json", required=False, allow_null=True)
|
||||
|
||||
class Meta:
|
||||
model = Issue
|
||||
fields = [
|
||||
"name",
|
||||
"description",
|
||||
"description", # Deprecated
|
||||
"description_json",
|
||||
"description_html",
|
||||
"priority",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class IssueSerializer(BaseSerializer):
|
|||
class Meta:
|
||||
model = Issue
|
||||
read_only_fields = ["id", "workspace", "project", "updated_by", "updated_at"]
|
||||
exclude = ["description", "description_stripped"]
|
||||
exclude = ["description_json", "description_stripped"]
|
||||
|
||||
def validate(self, data):
|
||||
if (
|
||||
|
|
@ -633,6 +633,7 @@ class IssueExpandSerializer(BaseSerializer):
|
|||
labels = serializers.SerializerMethodField()
|
||||
assignees = serializers.SerializerMethodField()
|
||||
state = StateLiteSerializer(read_only=True)
|
||||
description = serializers.JSONField(source="description_json", read_only=True)
|
||||
|
||||
def get_labels(self, obj):
|
||||
expand = self.context.get("expand", [])
|
||||
|
|
|
|||
|
|
@ -180,11 +180,14 @@ class IntakeIssueListCreateAPIEndpoint(BaseAPIView):
|
|||
)
|
||||
|
||||
# create an issue
|
||||
issue_data = request.data.get("issue", {})
|
||||
# Accept both "description" and "description_json" keys for the description_json field
|
||||
description_json = issue_data.get("description") or issue_data.get("description_json") or {}
|
||||
issue = Issue.objects.create(
|
||||
name=request.data.get("issue", {}).get("name"),
|
||||
description=request.data.get("issue", {}).get("description", {}),
|
||||
description_html=request.data.get("issue", {}).get("description_html", "<p></p>"),
|
||||
priority=request.data.get("issue", {}).get("priority", "none"),
|
||||
name=issue_data.get("name"),
|
||||
description_json=description_json,
|
||||
description_html=issue_data.get("description_html", "<p></p>"),
|
||||
priority=issue_data.get("priority", "none"),
|
||||
project_id=project_id,
|
||||
state_id=triage_state.id,
|
||||
)
|
||||
|
|
@ -365,10 +368,11 @@ class IntakeIssueDetailAPIEndpoint(BaseAPIView):
|
|||
|
||||
# Only allow guests to edit name and description
|
||||
if project_member.role <= 5:
|
||||
description_json = issue_data.get("description") or issue_data.get("description_json") or {}
|
||||
issue_data = {
|
||||
"name": issue_data.get("name", issue.name),
|
||||
"description_html": issue_data.get("description_html", issue.description_html),
|
||||
"description": issue_data.get("description", issue.description),
|
||||
"description_json": description_json,
|
||||
}
|
||||
|
||||
issue_serializer = IssueSerializer(issue, data=issue_data, partial=True)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class IssueFlatSerializer(BaseSerializer):
|
|||
fields = [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"description_json",
|
||||
"description_html",
|
||||
"priority",
|
||||
"start_date",
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class PageSerializer(BaseSerializer):
|
|||
labels = validated_data.pop("labels", None)
|
||||
project_id = self.context["project_id"]
|
||||
owned_by_id = self.context["owned_by_id"]
|
||||
description = self.context["description"]
|
||||
description_json = self.context["description_json"]
|
||||
description_binary = self.context["description_binary"]
|
||||
description_html = self.context["description_html"]
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class PageSerializer(BaseSerializer):
|
|||
# Create the page
|
||||
page = Page.objects.create(
|
||||
**validated_data,
|
||||
description=description,
|
||||
description_json=description_json,
|
||||
description_binary=description_binary,
|
||||
description_html=description_html,
|
||||
owned_by_id=owned_by_id,
|
||||
|
|
@ -171,7 +171,7 @@ class PageBinaryUpdateSerializer(serializers.Serializer):
|
|||
|
||||
description_binary = serializers.CharField(required=False, allow_blank=True)
|
||||
description_html = serializers.CharField(required=False, allow_blank=True)
|
||||
description = serializers.JSONField(required=False, allow_null=True)
|
||||
description_json = serializers.JSONField(required=False, allow_null=True)
|
||||
|
||||
def validate_description_binary(self, value):
|
||||
"""Validate the base64-encoded binary data"""
|
||||
|
|
@ -214,8 +214,8 @@ class PageBinaryUpdateSerializer(serializers.Serializer):
|
|||
if "description_html" in validated_data:
|
||||
instance.description_html = validated_data.get("description_html")
|
||||
|
||||
if "description" in validated_data:
|
||||
instance.description = validated_data.get("description")
|
||||
if "description_json" in validated_data:
|
||||
instance.description_json = validated_data.get("description_json")
|
||||
|
||||
instance.save()
|
||||
return instance
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ class IntakeIssueViewSet(BaseViewSet):
|
|||
issue_data = {
|
||||
"name": issue_data.get("name", issue.name),
|
||||
"description_html": issue_data.get("description_html", issue.description_html),
|
||||
"description": issue_data.get("description", issue.description),
|
||||
"description_json": issue_data.get("description_json", issue.description_json),
|
||||
}
|
||||
|
||||
issue_current_instance = json.dumps(IssueDetailSerializer(issue).data, cls=DjangoJSONEncoder)
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class PageViewSet(BaseViewSet):
|
|||
context={
|
||||
"project_id": project_id,
|
||||
"owned_by_id": request.user.id,
|
||||
"description": request.data.get("description", {}),
|
||||
"description_json": request.data.get("description_json", {}),
|
||||
"description_binary": request.data.get("description_binary", None),
|
||||
"description_html": request.data.get("description_html", "<p></p>"),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ def copy_s3_objects_of_description_and_assets(entity_name, entity_identifier, pr
|
|||
external_data = sync_with_external_service(entity_name, updated_html)
|
||||
|
||||
if external_data:
|
||||
entity.description = external_data.get("description")
|
||||
entity.description_json = external_data.get("description_json")
|
||||
entity.description_binary = base64.b64decode(external_data.get("description_binary"))
|
||||
entity.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def sync_issue_description_version(batch_size=5000, offset=0, countdown=300):
|
|||
"description_binary",
|
||||
"description_html",
|
||||
"description_stripped",
|
||||
"description",
|
||||
"description_json",
|
||||
)[offset:end_offset]
|
||||
)
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ def sync_issue_description_version(batch_size=5000, offset=0, countdown=300):
|
|||
description_binary=issue.description_binary,
|
||||
description_html=issue.description_html,
|
||||
description_stripped=issue.description_stripped,
|
||||
description_json=issue.description,
|
||||
description_json=issue.description_json,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def should_update_existing_version(
|
|||
|
||||
|
||||
def update_existing_version(version: IssueDescriptionVersion, issue) -> None:
|
||||
version.description_json = issue.description
|
||||
version.description_json = issue.description_json
|
||||
version.description_html = issue.description_html
|
||||
version.description_binary = issue.description_binary
|
||||
version.description_stripped = issue.description_stripped
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def page_version(page_id, existing_instance, user_id):
|
|||
description_binary=page.description_binary,
|
||||
owned_by_id=user_id,
|
||||
last_saved_at=page.updated_at,
|
||||
description_json=page.description,
|
||||
description_json=page.description_json,
|
||||
description_stripped=page.description_stripped,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ def create_pages(workspace: Workspace, project_map: Dict[int, uuid.UUID], bot_us
|
|||
is_global=False,
|
||||
access=page_seed.get("access", Page.PUBLIC_ACCESS),
|
||||
name=page_seed.get("name"),
|
||||
description=page_seed.get("description", {}),
|
||||
description_json=page_seed.get("description_json", {}),
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 4.2.22 on 2026-01-15 09:02
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0116_workspacemember_explored_features_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='draftissue',
|
||||
old_name='description',
|
||||
new_name='description_json',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='issue',
|
||||
old_name='description',
|
||||
new_name='description_json',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='page',
|
||||
old_name='description',
|
||||
new_name='description_json',
|
||||
),
|
||||
]
|
||||
|
|
@ -39,7 +39,7 @@ class DraftIssue(WorkspaceBaseModel):
|
|||
blank=True,
|
||||
)
|
||||
name = models.CharField(max_length=255, verbose_name="Issue Name", blank=True, null=True)
|
||||
description = models.JSONField(blank=True, default=dict)
|
||||
description_json = models.JSONField(blank=True, default=dict)
|
||||
description_html = models.TextField(blank=True, default="<p></p>")
|
||||
description_stripped = models.TextField(blank=True, null=True)
|
||||
description_binary = models.BinaryField(null=True)
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class Issue(ProjectBaseModel):
|
|||
blank=True,
|
||||
)
|
||||
name = models.CharField(max_length=255, verbose_name="Issue Name")
|
||||
description = models.JSONField(blank=True, default=dict)
|
||||
description_json = models.JSONField(blank=True, default=dict)
|
||||
description_html = models.TextField(blank=True, default="<p></p>")
|
||||
description_stripped = models.TextField(blank=True, null=True)
|
||||
description_binary = models.BinaryField(null=True)
|
||||
|
|
@ -800,7 +800,7 @@ class IssueDescriptionVersion(ProjectBaseModel):
|
|||
description_binary=issue.description_binary,
|
||||
description_html=issue.description_html,
|
||||
description_stripped=issue.description_stripped,
|
||||
description_json=issue.description,
|
||||
description_json=issue.description_json,
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Page(BaseModel):
|
|||
|
||||
workspace = models.ForeignKey("db.Workspace", on_delete=models.CASCADE, related_name="pages")
|
||||
name = models.TextField(blank=True)
|
||||
description = models.JSONField(default=dict, blank=True)
|
||||
description_json = models.JSONField(default=dict, blank=True)
|
||||
description_binary = models.BinaryField(null=True)
|
||||
description_html = models.TextField(blank=True, default="<p></p>")
|
||||
description_stripped = models.TextField(blank=True, null=True)
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class IssueFlatSerializer(BaseSerializer):
|
|||
fields = [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"description_json",
|
||||
"description_html",
|
||||
"priority",
|
||||
"start_date",
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class IntakeIssuePublicViewSet(BaseViewSet):
|
|||
# create an issue
|
||||
issue = Issue.objects.create(
|
||||
name=request.data.get("issue", {}).get("name"),
|
||||
description=request.data.get("issue", {}).get("description", {}),
|
||||
description_json=request.data.get("issue", {}).get("description_json", {}),
|
||||
description_html=request.data.get("issue", {}).get("description_html", "<p></p>"),
|
||||
priority=request.data.get("issue", {}).get("priority", "low"),
|
||||
project_id=project_deploy_board.project_id,
|
||||
|
|
@ -201,7 +201,7 @@ class IntakeIssuePublicViewSet(BaseViewSet):
|
|||
issue_data = {
|
||||
"name": issue_data.get("name", issue.name),
|
||||
"description_html": issue_data.get("description_html", issue.description_html),
|
||||
"description": issue_data.get("description", issue.description),
|
||||
"description_json": issue_data.get("description_json", issue.description_json),
|
||||
}
|
||||
|
||||
issue_serializer = IssueCreateSerializer(
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ class IssueRetrievePublicEndpoint(BaseAPIView):
|
|||
"name",
|
||||
"state_id",
|
||||
"sort_order",
|
||||
"description",
|
||||
"description_json",
|
||||
"description_html",
|
||||
"description_stripped",
|
||||
"description_binary",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue