@@ -21,6 +21,7 @@ class MotionErrorType(StrEnum):
2121 REASON = "reason"
2222 WORKFLOW = "workflow"
2323 TITLE = "title"
24+ DIFF_VERSION = "diff_version"
2425
2526
2627class MotionActionErrorData (TypedDict ):
@@ -86,6 +87,18 @@ def _check_recommendation_and_state(
8687 )
8788 return errors
8889
90+ def _check_diff_version (
91+ self , instance : dict [str , Any ], datastore_instance : dict [str , Any ] = {}
92+ ) -> list [MotionActionErrorData ]:
93+ if instance .get ("lead_motion_id" ) or datastore_instance .get ("lead_motion_id" ):
94+ return [
95+ {
96+ "type" : (MotionErrorType .DIFF_VERSION ),
97+ "message" : "You can define a diff_version only for the lead motion" ,
98+ }
99+ ]
100+ return []
101+
89102
90103class MotionCreatePayloadValidationMixin (MotionBasePayloadValidationMixin ):
91104 """
@@ -137,6 +150,8 @@ def _create_conduct_before_checks(
137150 "message" : "You can't give amendment_paragraphs in this context" ,
138151 }
139152 )
153+ if instance .get ("diff_version" ):
154+ errors += self ._check_diff_version (instance )
140155 if (not instance .get ("reason" )) and self .check_reason_required (meeting_id ):
141156 errors .append (
142157 {"type" : MotionErrorType .REASON , "message" : "Reason is required" }
@@ -196,10 +211,14 @@ def _update_conduct_before_checks(
196211 self , instance : dict [str , Any ], meeting_id : int
197212 ) -> list [MotionActionErrorData ]:
198213 errors : list [MotionActionErrorData ] = []
199- if instance .get ("text" ) or instance .get ("amendment_paragraphs" ):
214+ if (
215+ instance .get ("text" )
216+ or instance .get ("amendment_paragraphs" )
217+ or instance .get ("diff_version" )
218+ ):
200219 motion = self .datastore .get (
201220 fqid_from_collection_and_id ("motion" , instance ["id" ]),
202- ["text" , "amendment_paragraphs" ],
221+ ["text" , "amendment_paragraphs" , "lead_motion_id" ],
203222 )
204223 if instance .get ("text" ):
205224 if not motion .get ("text" ):
@@ -224,4 +243,6 @@ def _update_conduct_before_checks(
224243 "message" : "Reason is required to update." ,
225244 }
226245 )
246+ if instance .get ("diff_version" ):
247+ errors += self ._check_diff_version (instance , motion )
227248 return errors
0 commit comments