feat!: test language

This commit is contained in:
Sebastian Pravda 2023-01-16 15:41:42 +01:00
parent b6f4a66e5f
commit 95ae8220a5
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
7 changed files with 13 additions and 2 deletions

View file

@ -318,7 +318,8 @@ mod tests {
\"personalIdNumber\": \"0101010000\",
\"schoolName\": \"29988383\",
\"healthInsurance\": \"000\",
\"grades\": []
\"grades\": [],
\"test_language\": \"CZ\"
},
\"parents\": [
{

View file

@ -54,6 +54,7 @@ impl Mutation {
candidate.school_name = Set(enc_candidate.school_name.map(|e| e.into()));
candidate.health_insurance = Set(enc_candidate.health_insurance.map(|e| e.into()));
candidate.grades_json = Set(enc_candidate.grades_json.map(|e| e.into()));
candidate.test_language = Set(enc_candidate.test_language.map(|s| s));
candidate.encrypted_by_id = Set(Some(encrypted_by_id));
candidate.updated_at = Set(chrono::offset::Local::now().naive_local());

View file

@ -73,6 +73,7 @@ pub struct CandidateDetails {
pub school_name: String,
pub health_insurance: String,
pub grades: GradeList,
pub test_language: String,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]

View file

@ -27,6 +27,7 @@ pub struct EncryptedCandidateDetails {
pub school_name: Option<EncryptedString>,
pub health_insurance: Option<EncryptedString>,
pub grades_json: Option<EncryptedString>,
pub test_language: Option<String>,
}
#[derive(Debug, Clone)]
@ -151,6 +152,7 @@ impl EncryptedCandidateDetails {
school_name: d.10,
health_insurance: d.11,
grades_json: d.12,
test_language: Some(form.test_language.to_owned()),
}
)
}
@ -186,6 +188,7 @@ impl EncryptedCandidateDetails {
school_name: d.10.unwrap_or_default(),
health_insurance: d.11.unwrap_or_default(),
grades: GradeList::from_opt_str(d.12).unwrap_or_default(),
test_language: self.test_language.to_owned().unwrap_or_default().to_string(),
}
)
}
@ -221,6 +224,7 @@ impl From<&candidate::Model> for EncryptedCandidateDetails {
school_name: EncryptedString::try_from(&candidate.school_name).ok(),
health_insurance: EncryptedString::try_from(&candidate.health_insurance).ok(),
grades_json: EncryptedString::try_from(&candidate.grades_json).ok(),
test_language: candidate.test_language.to_owned(),
}
}
}
@ -359,6 +363,7 @@ impl TryFrom<ApplicationRow> for EncryptedApplicationDetails {
school_name: EncryptedString::try_from(&cp.school_name).ok(),
health_insurance: EncryptedString::try_from(&cp.health_insurance).ok(),
grades_json: None, // TODO
test_language: None // TODO
},
parents: vec![EncryptedParentDetails {
name: EncryptedString::try_from(&cp.parent_name).ok(),
@ -413,6 +418,7 @@ pub mod tests {
school_name: "school_name".to_string(),
health_insurance: "health_insurance".to_string(),
grades: GradeList::from(vec![]),
test_language: "test_language".to_string(),
},
parents: vec![ParentDetails {
name: "parent_name".to_string(),

View file

@ -12,7 +12,6 @@ pub struct GradeList(Vec<Grade>);
impl GradeList {
pub fn from_opt_str(grades: Option<String>) -> Option<Self> {
println!("grades: {:?}", grades);
grades.map(
|grades| serde_json::from_str(&grades).unwrap() // TODO: handle error
)

View file

@ -21,6 +21,7 @@ pub struct Model {
pub school_name: Option<String>,
pub health_insurance: Option<String>,
pub grades_json: Option<String>,
pub test_language: Option<String>,
pub encrypted_by_id: Option<i32>,
pub created_at: DateTime,
pub updated_at: DateTime,

View file

@ -32,6 +32,7 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Candidate::SchoolName).string())
.col(ColumnDef::new(Candidate::HealthInsurance).string())
.col(ColumnDef::new(Candidate::GradesJson).string())
.col(ColumnDef::new(Candidate::TestLanguage).string())
.col(ColumnDef::new(Candidate::EncryptedById).integer())
.col(ColumnDef::new(Candidate::CreatedAt).date_time().not_null())
.col(ColumnDef::new(Candidate::UpdatedAt).date_time().not_null())
@ -65,6 +66,7 @@ pub enum Candidate {
SchoolName,
HealthInsurance,
GradesJson,
TestLanguage,
EncryptedById,
CreatedAt,
UpdatedAt,