Commit e7982887 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Add "odj" field to "réunions".

parent 0a55d133
......@@ -5,8 +5,9 @@ use commun::{Codier, EmptyChoice, InfoJo, Rapporteur};
use contexts::Context;
use mandats::Mandat;
use organes::Organe;
use serde_utils::{map_to_vec, str_to_vec};
use points_odj::PointOdj;
use scrutins::Scrutin;
use serde_utils::{map_to_vec, str_to_vec};
use std::cmp;
use textes_legislatifs::Document;
......@@ -1800,6 +1801,32 @@ graphql_object!(DiscussionCommission: Context |&self| {
&self.libelle_acte
}
field odj(&executor) -> Option<&PointOdj> {
match (&self.odj_ref, &self.reunion_ref) {
(Some(ref odj_ref), Some(ref reunion_ref)) => {
let context = &executor.context();
match context.get_reunion_at_uid(&reunion_ref) {
None => None,
Some(reunion) => {
match reunion.odj {
None => None,
Some(ref odj) => {
match odj.points_odj {
None => None,
Some(ref points_odj) => points_odj.points_odj
.iter()
.filter(|ref point_odj| point_odj.uid() == odj_ref)
.nth(0)
}
},
}
},
}
},
_ => None,
}
}
field odj_ref() -> Option<&str> as "Référence de l'ordre du jour (à l'intérieur de la réunion référérencée par `reunion_ref`)" {
match &self.odj_ref {
None => None,
......@@ -1872,6 +1899,27 @@ graphql_object!(DiscussionSeancePublique: Context |&self| {
&self.libelle_acte
}
field odj(&executor) -> Option<&PointOdj> {
let context = &executor.context();
match context.get_reunion_at_uid(&self.reunion_ref) {
None => None,
Some(reunion) => {
match reunion.odj {
None => None,
Some(ref odj) => {
match odj.points_odj {
None => None,
Some(ref points_odj) => points_odj.points_odj
.iter()
.filter(|ref point_odj| point_odj.uid() == self.odj_ref)
.nth(0)
}
},
}
},
}
}
field odj_ref() -> Option<&str> as "Référence de l'ordre du jour (à l'intérieur de la réunion référérencée par `reunion_ref`)" {
Some(self.odj_ref.as_str())
}
......
......@@ -260,12 +260,12 @@ impl PointOdj {
// }
// }
// pub fn uid(&self) -> &str {
// match *self {
// PointOdj::PodjReunion(PodjReunion { ref uid, .. })
// | PointOdj::PodjSeanceConfPres(PodjSeanceConfPres { ref uid, .. }) => &uid,
// }
// }
pub fn uid(&self) -> &str {
match *self {
PointOdj::PodjReunion(PodjReunion { ref uid, .. })
| PointOdj::PodjSeanceConfPres(PodjSeanceConfPres { ref uid, .. }) => &uid,
}
}
}
// Using graphql_union because instance_resolvers of graphql_interface does not work with Juniper 0.9.2.
......
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