Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove newline from comments #118

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@
from django.db import connection, IntegrityError
from django.db.models import Prefetch
import itertools

from ..models import (Panel, Attrib,
LGDPanel, LocusGenotypeDisease, LGDVariantGenccConsequence,
LGDCrossCuttingModifier, LGDPublication,
LGDPhenotype, LGDVariantType, Locus,
LGDComment, LGDVariantTypeComment, User,
LGDMolecularMechanismEvidence, CVMolecularMechanism,
OntologyTerm, Publication, LGDPhenotypeSummary,
LGDVariantTypeDescription, LGDMolecularMechanismSynopsis)

import re

from ..models import (
Panel,
Attrib,
LGDPanel,
LocusGenotypeDisease,
LGDVariantGenccConsequence,
LGDCrossCuttingModifier,
LGDPublication,
LGDPhenotype,
LGDVariantType,
Locus,
LGDComment,
LGDVariantTypeComment,
User,
LGDMolecularMechanismEvidence,
CVMolecularMechanism,
OntologyTerm,
Publication,
LGDPhenotypeSummary,
LGDVariantTypeDescription,
LGDMolecularMechanismSynopsis
)

from .publication import LGDPublicationSerializer
from .locus import LocusSerializer
Expand Down Expand Up @@ -296,9 +310,11 @@ def get_comments(self, id):
if comment.date is not None:
date = comment.date.strftime("%Y-%m-%d")

text = { 'text': comment.comment,
'date': date,
'is_public': comment.is_public }
text = {
'text': comment.comment,
'date': date,
'is_public': comment.is_public
}

# authenticated users can have access to the user name
if authenticated_user == 1:
Expand Down Expand Up @@ -410,7 +426,9 @@ def create(self, data, disease_obj, publications_list):
mechanism_support_obj = data.get('mechanism_support')

if not panels or not publications_list:
raise serializers.ValidationError({"message": f"Missing data to create the G2P record {stable_id_obj.stable_id}"})
raise serializers.ValidationError(
{"message": f"Missing data to create the G2P record {stable_id_obj.stable_id}"}
)

# Check if record (LGD) is already inserted
try:
Expand Down Expand Up @@ -757,11 +775,16 @@ def create(self, data):
lgd = self.context["lgd"]
user = self.context["user"]

# Remove newlines from comment
comment = re.sub(r"\n", " ", comment)

# Check if this comment is already linked to the G2P entry
lgd_comments = LGDComment.objects.filter(lgd_id=lgd, is_deleted=0, comment=comment)

if lgd_comments:
raise serializers.ValidationError({"message": f"Comment is already associated with {lgd.stable_id.stable_id}"})
raise serializers.ValidationError(
{"message": f"Comment is already associated with {lgd.stable_id.stable_id}"}
)

else:
try:
Expand Down