@@ -674,6 +674,7 @@ impl Form {
674674 form_group,
675675 form_state,
676676 states : None ,
677+ lock_state : None ,
677678 categories : None ,
678679 } )
679680 }
@@ -780,6 +781,116 @@ impl State {
780781 }
781782}
782783
784+ #[ cfg( not( feature = "python" ) ) ]
785+ #[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
786+ pub struct LockState {
787+ #[ serde( rename = "locked" ) ]
788+ #[ serde( alias = "@locked" ) ]
789+ #[ serde( alias = "locked" ) ]
790+ pub locked : bool ,
791+
792+ #[ serde( rename = "user" ) ]
793+ #[ serde( alias = "@user" ) ]
794+ #[ serde( alias = "user" ) ]
795+ #[ serde(
796+ default = "default_string_none" ,
797+ deserialize_with = "deserialize_empty_string_as_none"
798+ ) ]
799+ pub user : Option < String > ,
800+
801+ #[ serde( rename = "userUniqueId" ) ]
802+ #[ serde( alias = "@userUniqueId" ) ]
803+ #[ serde( alias = "userUniqueId" ) ]
804+ #[ serde(
805+ default = "default_string_none" ,
806+ deserialize_with = "deserialize_empty_string_as_none"
807+ ) ]
808+ pub user_unique_id : Option < String > ,
809+
810+ #[ serde( rename = "dateTimeChanged" ) ]
811+ #[ serde( alias = "@dateTimeChanged" ) ]
812+ #[ serde( alias = "dateTimeChanged" ) ]
813+ #[ serde(
814+ default = "default_datetime_none" ,
815+ deserialize_with = "deserialize_empty_string_as_none_datetime"
816+ ) ]
817+ pub date_time_changed : Option < DateTime < Utc > > ,
818+ }
819+
820+ #[ cfg( feature = "python" ) ]
821+ #[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
822+ #[ pyclass]
823+ pub struct LockState {
824+ #[ serde( rename = "locked" ) ]
825+ #[ serde( alias = "@locked" ) ]
826+ #[ serde( alias = "locked" ) ]
827+ pub locked : bool ,
828+
829+ #[ serde( rename = "user" ) ]
830+ #[ serde( alias = "@user" ) ]
831+ #[ serde( alias = "user" ) ]
832+ #[ serde(
833+ default = "default_string_none" ,
834+ deserialize_with = "deserialize_empty_string_as_none"
835+ ) ]
836+ pub user : Option < String > ,
837+
838+ #[ serde( rename = "userUniqueId" ) ]
839+ #[ serde( alias = "@userUniqueId" ) ]
840+ #[ serde( alias = "userUniqueId" ) ]
841+ #[ serde(
842+ default = "default_string_none" ,
843+ deserialize_with = "deserialize_empty_string_as_none"
844+ ) ]
845+ pub user_unique_id : Option < String > ,
846+
847+ #[ serde( rename = "dateTimeChanged" ) ]
848+ #[ serde( alias = "@dateTimeChanged" ) ]
849+ #[ serde( alias = "dateTimeChanged" ) ]
850+ #[ serde(
851+ default = "default_datetime_none" ,
852+ deserialize_with = "deserialize_empty_string_as_none_datetime"
853+ ) ]
854+ pub date_time_changed : Option < DateTime < Utc > > ,
855+ }
856+
857+ #[ cfg( feature = "python" ) ]
858+ #[ pymethods]
859+ impl LockState {
860+ #[ getter]
861+ fn locked ( & self ) -> PyResult < bool > {
862+ Ok ( self . locked )
863+ }
864+
865+ #[ getter]
866+ fn user ( & self ) -> PyResult < Option < String > > {
867+ Ok ( self . user . clone ( ) )
868+ }
869+
870+ #[ getter]
871+ fn user_unique_id ( & self ) -> PyResult < Option < String > > {
872+ Ok ( self . user_unique_id . clone ( ) )
873+ }
874+
875+ #[ getter]
876+ fn date_time_changed < ' py > ( & self , py : Python < ' py > ) -> PyResult < Option < Bound < ' py , PyDateTime > > > {
877+ to_py_datetime_option ( py, & self . date_time_changed )
878+ }
879+
880+ pub fn to_dict < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyDict > > {
881+ let dict = PyDict :: new ( py) ;
882+ dict. set_item ( "locked" , self . locked ) ?;
883+ dict. set_item ( "user" , & self . user ) ?;
884+ dict. set_item ( "user_unique_id" , & self . user_unique_id ) ?;
885+ dict. set_item (
886+ "date_time_changed" ,
887+ to_py_datetime_option ( py, & self . date_time_changed ) ?,
888+ ) ?;
889+
890+ Ok ( dict)
891+ }
892+ }
893+
783894#[ cfg( not( feature = "python" ) ) ]
784895#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
785896pub struct Form {
@@ -876,6 +987,9 @@ pub struct Form {
876987 #[ serde( alias = "state" ) ]
877988 pub states : Option < Vec < State > > ,
878989
990+ #[ serde( alias = "lockState" ) ]
991+ pub lock_state : Option < LockState > ,
992+
879993 #[ serde( alias = "category" ) ]
880994 pub categories : Option < Vec < Category > > ,
881995}
@@ -977,6 +1091,9 @@ pub struct Form {
9771091 #[ serde( alias = "state" ) ]
9781092 pub states : Option < Vec < State > > ,
9791093
1094+ #[ serde( alias = "lockState" ) ]
1095+ pub lock_state : Option < LockState > ,
1096+
9801097 #[ serde( alias = "category" ) ]
9811098 pub categories : Option < Vec < Category > > ,
9821099}
@@ -1059,6 +1176,11 @@ impl Form {
10591176 Ok ( self . states . clone ( ) )
10601177 }
10611178
1179+ #[ getter]
1180+ fn lock_state ( & self ) -> PyResult < Option < LockState > > {
1181+ Ok ( self . lock_state . clone ( ) )
1182+ }
1183+
10621184 #[ getter]
10631185 fn categories ( & self ) -> PyResult < Option < Vec < Category > > > {
10641186 Ok ( self . categories . clone ( ) )
@@ -1098,6 +1220,12 @@ impl Form {
10981220 dict. set_item ( "states" , py. None ( ) ) ?;
10991221 }
11001222
1223+ if let Some ( lock_state) = & self . lock_state {
1224+ dict. set_item ( "lock_state" , lock_state. to_dict ( py) ?) ?;
1225+ } else {
1226+ dict. set_item ( "lock_state" , py. None ( ) ) ?;
1227+ }
1228+
11011229 if let Some ( categories) = & self . categories {
11021230 let mut category_dicts = Vec :: new ( ) ;
11031231 for category in categories {
@@ -1140,6 +1268,33 @@ impl State {
11401268 }
11411269}
11421270
1271+ impl LockState {
1272+ pub fn from_attributes (
1273+ attrs : std:: collections:: HashMap < String , String > ,
1274+ ) -> Result < Self , crate :: errors:: Error > {
1275+ let locked = attrs. get ( "locked" ) . map ( |s| s == "true" ) . unwrap_or ( false ) ;
1276+ let user = attrs. get ( "user" ) . filter ( |s| !s. is_empty ( ) ) . cloned ( ) ;
1277+ let user_unique_id = attrs. get ( "userUniqueId" ) . filter ( |s| !s. is_empty ( ) ) . cloned ( ) ;
1278+
1279+ let date_time_changed = if let Some ( dtc) = attrs. get ( "dateTimeChanged" ) {
1280+ if dtc. is_empty ( ) {
1281+ None
1282+ } else {
1283+ parse_datetime_internal ( dtc) . ok ( )
1284+ }
1285+ } else {
1286+ None
1287+ } ;
1288+
1289+ Ok ( LockState {
1290+ locked,
1291+ user,
1292+ user_unique_id,
1293+ date_time_changed,
1294+ } )
1295+ }
1296+ }
1297+
11431298impl Category {
11441299 pub fn from_attributes (
11451300 attrs : std:: collections:: HashMap < String , String > ,
0 commit comments