Commit 60375d2e authored by Emmanuel Raviart's avatar Emmanuel Raviart

Add fields to Amendements struct.

parent a36c352b
Pipeline #104532 passed with stage
in 3 minutes and 6 seconds
......@@ -169,8 +169,11 @@ graphql_object!(Amendement: Context |&self| {
});
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
// See field codeLoi below to know why option "deny_unknown_fields" is commented out.
// #[serde(deny_unknown_fields)]
pub struct Amendements {
#[serde(rename = "acteurRef")]
pub acteur_ref: Option<String>,
#[serde(deserialize_with = "map_to_vec", rename = "amendement")]
pub amendements: Vec<Amendement>,
#[serde(rename = "annexeExposeSommaire")]
......@@ -181,12 +184,16 @@ pub struct Amendements {
pub article_additionnel: Option<String>,
#[serde(default, deserialize_with = "str_to_option_bool")]
pub canonique: Option<bool>,
// codeLoi can be null, [null, null], so a conversion from Option<str> to Vec<str> is needed.
// In the mean time, don't deserialize this field & remove "deny_unknown_fields" above.
// #[serde(rename = "codeLoi")]
// pub code_loi: Vec<String>,
#[serde(rename = "dateDepot")]
pub date_depot: Option<String>,
#[serde(rename = "dateDispoRepresentation")]
pub date_dispo_representation: Option<String>,
#[serde(rename = "dateDistribution")]
pub date_distribution: Option<String>,
#[serde(default, deserialize_with = "str_to_vec", rename = "dateDistribution")]
pub date_distribution: Vec<String>,
#[serde(rename = "divisionCodeLoi")]
pub division_code_loi: Option<EmptyChoice>,
#[serde(rename = "documentURI")]
......@@ -194,11 +201,18 @@ pub struct Amendements {
pub libelle: Option<String>,
#[serde(rename = "lignesCredits")]
pub lignes_credits: Option<EmptyChoice>,
#[serde(default, deserialize_with = "map_to_vec", rename = "loiReference")]
pub loi_reference: Vec<LoiReference>,
#[serde(rename = "montantNegatif")]
pub montant_negatif: Option<String>,
#[serde(rename = "montantPositif")]
pub montant_positif: Option<String>,
pub nom: Option<String>,
#[serde(default, deserialize_with = "str_to_option_bool")]
pub officielle: Option<bool>,
pub offset: Option<EmptyChoice>,
#[serde(rename = "repSource")]
pub rep_source: Option<String>,
#[serde(rename = "seanceDiscussion")]
pub seance_discussion: Option<String>,
#[serde(rename = "sort")]
......@@ -216,6 +230,23 @@ pub struct Amendements {
}
graphql_object!(Amendements: Context |&self| {
field acteur(&executor) -> Option<&Acteur> {
match &self.acteur_ref {
None => None,
Some(ref acteur_ref) => {
let context = &executor.context();
context.get_acteur_at_uid(acteur_ref)
},
}
}
field acteur_ref() -> Option<&str> {
match &self.acteur_ref {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field amendements() -> &Vec<Amendement> {
&self.amendements
}
......@@ -238,6 +269,10 @@ graphql_object!(Amendements: Context |&self| {
self.canonique
}
// field code_loi() -> &Vec<String> {
// &self.code_loi
// }
field date_depot() -> Option<&str> {
match &self.date_depot {
None => None,
......@@ -252,11 +287,8 @@ graphql_object!(Amendements: Context |&self| {
}
}
field date_distribution() -> Option<&str> {
match &self.date_distribution {
None => None,
Some(ref s) => Some(s.as_str()),
}
field date_distribution() -> &Vec<String> {
&self.date_distribution
}
field document_uri() -> Option<&str> {
......@@ -273,6 +305,10 @@ graphql_object!(Amendements: Context |&self| {
}
}
field loi_reference() -> &Vec<LoiReference> {
&self.loi_reference
}
field montant_negatif() -> Option<&str> {
match &self.montant_negatif {
None => None,
......@@ -287,6 +323,24 @@ graphql_object!(Amendements: Context |&self| {
}
}
field nom() -> Option<&str> {
match &self.nom {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field officielle() -> Option<bool> {
self.officielle
}
field rep_source() -> Option<&str> {
match &self.rep_source {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field seance_discussion() -> Option<&str> {
match &self.seance_discussion {
None => None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment