mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge branch 'feat/pages-collaboration' of https://github.com/makeplane/plane into feat/pages-collaboration
This commit is contained in:
commit
6f190ea6ee
@ -1,5 +1,4 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
import zoneinfo
|
import zoneinfo
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
import json
|
import json
|
||||||
|
import y_py as Y
|
||||||
import base64
|
import base64
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
@ -9,7 +10,7 @@ from django.db import connection
|
|||||||
from django.db.models import Exists, OuterRef, Q
|
from django.db.models import Exists, OuterRef, Q
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.gzip import gzip_page
|
from django.views.decorators.gzip import gzip_page
|
||||||
from django.http import StreamingHttpResponse, HttpResponse
|
from django.http import StreamingHttpResponse
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
@ -417,11 +418,34 @@ class PagesDescriptionViewSet(BaseViewSet):
|
|||||||
page = Page.objects.get(
|
page = Page.objects.get(
|
||||||
pk=pk, workspace__slug=slug, project_id=project_id
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
)
|
)
|
||||||
|
|
||||||
base64_data = request.data.get("description_yjs")
|
base64_data = request.data.get("description_yjs")
|
||||||
|
|
||||||
if base64_data:
|
if base64_data:
|
||||||
binary_data = base64.b64decode(base64_data)
|
# Decode the base64 data to bytes
|
||||||
page.description_yjs = binary_data
|
new_binary_data = base64.b64decode(base64_data)
|
||||||
|
|
||||||
|
# Load the existing data into a YDoc
|
||||||
|
existing_doc = Y.YDoc()
|
||||||
|
if page.description_yjs:
|
||||||
|
Y.apply_update(existing_doc, page.description_yjs)
|
||||||
|
|
||||||
|
# Load the new data into a separate YDoc
|
||||||
|
new_doc = Y.YDoc()
|
||||||
|
Y.apply_update(new_doc, new_binary_data)
|
||||||
|
|
||||||
|
# Merge the new data into the existing data
|
||||||
|
# This will automatically resolve any conflicts
|
||||||
|
new_state_vector = Y.encode_state_vector(new_doc)
|
||||||
|
diff = Y.encode_state_as_update(existing_doc, new_state_vector)
|
||||||
|
Y.apply_update(existing_doc, diff)
|
||||||
|
|
||||||
|
# Encode the updated state as binary data
|
||||||
|
updated_binary_data = Y.encode_state_as_update(existing_doc)
|
||||||
|
|
||||||
|
# Store the updated binary data
|
||||||
|
page.description_yjs = updated_binary_data
|
||||||
|
page.description_html = request.data.get("description_html")
|
||||||
page.save()
|
page.save()
|
||||||
return Response({"message": "Updated successfully"})
|
return Response({"message": "Updated successfully"})
|
||||||
else:
|
else:
|
||||||
|
@ -2,7 +2,6 @@ import uuid
|
|||||||
from urllib.parse import urlencode, urljoin
|
from urllib.parse import urlencode, urljoin
|
||||||
|
|
||||||
# Django import
|
# Django import
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import uuid
|
|||||||
from urllib.parse import urlencode, urljoin
|
from urllib.parse import urlencode, urljoin
|
||||||
|
|
||||||
# Django import
|
# Django import
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import uuid
|
|||||||
from urllib.parse import urlencode, urljoin
|
from urllib.parse import urlencode, urljoin
|
||||||
|
|
||||||
# Django import
|
# Django import
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from urllib.parse import urlencode, urljoin
|
from urllib.parse import urlencode, urljoin
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
|
||||||
from django.core.validators import validate_email
|
from django.core.validators import validate_email
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
@ -60,4 +60,6 @@ zxcvbn==4.4.28
|
|||||||
# timezone
|
# timezone
|
||||||
pytz==2024.1
|
pytz==2024.1
|
||||||
# jwt
|
# jwt
|
||||||
PyJWT==2.8.0
|
PyJWT==2.8.0
|
||||||
|
# real-time
|
||||||
|
y-py==0.6.2
|
Loading…
Reference in New Issue
Block a user