finish
This commit is contained in:
parent
9a3e381644
commit
cf8d4f8087
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -521,6 +521,27 @@ dependencies = [
|
|||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "csv"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe"
|
||||||
|
dependencies = [
|
||||||
|
"csv-core",
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "csv-core"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctr"
|
name = "ctr"
|
||||||
version = "0.9.2"
|
version = "0.9.2"
|
||||||
@ -2195,6 +2216,7 @@ dependencies = [
|
|||||||
"argon2",
|
"argon2",
|
||||||
"chrono",
|
"chrono",
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
|
"csv",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"ics",
|
"ics",
|
||||||
|
@ -23,6 +23,7 @@ tera = { version = "1.18", features = ["date-locale"], optional = true}
|
|||||||
ics = "0.5"
|
ics = "0.5"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
lettre = "0.11"
|
lettre = "0.11"
|
||||||
|
csv = "1.3"
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
openssl = { version = "0.10", features = [ "vendored" ] }
|
openssl = { version = "0.10", features = [ "vendored" ] }
|
||||||
|
@ -47,7 +47,7 @@ WHERE name like ?
|
|||||||
|
|
||||||
pub async fn names_from_role(&self, db: &SqlitePool) -> Vec<String> {
|
pub async fn names_from_role(&self, db: &SqlitePool) -> Vec<String> {
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"SELECT u.name.
|
"SELECT u.name
|
||||||
FROM user u
|
FROM user u
|
||||||
JOIN user_role ur ON u.id = ur.user_id
|
JOIN user_role ur ON u.id = ur.user_id
|
||||||
JOIN role r ON ur.role_id = r.id
|
JOIN role r ON ur.role_id = r.id
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use csv::ReaderBuilder;
|
||||||
use rocket::{form::Form, get, post, routes, FromForm, Route, State};
|
use rocket::{form::Form, get, post, routes, FromForm, Route, State};
|
||||||
use rocket_dyn_templates::{context, Template};
|
use rocket_dyn_templates::{context, Template};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
@ -41,10 +42,30 @@ async fn list(db: &State<SqlitePool>, _admin: AdminUser, list_form: Form<ListFor
|
|||||||
let role = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
let role = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||||
let acceptable_users = role.names_from_role(db).await;
|
let acceptable_users = role.names_from_role(db).await;
|
||||||
|
|
||||||
//TODO: continue here
|
let mut rdr = ReaderBuilder::new()
|
||||||
|
.has_headers(true)
|
||||||
|
.delimiter(b';')
|
||||||
|
.from_reader(list_form.list.trim().as_bytes());
|
||||||
|
|
||||||
|
let mut names_not_in_acceptable_users = Vec::new();
|
||||||
|
|
||||||
|
for result in rdr.records() {
|
||||||
|
println!("{result:?}");
|
||||||
|
let record = result.unwrap();
|
||||||
|
|
||||||
|
// Concatenate Vorname and Nachname
|
||||||
|
let vorname = record.get(2).unwrap_or_default().trim();
|
||||||
|
let nachname = record.get(3).unwrap_or_default().trim();
|
||||||
|
let full_name = format!("{} {}", vorname, nachname);
|
||||||
|
|
||||||
|
// Check if the concatenated name is not in the acceptable_users vector
|
||||||
|
if !acceptable_users.contains(&full_name) {
|
||||||
|
names_not_in_acceptable_users.push(full_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let context = context! {
|
let context = context! {
|
||||||
result: "test"
|
result: names_not_in_acceptable_users
|
||||||
};
|
};
|
||||||
|
|
||||||
Template::render("admin/list/result", &context)
|
Template::render("admin/list/result", &context)
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
{% if flash %}{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}{% endif %}
|
{% if flash %}{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}{% endif %}
|
||||||
<div class="max-w-screen-lg w-full">
|
<div class="max-w-screen-lg w-full">
|
||||||
<h1 class="h1">List - Result</h1>
|
<h1 class="h1">List - Result</h1>
|
||||||
{{result}}
|
<ol>
|
||||||
|
{% for person in result%}
|
||||||
|
<li>{{person}}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
Loading…
Reference in New Issue
Block a user