44"""
55from __future__ import annotations
66
7- from typing import List
7+ from typing import List , Optional
88
99from sqlalchemy import ForeignKey
1010from sqlalchemy .dialects import postgresql
@@ -26,20 +26,27 @@ class Submission(BaseModel): # pylint: disable=too-few-public-methods
2626 __tablename__ = 'submission'
2727
2828 id = db .Column (db .Integer , primary_key = True , autoincrement = True )
29- submission_json = db .Column (postgresql .JSONB (astext_type = db .Text ()), nullable = False , server_default = '{}' )
30- survey_id = db .Column (db .Integer , ForeignKey ('survey.id' , ondelete = 'CASCADE' ), nullable = False )
31- engagement_id = db .Column (db .Integer , ForeignKey ('engagement.id' , ondelete = 'CASCADE' ), nullable = False )
32- participant_id = db .Column (db .Integer , ForeignKey ('participant.id' ), nullable = True )
29+ submission_json = db .Column (postgresql .JSONB (
30+ astext_type = db .Text ()), nullable = False , server_default = '{}' )
31+ survey_id = db .Column (db .Integer , ForeignKey (
32+ 'survey.id' , ondelete = 'CASCADE' ), nullable = False )
33+ engagement_id = db .Column (db .Integer , ForeignKey (
34+ 'engagement.id' , ondelete = 'CASCADE' ), nullable = False )
35+ participant_id = db .Column (
36+ db .Integer , ForeignKey ('participant.id' ), nullable = True )
3337 reviewed_by = db .Column (db .String (50 ))
3438 review_date = db .Column (db .DateTime )
35- comment_status_id = db .Column (db .Integer , ForeignKey ('comment_status.id' , ondelete = 'SET NULL' ))
39+ comment_status_id = db .Column (db .Integer , ForeignKey (
40+ 'comment_status.id' , ondelete = 'SET NULL' ))
3641 has_personal_info = db .Column (db .Boolean , nullable = True )
3742 has_profanity = db .Column (db .Boolean , nullable = True )
3843 rejected_reason_other = db .Column (db .String (500 ), nullable = True )
3944 has_threat = db .Column (db .Boolean , nullable = True )
4045 notify_email = db .Column (db .Boolean (), default = True )
41- comments = db .relationship ('Comment' , backref = 'submission' , cascade = 'all, delete' )
42- staff_note = db .relationship ('StaffNote' , backref = 'submission' , cascade = 'all, delete' )
46+ comments = db .relationship (
47+ 'Comment' , backref = 'submission' , cascade = 'all, delete' )
48+ staff_note = db .relationship (
49+ 'StaffNote' , backref = 'submission' , cascade = 'all, delete' )
4350
4451 @classmethod
4552 def get_by_survey_id (cls , survey_id ) -> List [SubmissionSchema ]:
@@ -118,7 +125,7 @@ def update(cls, submission: SubmissionSchema, session=None) -> Submission:
118125 return query .first ()
119126
120127 @classmethod
121- def update_comment_status (cls , submission_id , comment : dict , session = None ) -> Submission :
128+ def update_comment_status (cls , submission_id , comment : dict , session = None ) -> Optional [ Submission ] :
122129 """Update comment status."""
123130 status_id = comment .get ('status_id' , None )
124131 has_personal_info = comment .get ('has_personal_info' , None )
0 commit comments