Skip to content

Commit

Permalink
Merge pull request #1633 from ResearchHub/fix-post-update
Browse files Browse the repository at this point in the history
fix issue with post not updating properly
  • Loading branch information
lightninglu10 committed Jun 17, 2024
2 parents 387fb21 + 1e29682 commit 60b7244
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/researchhub_document/views/researchhub_post_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def create_researchhub_post(self, request):
note = Note.objects.get(id=note_id)
organization = note.organization
if not self._check_authors_in_org(authors, organization):
return Response("No permission to create note for organization", status=403)
return Response(
"No permission to create note for organization", status=403
)

try:
with transaction.atomic():
Expand Down Expand Up @@ -213,10 +215,13 @@ def update_existing_researchhub_posts(self, request):
rh_post = ResearchhubPost.objects.get(id=rh_post_id)

# Check if all given authors are in the same organization
note = Note.objects.get(id=rh_post.note_id)
organization = note.organization
if not self._check_authors_in_org(authors, organization):
return Response("No permission to update post for organization", status=403)
if rh_post.note_id:
note = Note.objects.get(id=rh_post.note_id)
organization = note.organization
if not self._check_authors_in_org(authors, organization):
return Response(
"No permission to update post for organization", status=403
)

created_by = request.user
hubs = data.pop("hubs", None)
Expand Down Expand Up @@ -249,7 +254,12 @@ def update_existing_researchhub_posts(self, request):
unified_doc.hubs.set(hubs)

reset_unified_document_cache(
document_type=[ALL.lower(), POSTS.lower(), PREREGISTRATION.lower(), QUESTION.lower()],
document_type=[
ALL.lower(),
POSTS.lower(),
PREREGISTRATION.lower(),
QUESTION.lower(),
],
filters=[NEW, DISCUSSED, UPVOTED, HOT],
)

Expand Down

0 comments on commit 60b7244

Please sign in to comment.