Commit 642cfb38 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Make group CSV upload respect config setting 'require_sex'

parent f52f8eb5
Pipeline #957 passed with stages
in 13 minutes and 46 seconds
......@@ -878,12 +878,17 @@ pub fn add_group<T: MedalConnection>(conn: &T, session_token: &str, csrf_token:
Ok(group.id.unwrap())
}
pub fn group_csv<T: MedalConnection>(conn: &T, session_token: &str) -> MedalValueResult {
pub fn group_csv<T: MedalConnection>(conn: &T, session_token: &str, sex_infos: SexInformation) -> MedalValueResult {
let session = conn.get_session(&session_token).ensure_logged_in().ok_or(MedalError::NotLoggedIn)?;
let mut data = json_val::Map::new();
data.insert("csrf_token".to_string(), to_json(&session.csrf_token));
data.insert("require_sex".to_string(), to_json(&sex_infos.require_sex));
data.insert("allow_sex_na".to_string(), to_json(&sex_infos.allow_sex_na));
data.insert("allow_sex_diverse".to_string(), to_json(&sex_infos.allow_sex_diverse));
data.insert("allow_sex_other".to_string(), to_json(&sex_infos.allow_sex_other));
Ok(("groupcsv".to_string(), data))
}
......
......@@ -784,7 +784,15 @@ fn group_csv<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
let session_token = req.require_session_token()?;
template_ok!(with_conn![core::group_csv, C, req, &session_token].aug(req)?)
let si = {
let config = req.get::<Read<SharedConfiguration>>().unwrap();
core::SexInformation { require_sex: config.require_sex.unwrap_or(false),
allow_sex_na: config.allow_sex_na.unwrap_or(true),
allow_sex_diverse: config.allow_sex_diverse.unwrap_or(false),
allow_sex_other: config.allow_sex_other.unwrap_or(true) }
};
template_ok!(with_conn![core::group_csv, C, req, &session_token, si].aug(req)?)
}
fn group_csv_upload<C>(req: &mut Request) -> IronResult<Response>
......
......@@ -147,6 +147,10 @@ function fileLoadHandler(event) {
data[i][4] = "d";
} else {
data[i][4] = "?";
{{#if require_sex}}
skiplines++;
continue;
{{/if}}
}
for (var j = 0; j < 5; j++) {
......
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