From ab0b331dd25a3aae05a7104e0416b00d15fca646 Mon Sep 17 00:00:00 2001 From: dglemos Date: Thu, 17 Oct 2024 17:11:41 +0100 Subject: [PATCH] Fix bug in publication comment --- .../gene2phenotype_app/serializers/curation.py | 2 +- .../gene2phenotype_app/serializers/publication.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gene2phenotype_project/gene2phenotype_app/serializers/curation.py b/gene2phenotype_project/gene2phenotype_app/serializers/curation.py index 43d1fadc..389a5156 100644 --- a/gene2phenotype_project/gene2phenotype_app/serializers/curation.py +++ b/gene2phenotype_project/gene2phenotype_app/serializers/curation.py @@ -377,7 +377,7 @@ def publish(self, data): # Get or create publications # Publications should be stored in the db before any data is stored try: - publication_serializer = PublicationSerializer(data=publication_data) + publication_serializer = PublicationSerializer(data=publication_data, context={'user':user_obj}) # Validate the input data if publication_serializer.is_valid(raise_exception=True): # save and create publication obj diff --git a/gene2phenotype_project/gene2phenotype_app/serializers/publication.py b/gene2phenotype_project/gene2phenotype_app/serializers/publication.py index 58555b71..cfbf616b 100644 --- a/gene2phenotype_project/gene2phenotype_app/serializers/publication.py +++ b/gene2phenotype_project/gene2phenotype_app/serializers/publication.py @@ -234,6 +234,8 @@ def create(self, validated_data): comment = validated_data.get('comment') # extra data - comment number_of_families = validated_data.get('families') # extra data - families reported in publication + user_obj = self.context.get('user') + try: publication_obj = Publication.objects.get(pmid=pmid) @@ -266,7 +268,7 @@ def create(self, validated_data): if comment is not None: PublicationCommentSerializer( # the user is necessary to save the comment - context={'user': self.context.get('user')} + context={'user': user_obj} ).create(comment, publication_obj) # Add family info linked to publication