forked from github/plane
fix: added issue embed
This commit is contained in:
parent
176e184220
commit
572be0fe60
@ -87,7 +87,7 @@ class PageViewSet(BaseViewSet):
|
|||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
.order_by(self.request.GET.get("order_by", "-created_at"))
|
.order_by(self.request.GET.get("order_by", "-created_at"))
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite","-created_at")
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -135,18 +135,6 @@ class PageViewSet(BaseViewSet):
|
|||||||
status=status.HTTP_400_BAD_REQUEST,
|
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)
|
serializer = PageSerializer(page, data=request.data, partial=True)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
serializer.save()
|
serializer.save()
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
# Generated by Django 4.2.5 on 2023-11-15 09:16
|
# Generated by Django 4.2.5 on 2023-11-15 09:16
|
||||||
|
|
||||||
# Python imports
|
# Python imports
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
def update_pages(apps, schema_editor):
|
def update_pages(apps, schema_editor):
|
||||||
try:
|
try:
|
||||||
Page = apps.get_model("db", "Page")
|
Page = apps.get_model("db", "Page")
|
||||||
@ -22,17 +24,18 @@ def update_pages(apps, schema_editor):
|
|||||||
if page_blocks:
|
if page_blocks:
|
||||||
# looping through all the page blocks in a page
|
# looping through all the page blocks in a page
|
||||||
for page_block in page_blocks:
|
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:
|
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
|
# create the page transaction for the issue
|
||||||
page_logs.append(
|
page_logs.append(
|
||||||
PageLog(
|
PageLog(
|
||||||
page_id=page_block.page_id,
|
page_id=page_block.page_id,
|
||||||
transaction=uuid.uuid4().hex,
|
transaction=transaction,
|
||||||
entity_identifier=page_block.issue_id,
|
entity_identifier=page_block.issue_id,
|
||||||
entity_name="issue",
|
entity_name="issue",
|
||||||
project_id=page.project_id,
|
project_id=page.project_id,
|
||||||
@ -41,6 +44,11 @@ def update_pages(apps, schema_editor):
|
|||||||
updated_by_id=page_block.updated_by_id,
|
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)
|
updated_pages.append(page)
|
||||||
|
|
||||||
Page.objects.bulk_update(
|
Page.objects.bulk_update(
|
||||||
@ -55,9 +63,8 @@ def update_pages(apps, schema_editor):
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
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 = [
|
operations = [
|
||||||
|
Loading…
Reference in New Issue
Block a user