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