fix: added issue embed

This commit is contained in:
NarayanBavisetti 2023-11-16 12:36:30 +05:30
parent 176e184220
commit 572be0fe60
2 changed files with 17 additions and 22 deletions

View File

@ -87,7 +87,7 @@ class PageViewSet(BaseViewSet):
.annotate(is_favorite=Exists(subquery))
.order_by(self.request.GET.get("order_by", "-created_at"))
.prefetch_related("labels")
.order_by("name", "-is_favorite")
.order_by("-is_favorite","-created_at")
.distinct()
)
@ -135,18 +135,6 @@ class PageViewSet(BaseViewSet):
status=status.HTTP_400_BAD_REQUEST,
)
# # only update lock if the page owner is the requesting user
# if (
# page.is_locked != request.data.get("is_locked", page.is_locked)
# and page.owned_by_id != request.user.id
# ):
# return Response(
# {
# "error": "Lock cannot be updated since this page is owned by someone else"
# },
# status=status.HTTP_400_BAD_REQUEST,
# )
serializer = PageSerializer(page, data=request.data, partial=True)
if serializer.is_valid():
serializer.save()

View File

@ -1,9 +1,11 @@
# Generated by Django 4.2.5 on 2023-11-15 09:16
# Python imports
import uuid
from django.db import migrations
def update_pages(apps, schema_editor):
try:
Page = apps.get_model("db", "Page")
@ -22,17 +24,18 @@ def update_pages(apps, schema_editor):
if page_blocks:
# looping through all the page blocks in a page
for page_block in page_blocks:
# adding the page block name and description to the page description
page.description_html += f"<p>{page_block.name}</p>"
page.description_html += page_block.description_html
if page_block.issue is not None:
project_identifier = page.project.identifier
sequence_id = page_block.issue.sequence_id
transaction = uuid.uuid4().hex
embed_component = f'<issue-embed-component id="{transaction}" entity_name="issue" entity_identifier="{page_block.issue_id}" sequence_id="{sequence_id}" project_identifier="{project_identifier}" title="{page_block.name}"></issue-embed-component>'
page.description_html += embed_component
# create the page transaction for the issue
page_logs.append(
PageLog(
page_id=page_block.page_id,
transaction=uuid.uuid4().hex,
transaction=transaction,
entity_identifier=page_block.issue_id,
entity_name="issue",
project_id=page.project_id,
@ -41,6 +44,11 @@ def update_pages(apps, schema_editor):
updated_by_id=page_block.updated_by_id,
)
)
else:
# adding the page block name and description to the page description
page.description_html += f"<h2>{page_block.name}</h2>"
page.description_html += page_block.description_html
updated_pages.append(page)
Page.objects.bulk_update(
@ -55,9 +63,8 @@ def update_pages(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('db', '0047_issuemention_pagelog_page_archived_at_page_is_locked_and_more'),
("db", "0047_issuemention_pagelog_page_archived_at_page_is_locked_and_more"),
]
operations = [