Add some to_json functions to models for serialization in templates

This commit is contained in:
Bat
2018-06-18 17:34:29 +01:00
parent 58cc35691d
commit 7e3cdec0b6
7 changed files with 28 additions and 77 deletions
+6
View File
@@ -330,6 +330,12 @@ impl User {
};
actor
}
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
let mut json = serde_json::to_value(self).unwrap();
json["fqn"] = serde_json::Value::String(self.get_fqn(conn));
json
}
}
impl<'a, 'r> FromRequest<'a, 'r> for User {