Browse Source

FEA: Migrated to rocket v0.5-rc.1

develop
Keanu D?lle 3 months ago
parent
commit
84971cf73e
  1. 1512
      Cargo.lock
  2. 15
      Cargo.toml
  3. 12
      Rocket.toml
  4. 0
      resources/templates/alert.html.hbs
  5. 0
      resources/templates/delete-groups-modal.html.hbs
  6. 0
      resources/templates/delete-member-modal.html.hbs
  7. 0
      resources/templates/footer.html.hbs
  8. 0
      resources/templates/header.html.hbs
  9. 0
      resources/templates/module_communicator_email.html.hbs
  10. 0
      resources/templates/module_dashboard.html.hbs
  11. 0
      resources/templates/module_em_create_event.html.hbs
  12. 0
      resources/templates/module_em_edit_event.html.hbs
  13. 0
      resources/templates/module_em_event_unit_positions.html.hbs
  14. 0
      resources/templates/module_em_event_unit_templates.html.hbs
  15. 0
      resources/templates/module_em_eventlist.html.hbs
  16. 0
      resources/templates/module_em_organisers.html.hbs
  17. 0
      resources/templates/module_member_management_create.html.hbs
  18. 0
      resources/templates/module_member_management_groups.html.hbs
  19. 0
      resources/templates/module_member_management_personal_profile.html.hbs
  20. 0
      resources/templates/module_member_management_profile.html.hbs
  21. 0
      resources/templates/module_member_management_selection.html.hbs
  22. 0
      resources/templates/module_resource_management_vehicle_list.html.hbs
  23. 0
      resources/templates/module_settings_permissions.html.hbs
  24. 0
      resources/templates/module_welcome.html.hbs
  25. 0
      resources/templates/password_reset.html.hbs
  26. 0
      resources/templates/searchbar.html.hbs
  27. 0
      resources/templates/sidebar.html.hbs
  28. 2
      resources/templates/versiontag.hbs
  29. 6
      src/database/controller/api_members.rs
  30. 2
      src/database/controller/members_groups.rs
  31. 110
      src/helper/handlebars_in_list_helper.rs
  32. 6
      src/helper/mail_templates.rs
  33. 21
      src/helper/server_errors.rs
  34. 2
      src/helper/translate_diesel_error.rs
  35. 9
      src/helper/user_request_guard.rs
  36. 35
      src/main.rs
  37. 5
      src/modules/admin_settings/permissions.rs
  38. 8
      src/modules/api/appointments/create.rs
  39. 10
      src/modules/api/appointments/delete.rs
  40. 12
      src/modules/api/appointments/read.rs
  41. 22
      src/modules/api/communicator/create.rs
  42. 8
      src/modules/api/event_organisers/create.rs
  43. 6
      src/modules/api/event_organisers/delete.rs
  44. 12
      src/modules/api/event_organisers/read.rs
  45. 6
      src/modules/api/event_organisers/update.rs
  46. 8
      src/modules/api/events/create.rs
  47. 6
      src/modules/api/events/delete.rs
  48. 14
      src/modules/api/events/event_units/position/create.rs
  49. 10
      src/modules/api/events/event_units/position/delete.rs
  50. 12
      src/modules/api/events/event_units/position/read.rs
  51. 6
      src/modules/api/events/event_units/position/update.rs
  52. 8
      src/modules/api/events/event_units/templates/create.rs
  53. 10
      src/modules/api/events/event_units/templates/delete.rs
  54. 16
      src/modules/api/events/event_units/templates/read.rs
  55. 10
      src/modules/api/events/event_units/templates/update.rs
  56. 10
      src/modules/api/events/instances/create.rs
  57. 6
      src/modules/api/events/instances/delete.rs
  58. 14
      src/modules/api/events/instances/read.rs
  59. 12
      src/modules/api/events/instances/update.rs
  60. 16
      src/modules/api/events/read.rs
  61. 10
      src/modules/api/events/types/read.rs
  62. 6
      src/modules/api/events/update.rs
  63. 8
      src/modules/api/groups/create.rs
  64. 12
      src/modules/api/groups/delete.rs
  65. 20
      src/modules/api/groups/read.rs
  66. 14
      src/modules/api/groups/update.rs
  67. 6
      src/modules/api/info/caller.rs
  68. 2
      src/modules/api/member_management/controller/member_driving_permissions.rs
  69. 2
      src/modules/api/member_management/controller/member_qualifications.rs
  70. 2
      src/modules/api/member_management/controller/parser.rs
  71. 8
      src/modules/api/member_management/view/member_driving_permissions.rs
  72. 14
      src/modules/api/member_management/view/member_qualifications.rs
  73. 8
      src/modules/api/members/delete_member.rs
  74. 10
      src/modules/api/members/get_member.rs
  75. 6
      src/modules/api/members/licenses/read.rs
  76. 34
      src/modules/api/members/member_communication.rs
  77. 14
      src/modules/api/members/member_qualification.rs
  78. 24
      src/modules/api/resources/vehicles/create.rs
  79. 6
      src/modules/api/resources/vehicles/delete.rs
  80. 16
      src/modules/api/resources/vehicles/read.rs
  81. 8
      src/modules/api/resources/vehicles/update.rs
  82. 8
      src/modules/api/units/delete.rs
  83. 8
      src/modules/api/units/read.rs
  84. 8
      src/modules/api/units/update.rs
  85. 10
      src/modules/api/users/create.rs
  86. 10
      src/modules/api/users/delete.rs
  87. 124
      src/modules/api/users/read.rs
  88. 10
      src/modules/api/users/update.rs
  89. 3
      src/modules/communicator/send_email.rs
  90. 7
      src/modules/dashboard/view/mod.rs
  91. 5
      src/modules/event_management/add_event.rs
  92. 2
      src/modules/event_management/check_position_requirements.rs
  93. 5
      src/modules/event_management/edit_event.rs
  94. 5
      src/modules/event_management/event_unit_positions.rs
  95. 5
      src/modules/event_management/event_unit_templates.rs
  96. 7
      src/modules/event_management/eventlist.rs
  97. 2
      src/modules/event_management/organisers.rs
  98. 33
      src/modules/member_management/controller/filter_form_from_form_trait.rs
  99. 2
      src/modules/member_management/controller/member_groups.rs
  100. 3
      src/modules/member_management/controller/member_personal_profile.rs

1512
Cargo.lock
File diff suppressed because it is too large
View File

15
Cargo.toml

@ -13,7 +13,6 @@ serde = { version = "1.0.125", features = ["derive"] }
serde_json = "1.0.64"
log = "0.4.14"
env_logger = "0.8.3"
rocket = "0.4.10"
diesel = { version = "1.4.6", features = ["postgres", "uuidv07", "chrono", "serde_json"] } #uuidv07 vs uuid to use uuid >= 0.7
diesel_geometry = "1.4.0"
uuid = { version = "0.8.2", features = ["serde", "v4"] }
@ -21,10 +20,12 @@ rust-argon2 = "0.8.3"
chrono = { version = "0.4.19", features = ["serde"] }
rand = "0.8.3"
iban_validate = "4.0.0"
lettre = "0.9.5"
lettre_email = "0.9.4"
base64 = "0.13.0"
[dependencies.rocket_contrib]
version = "0.4.7"
default-features = false
features = ["handlebars_templates", "serve", "json"]
[dependencies.rocket]
version = "0.5.0-rc.1"
features = ["json", "secrets", "uuid"]
[dependencies.rocket_dyn_templates]
version = "0.1.0-rc.1"
features = ["handlebars"]

12
Rocket.toml

@ -1,21 +1,21 @@
[development]
address = "localhost"
[debug]
address = "127.0.0.1"
port = 8000
keep_alive = 5
log = "normal"
log = "debug"
limits = { forms = 32768 }
template_dir = "resources/templates"
[staging]
address = "0.0.0.0"
address = "127.0.0.1"
port = 8000
keep_alive = 5
log = "normal"
limits = { forms = 32768 }
template_dir = "resources/templates"
[production]
address = "0.0.0.0"
[release]
address = "127.0.0.1"
port = 8000
keep_alive = 5
log = "critical"

0
resources/templates/alert.hbs → resources/templates/alert.html.hbs

0
resources/templates/delete-groups-modal.hbs → resources/templates/delete-groups-modal.html.hbs

0
resources/templates/delete-member-modal.hbs → resources/templates/delete-member-modal.html.hbs

0
resources/templates/footer.hbs → resources/templates/footer.html.hbs

0
resources/templates/header.hbs → resources/templates/header.html.hbs

0
resources/templates/module_communicator_email.hbs → resources/templates/module_communicator_email.html.hbs

0
resources/templates/module_dashboard.hbs → resources/templates/module_dashboard.html.hbs

0
resources/templates/module_em_create_event.hbs → resources/templates/module_em_create_event.html.hbs

0
resources/templates/module_em_edit_event.hbs → resources/templates/module_em_edit_event.html.hbs

0
resources/templates/module_em_event_unit_positions.hbs → resources/templates/module_em_event_unit_positions.html.hbs

0
resources/templates/module_em_event_unit_templates.hbs → resources/templates/module_em_event_unit_templates.html.hbs

0
resources/templates/module_em_eventlist.hbs → resources/templates/module_em_eventlist.html.hbs

0
resources/templates/module_em_organisers.hbs → resources/templates/module_em_organisers.html.hbs

0
resources/templates/module_member_management_create.hbs → resources/templates/module_member_management_create.html.hbs

0
resources/templates/module_member_management_groups.hbs → resources/templates/module_member_management_groups.html.hbs

0
resources/templates/module_member_management_personal_profile.hbs → resources/templates/module_member_management_personal_profile.html.hbs

0
resources/templates/module_member_management_profile.hbs → resources/templates/module_member_management_profile.html.hbs

0
resources/templates/module_member_management_selection.hbs → resources/templates/module_member_management_selection.html.hbs

0
resources/templates/module_resource_management_vehicle_list.hbs → resources/templates/module_resource_management_vehicle_list.html.hbs

0
resources/templates/module_settings_permissions.hbs → resources/templates/module_settings_permissions.html.hbs

0
resources/templates/module_welcome.hbs → resources/templates/module_welcome.html.hbs

0
resources/templates/password_reset.hbs → resources/templates/password_reset.html.hbs

0
resources/templates/searchbar.hbs → resources/templates/searchbar.html.hbs

0
resources/templates/sidebar.hbs → resources/templates/sidebar.html.hbs

2
resources/templates/versiontag.hbs

@ -1 +1 @@
v0.2-16-g96fc203
v0.2-19-gdbc762a

6
src/database/controller/api_members.rs

@ -18,7 +18,7 @@ pub fn get_raw_member_search_result(
) -> Result<RawMemberSearchResult, diesel::result::Error> {
use crate::schema::members::dsl::*;
let connection = establish_connection(&settings);
let connection = establish_connection(settings);
let short_member: Result<RawMemberSearchResult, diesel::result::Error> = members
.filter(entity_id.eq(member_entity_id))
@ -63,7 +63,7 @@ pub fn get_raw_member_search_result_by_name(
) -> Result<Vec<RawMemberSearchResult>, diesel::result::Error> {
use crate::schema::members::dsl::*;
let connection = establish_connection(&settings);
let connection = establish_connection(settings);
let splitted_name: Vec<&str> = member_name.split_whitespace().collect();
@ -131,7 +131,7 @@ pub fn delete_entity_deprecated(
) -> Result<usize, diesel::result::Error> {
use crate::schema::entities::dsl::*;
let connection = establish_connection(&settings);
let connection = establish_connection(settings);
match diesel::delete(entities.filter(entity_id.eq(entity_id_to_delete))).execute(&connection) {
Ok(size) => Ok(size),

2
src/database/controller/members_groups.rs

@ -46,7 +46,7 @@ pub fn get_member_search_results_in_group(
let readable = check_access_to_member_and_group(
settings,
member.entity_id,
get_groups_for_member(&settings, member.entity_id),
get_groups_for_member(settings, member.entity_id),
caller_entity_id,
crate::permissions::modules::member_management::profile::VIEW.to_string(),
);

110
src/helper/handlebars_in_list_helper.rs

@ -1,78 +1,72 @@
use rocket_contrib::templates::handlebars::{
use rocket_dyn_templates::handlebars::{
Context, Handlebars, Helper, HelperDef, HelperResult, Output, RenderContext, RenderError,
Renderable,
};
#[derive(Clone, Copy)]
pub(crate) struct InListHelper;
/// Implements an "if_in_list" block helper for string vectors.
/// Will render true block if one of the parameters 1-x is found in list.
impl HelperDef for InListHelper {
fn call<'reg: 'rc, 'rc>(
&self,
h: &Helper<'reg, 'rc>,
r: &'reg Handlebars,
ctx: &Context,
rc: &mut RenderContext<'reg>,
out: &mut dyn Output,
) -> HelperResult {
let list = h.param(0).unwrap();
let mut to_find: Vec<&str> = vec![];
pub fn in_list_block_helper<'reg, 'rc>(h: &Helper<'reg, 'rc>,
r: &'reg Handlebars<'reg>,
ctx: &'rc Context,
rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output
) -> HelperResult{
let list = h.param(0).unwrap();
let mut to_find: Vec<&str> = vec![];
let mut count: usize = 1;
loop {
match h.param(count) {
None => break,
Some(val) => {
match val.value().as_str() {
Some(value) => to_find.push(value),
None => {
return Err(RenderError::new(
"wrong parameter type. Should be a String.",
))
}
};
}
let mut count: usize = 1;
loop {
match h.param(count) {
None => break,
Some(val) => {
match val.value().as_str() {
Some(value) => to_find.push(value),
None => {
return Err(RenderError::new(
"wrong parameter type. Should be a String.",
))
}
};
}
count = count + 1;
}
count = count + 1;
}
let list: &Vec<serde_json::Value> = match list.value().as_array() {
Some(array) => array,
None => {
return Err(RenderError::new(
"wrong parameter type. Should be array/Vec.",
))
}
};
let list: &Vec<serde_json::Value> = match list.value().as_array() {
Some(array) => array,
let mut found = false;
for value in list {
let string = match value.as_str() {
Some(string) => string,
None => {
return Err(RenderError::new(
"wrong parameter type. Should be array/Vec.",
"wrong parameter type. Should be string array/string Vec.",
))
}
};
let mut found = false;
for value in list {
let string = match value.as_str() {
Some(string) => string,
None => {
return Err(RenderError::new(
"wrong parameter type. Should be string array/string Vec.",
))
}
};
if to_find.contains(&string) {
found = true;
break;
}
if to_find.contains(&string) {
found = true;
break;
}
}
if found {
h.template()
.map(|t| t.render(r, ctx, rc, out))
.unwrap_or(Ok(()))
} else {
//render inverse template (else block), if not found in list.
h.inverse()
.map(|t| t.render(r, ctx, rc, out))
.unwrap_or(Ok(()))
}
if found {
h.template()
.map(|t| t.render(r, ctx, rc, out))
.unwrap_or(Ok(()))
} else {
//render inverse template (else block), if not found in list.
h.inverse()
.map(|t| t.render(r, ctx, rc, out))
.unwrap_or(Ok(()))
}
}

6
src/helper/mail_templates.rs

@ -1,5 +1,5 @@
use rocket_contrib::templates::handlebars::Handlebars;
use rocket_dyn_templates::handlebars::Handlebars;
pub struct MailTemplates{
pub registry: Handlebars,
pub struct MailTemplates<'a>{
pub registry: Handlebars<'a>,
}

21
src/helper/server_errors.rs

@ -10,20 +10,13 @@ use rocket::response::status::Custom;
/// Catches all 401 errors and redirects to front page to show error / portal page if cookie valled
/// Will be called when session cookies are invalid / if user has no permission to access feature
#[catch(401)]
pub fn unauthorized<'a>(req: &Request) -> Result<Redirect, Response<'a>> {
warn!("URI: {}", req.uri().to_string());
if req.uri().to_string().find("/api/http_basic_auth").is_some(){
let mut res = Response::new();
res.set_status(Status::Unauthorized);
res.set_raw_header("WWW-Authenticate", "Basic");
return Err(res.respond_to(req).unwrap())
}
let storage = match req.guard::<State<SessionCookieStorage>>() {
pub async fn unauthorized (req: & Request<'_>) -> Redirect {
let storage = match req.guard::<&State<SessionCookieStorage>>().await {
Outcome::Success(storage) => storage,
_ => return Ok(Redirect::to("/?error=unauthorized")),
_ => return Redirect::to("/?error=unauthorized"),
};
let settings = req
.guard::<State<Settings>>()
.guard::<&State<Settings>>().await
.expect("Settings not available!");
match req.cookies().get_private("session") {
Some(cookie) => match storage.get(cookie.value().to_string()) {
@ -33,11 +26,11 @@ pub fn unauthorized<'a>(req: &Request) -> Result<Redirect, Response<'a>> {
.checked_add_signed(Duration::seconds(settings.application.session_timeout))
.expect("Session timeout specified in configuration is too great!");
storage.update(updated_cookie);
Ok(Redirect::to("/portal?error=unauthorized"))
Redirect::to("/portal?error=unauthorized")
}
Err(_) => Ok(Redirect::to("/?error=unauthorized")),
Err(_) => Redirect::to("/?error=unauthorized"),
},
None => Ok(Redirect::to("/?error=unauthorized")),
None => Redirect::to("/?error=unauthorized"),
}
}

2
src/helper/translate_diesel_error.rs

@ -1,5 +1,5 @@
use crate::modules::api::model::api_outcome::{ApiError, ApiErrorWrapper};
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
/// Transforms diesel error into ApiErrorWrapper with proper error message.
/// Currently checks for NotFound and UniquieViolation

9
src/helper/user_request_guard.rs

@ -7,16 +7,17 @@ use rocket::http::Status;
use rocket::request::{FromRequest, Outcome};
use rocket::{request, Request, State};
impl<'a, 'r> FromRequest<'a, 'r> for SessionCookie {
#[rocket::async_trait]
impl<'r> FromRequest<'r> for SessionCookie {
type Error = SessionCookieError;
fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
let storage = match request.guard::<State<SessionCookieStorage>>() {
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
let storage = match request.guard::<&State<SessionCookieStorage>>().await {
Outcome::Success(storage) => storage,
_ => return Outcome::Failure((Status::Unauthorized, SessionCookieError::Unavailable)),
};
let settings = request
.guard::<State<Settings>>()
.guard::<&State<Settings>>().await
.expect("Settings not available!");
match request.cookies().get_private("session") {

35
src/main.rs

@ -1,9 +1,6 @@
#![feature(proc_macro_hygiene, decl_macro)]
extern crate config;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate log;
#[macro_use]
extern crate rocket;
@ -14,26 +11,29 @@ extern crate serde_derive;
extern crate argon2;
extern crate chrono;
extern crate iban;
extern crate base64;
use crate::helper::handlebars_in_list_helper::InListHelper;
use crate::helper::handlebars_in_list_helper::in_list_block_helper;
use crate::helper::mail_queue::queue::MailQueue;
use crate::helper::mail_templates::MailTemplates;
use crate::helper::session_cookies::model::SessionCookieStorage;
use helper::settings::Settings;
use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::handlebars::Handlebars;
use rocket_contrib::templates::Template;
use std::io::Write;
use std::process::Command;
use std::sync::Arc;
use std::{thread, time};
use rocket_dyn_templates::Template;
use rocket::fs::FileServer;
use rocket_dyn_templates::handlebars::Handlebars;
pub mod database;
pub mod helper;
pub mod modules;
pub mod permissions;
pub mod schema;
fn main() {
#[launch]
fn rocket() -> _ {
env_logger::init(); //Initializes logger. Set environment variable RUST_LOG=debug|info|warn|error to set loglevel
let settings = match Settings::new() {
@ -88,9 +88,7 @@ fn main() {
let mut mail_templates = MailTemplates {
registry: Handlebars::new(),
};
match mail_templates
.registry
.register_templates_directory(".hbs", "resources/mail_templates")
match mail_templates.registry.register_template_file("password-reset-de", "resources/mail_templates/password-reset-de.hbs")
{
Ok(_) => {}
Err(e) => {
@ -99,7 +97,7 @@ fn main() {
}
}
rocket::ignite()
rocket::build()
.manage(settings)
.manage(cookie_storage)
.manage(mail_queue)
@ -214,12 +212,11 @@ fn main() {
modules::admin_settings::permissions::settings_permissions,
],
)
.mount("/css", StaticFiles::from("resources/css"))
.mount("/js", StaticFiles::from("resources/js"))//TODO: Replace popper and bootstrap with local files
.mount("/img", StaticFiles::from("resources/images"))
.mount("/templates", StaticFiles::from("resources/ajax_templates"))
.mount("/css", FileServer::from("resources/css"))
.mount("/js", FileServer::from("resources/js"))//TODO: Replace popper and bootstrap with local files
.mount("/img", FileServer::from("resources/images"))
.mount("/templates", FileServer::from("resources/ajax_templates"))
.attach(Template::custom(|engine|{
engine.handlebars.register_helper("if_in_list", Box::new(InListHelper));
engine.handlebars.register_helper("if_in_list", Box::new(in_list_block_helper));
}))
.launch();
}
}

5
src/modules/admin_settings/permissions.rs

@ -1,10 +1,11 @@
use crate::helper::session_cookies::model::SessionCookie;
use rocket::State;
use crate::helper::settings::Settings;
use rocket_contrib::templates::Template;
use rocket::http::Status;
use crate::helper::sitebuilder::model::sidebar::Sidebar;
use crate::helper::sitebuilder::model::general::{Header, Stylesheet, Footer, Script};
use rocket_dyn_templates::Template;
#[derive(Serialize)]
pub struct SettingsModule {
@ -15,7 +16,7 @@ pub struct SettingsModule {
}
#[get("/portal/settings/permissions")]
pub fn settings_permissions(cookie: SessionCookie, settings: State<Settings>) -> Result<Template, Status> {
pub fn settings_permissions(cookie: SessionCookie, settings: &State<Settings>) -> Result<Template, Status> {
let member = match cookie.member {
//Unwraps member from cookie or send user to login if no member specified (user skipped member selection)
Some(member) => member,

8
src/modules/api/appointments/create.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::database::model::appointments::Appointment;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
@ -31,7 +31,7 @@ pub struct CreateAppointmentData{
/// * modules.scheduler.appointments.edit on specified entity
#[post("/api/appointments", format = "json", data = "<create_appointment_data>")]
pub fn create_appointment(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_appointment_data: Json<CreateAppointmentData>,
) -> Result<Json<Appointment>, Json<ApiErrorWrapper>> {
@ -40,7 +40,7 @@ pub fn create_appointment(
let apentity_id : uuid::Uuid = parse_uuid_string(cad.entity_id)?;
if !check_access_to_resource(&settings, caller.entity_id, apentity_id, crate::permissions::modules::scheduler::appointments::EDIT){
if !check_access_to_resource(settings, caller.entity_id, apentity_id, crate::permissions::modules::scheduler::appointments::EDIT){
return Err(Json(
ApiError::new(403, "Keine Berechtigung, Termine anzulegen!".to_string()).to_wrapper(),
));
@ -55,7 +55,7 @@ pub fn create_appointment(
};
let aptype_id : uuid::Uuid = parse_uuid_string(cad.type_id)?;
match add_appointment(&settings, aptype_id, apentity_id, apdate){
match add_appointment(settings, aptype_id, apentity_id, apdate){
Ok(appointment) => Ok(Json(appointment)),
Err(e) => Err(translate_diesel(e))
}

10
src/modules/api/appointments/delete.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
@ -23,25 +23,25 @@ use crate::database::controller::appointments::{remove_appointment, get_appointm
/// * modules.scheduler.appointments.edit on specified entity
#[delete("/api/appointments/<appointment_id>", format = "json")]
pub fn delete_appointment(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
appointment_id: String,
) -> Result<(), Json<ApiErrorWrapper>> {
let caller = parse_member_cookie(cookie.member)?;
let ap_id : uuid::Uuid = parse_uuid_string(appointment_id)?;
let ap = match get_appointment_with_id(&settings, ap_id){
let ap = match get_appointment_with_id(settings, ap_id){
Ok(ap) => ap,
Err(e) => return Err(translate_diesel(e))
};
if !check_access_to_resource(&settings, caller.entity_id, ap.entity_id, crate::permissions::modules::scheduler::appointments::EDIT){
if !check_access_to_resource(settings, caller.entity_id, ap.entity_id, crate::permissions::modules::scheduler::appointments::EDIT){
return Err(Json(
ApiError::new(403, "Keine Berechtigung, Termine zu löschen!".to_string()).to_wrapper(),
));
}
match remove_appointment(&settings, ap_id){
match remove_appointment(settings, ap_id){
Ok(_) => Ok(()),
Err(e) => Err(translate_diesel(e))
}

12
src/modules/api/appointments/read.rs

@ -2,7 +2,7 @@ use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use crate::database::model::appointments::{AppointmentType, Appointment};
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
use crate::database::controller::appointments::{get_appointment_types, get_appointment_for_entity};
@ -22,12 +22,12 @@ use crate::database::controller::members::check_access_to_resource;
/// * None
#[get("/api/appointments/types", format = "json")]
pub fn read_appointment_types(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
) -> Result<Json<Vec<AppointmentType>>, Json<ApiErrorWrapper>> {
parse_member_cookie(cookie.member)?;
match get_appointment_types(&settings){
match get_appointment_types(settings){
Ok(at) => Ok(Json(at)),
Err(e) => Err(translate_diesel(e)),
}
@ -46,20 +46,20 @@ pub fn read_appointment_types(
/// * modules.scheduler.appointments.view
#[get("/api/appointments?<entity_id>", format = "json")]
pub fn read_appointments_for_entity(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
entity_id: String,
) -> Result<Json<Vec<Appointment>>, Json<ApiErrorWrapper>> {
let caller = parse_member_cookie(cookie.member)?;
let entity_id = parse_uuid_string(entity_id)?;
if !check_access_to_resource(&settings, caller.entity_id, entity_id, crate::permissions::modules::scheduler::appointments::VIEW){
if !check_access_to_resource(settings, caller.entity_id, entity_id, crate::permissions::modules::scheduler::appointments::VIEW){
return Err(Json(
ApiError::new(403, "Keine Berechtigung, Termine anzuzeigen!".to_string()).to_wrapper(),
));
}
match get_appointment_for_entity(&settings, entity_id){
match get_appointment_for_entity(settings, entity_id){
Ok(at) => Ok(Json(at)),
Err(e) => Err(translate_diesel(e)),
}

22
src/modules/api/communicator/create.rs

@ -2,7 +2,7 @@ use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::member_management::controller::parser::parse_member_cookie;
use crate::helper::mail_queue::queue::{Mail, MailQueue};
@ -33,7 +33,7 @@ pub struct ApiEmail{
}
#[post("/api/communicator/email", format = "json", data = "<mail>")]
pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie: SessionCookie, mail: Json<ApiEmail>) -> Result<(), Json<ApiErrorWrapper>>{
pub fn create_email(mq: &State<Arc<MailQueue>>, settings: &State<Settings>, cookie: SessionCookie, mail: Json<ApiEmail>) -> Result<(), Json<ApiErrorWrapper>>{
let caller = parse_member_cookie(cookie.member)?;
if !caller.has_permission(crate::permissions::modules::communicator::email::SEND.to_string()){
return Err(Json(ApiError::new(403, "Keine Berechtigung Email zu versenden!".to_string()).to_wrapper()));
@ -54,7 +54,7 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
match mail.to_members{
Some(members) => {
for member_id in members{
match get_member_email_addresses(&settings, member_id){
match get_member_email_addresses(settings, member_id){
Ok(mut addresses) => {
to.append(addresses.as_mut());
}
@ -76,7 +76,7 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
match mail.cc_members{
Some(members) => {
for member_id in members{
match get_member_email_addresses(&settings, member_id){
match get_member_email_addresses(settings, member_id){
Ok(mut addresses) => {
cc.append(addresses.as_mut());
}
@ -98,7 +98,7 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
match mail.bcc_members{
Some(members) => {
for member_id in members{
match get_member_email_addresses(&settings, member_id){
match get_member_email_addresses(settings, member_id){
Ok(mut addresses) => {
bcc.append(addresses.as_mut());
}
@ -116,8 +116,8 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
None => {}
Some(groups) => {
for group in groups{
if !check_access_to_resource(&settings, caller.entity_id, group, crate::permissions::modules::communicator::email::SEND){
match get_group(&settings, group){
if !check_access_to_resource(settings, caller.entity_id, group, crate::permissions::modules::communicator::email::SEND){
match get_group(settings, group){
Ok(group) => {
return Err(Json(ApiError::new(403, format!("Keine Berechtigung eine Email an die Gruppe {} zu schicken!", group.name)).to_wrapper()))
}
@ -126,7 +126,7 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
}
}
}
match get_group_email_addresses(&settings, group){
match get_group_email_addresses(settings, group){
Ok(mut emails) => {
bcc.append(emails.as_mut());
}
@ -142,8 +142,8 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
None => {}
Some(units) => {
for unit in units{
if !check_access_to_resource(&settings, caller.entity_id, unit, crate::permissions::modules::communicator::email::SEND){
match get_unit(&settings, unit){
if !check_access_to_resource(settings, caller.entity_id, unit, crate::permissions::modules::communicator::email::SEND){
match get_unit(settings, unit){
Ok(unit) => {
return Err(Json(ApiError::new(403, format!("Keine Berechtigung eine Email an die Einheit {} zu schicken!", unit.name)).to_wrapper()))
}
@ -152,7 +152,7 @@ pub fn create_email(mq: State<Arc<MailQueue>>, settings: State<Settings>, cookie
}
}
}
match get_unit_email_addresses(&settings, unit){
match get_unit_email_addresses(settings, unit){
Ok(mut emails) => {
bcc.append(emails.as_mut());
}

8
src/modules/api/event_organisers/create.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::database::model::organisers::Organiser;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::parse_member_cookie;
@ -21,7 +21,7 @@ pub struct CreateOrganiserData{
#[post("/api/event_organisers", format = "json", data = "<create_organiser_data>")]
pub fn create_organiser(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_organiser_data: Json<CreateOrganiserData>,
) -> Result<Json<Organiser>, Json<ApiErrorWrapper>> {
@ -34,7 +34,7 @@ pub fn create_organiser(
let organiser_create_data = create_organiser_data.into_inner();
let entity_id2 = match generate_entity(&settings){
let entity_id2 = match generate_entity(settings){
Ok(ent) => ent,
Err(_e) => return Err(Json(ApiError::new(500, "Konnte keine neue Entität anlegen!".to_string()).to_wrapper()))
};
@ -49,7 +49,7 @@ pub fn create_organiser(
other: organiser_create_data.other
};
match add_organiser(&settings, input){
match add_organiser(settings, input){
Ok(org) => Ok(Json(org)),
Err(e) => Err(translate_diesel(e))
}

6
src/modules/api/event_organisers/delete.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::parse_member_cookie;
@ -11,7 +11,7 @@ use crate::database::controller::entities::remove_entity;
#[delete("/api/event_organisers", format = "json", data = "<organiser_list>")]
pub fn delete_organisers(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
organiser_list: Json<Vec<uuid::Uuid>>,
) -> Result<(), Json<ApiErrorWrapper>> {
@ -25,7 +25,7 @@ pub fn delete_organisers(
let organiser_list = organiser_list.into_inner();
for organiser in organiser_list {
match remove_entity(&settings, organiser){
match remove_entity(settings, organiser){
Ok(_) => {}
Err(e) => return Err(translate_diesel(e)),
}

12
src/modules/api/event_organisers/read.rs

@ -2,7 +2,7 @@ use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
use crate::database::model::organisers::Organiser;
@ -20,14 +20,14 @@ pub struct OrganiserList{
/// * modules.event_management.organisers.view (optional, limited set will provided if permission missing)
#[get("/api/event_organisers/<entity_id>", format = "json")]
pub fn read_organiser(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
entity_id: String,
) -> Result<Json<Organiser>, Json<ApiErrorWrapper>>{
let caller = parse_member_cookie(cookie.member)?;
let entity_id = parse_uuid_string(entity_id)?;
match get_organiser(&settings, entity_id){
match get_organiser(settings, entity_id){
Ok(organiser) => {
if caller.has_permission(crate::permissions::modules::event_management::organisers::VIEW.to_string()){
Ok(Json(organiser))
@ -46,7 +46,7 @@ pub fn read_organiser(
#[get("/api/event_organisers?<entries>&<page>&<q>", format = "json")]
pub fn read_organisers(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
entries: Option<i64>, //TODO: replace with limit/offset
page: Option<i64>,
@ -87,12 +87,12 @@ pub fn read_organisers(
total_organiser_count: 0
};
match get_organisers(&settings, entries, (page-1)*entries, q){
match get_organisers(settings, entries, (page-1)*entries, q){
Ok(organisers) => res.organisers = organisers,
Err(e) => return Err(translate_diesel(e))
};
match get_organiser_count(&settings){
match get_organiser_count(settings){
Ok(count) => res.total_organiser_count = count,
Err(e) => return Err(translate_diesel(e))
};

6
src/modules/api/event_organisers/update.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::event_organisers::create::CreateOrganiserData;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
@ -11,7 +11,7 @@ use crate::helper::translate_diesel_error::translate_diesel;
#[put("/api/event_organisers/<organiser_id>", format = "json", data = "<change_organiser_data>")]
pub fn update_organiser(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
change_organiser_data: Json<CreateOrganiserData>,
organiser_id: String,
@ -37,7 +37,7 @@ pub fn update_organiser(
other: cod.other
};
match change_organiser(&settings, org){
match change_organiser(settings, org){
Ok(_) => Ok(()),
Err(e) => Err(translate_diesel(e))
}

8
src/modules/api/events/create.rs

@ -2,7 +2,7 @@ use chrono::NaiveDateTime;
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_option_uuid};
use crate::database::model::events::Event;
@ -28,7 +28,7 @@ pub struct CreateEventData{
#[post("/api/events", format = "json", data = "<create_event_data>")]
pub fn create_event(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_event_data: Json<CreateEventData>,
) -> Result<Json<Event>, Json<ApiErrorWrapper>> {
@ -41,7 +41,7 @@ pub fn create_event(
let ecd = create_event_data.into_inner();
let entity_id2 = match generate_entity(&settings){
let entity_id2 = match generate_entity(settings){
Ok(ent) => ent,
Err(_e) => return Err(Json(ApiError::new(500, "Konnte keine neue Entität anlegen!".to_string()).to_wrapper()))
};
@ -82,7 +82,7 @@ pub fn create_event(
other_intern: ecd.other_intern
};
match add_event(&settings, input){
match add_event(settings, input){
Ok(event) => Ok(Json(event)),
Err(e) => Err(translate_diesel(e))
}

6
src/modules/api/events/delete.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
use crate::database::controller::entities::remove_entity;
@ -9,7 +9,7 @@ use crate::helper::translate_diesel_error::translate_diesel;
#[delete("/api/events/<event_id>", format = "json")]
pub fn delete_event(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
event_id: String,
) -> Result<(), Json<ApiErrorWrapper>> {
@ -22,7 +22,7 @@ pub fn delete_event(
));
}
match remove_entity(&settings, event_id){
match remove_entity(settings, event_id){
Ok(_) => {}
Err(e) => return Err(translate_diesel(e)),
}

14
src/modules/api/events/event_units/position/create.rs

@ -1,7 +1,7 @@
use crate::helper::session_cookies::model::SessionCookie;
use rocket::State;
use crate::helper::settings::Settings;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
use crate::database::controller::entities::generate_entity;
@ -19,7 +19,7 @@ pub struct CreatePositionData{
#[post("/api/events/units/positions", format = "json", data = "<create_position_data>")]
pub fn create_event_unit_position(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_position_data: Json<CreatePositionData>,
) -> Result<Json<EventUnitPosition>, Json<ApiErrorWrapper>> {
@ -31,7 +31,7 @@ pub fn create_event_unit_position(
}
let create_position_data = create_position_data.into_inner();
let entity_id = match generate_entity(&settings){
let entity_id = match generate_entity(settings){
Ok(entity) => entity,
Err(_e) => return Err(Json(ApiError::new(500, "Konnte keine neue Entität anlegen.".to_string()).to_wrapper())),
};
@ -50,7 +50,7 @@ pub fn create_event_unit_position(
requirements
};
match add_event_unit_position(&settings, event_position){
match add_event_unit_position(settings, event_position){
Ok(eup) => Ok(Json(eup)),
Err(e) => Err(translate_diesel(e))
}
@ -68,7 +68,7 @@ pub struct CreateVehiclePositionData{
#[post("/api/events/units/vehicle_positions", format = "json", data = "<create_vehicle_position_data>")]
pub fn create_event_unit_vehicle_position(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_vehicle_position_data: Json<CreateVehiclePositionData>,
) -> Result<Json<EventUnitVehiclePosition>, Json<ApiErrorWrapper>> {
@ -80,7 +80,7 @@ pub fn create_event_unit_vehicle_position(
}
let cvpd = create_vehicle_position_data.into_inner();
let entity_id = match generate_entity(&settings){
let entity_id = match generate_entity(settings){
Ok(entity) => entity,
Err(_e) => return Err(Json(ApiError::new(500, "Konnte keine neue Entität anlegen.".to_string()).to_wrapper())),
};
@ -93,7 +93,7 @@ pub fn create_event_unit_vehicle_position(
template_id: parse_uuid_string(cvpd.template_id)?,
};
match add_vehicle_position(&settings, pos){
match add_vehicle_position(settings, pos){
Ok(pos) => Ok(Json(pos)),
Err(e) => Err(translate_diesel(e))
}

10
src/modules/api/events/event_units/position/delete.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::parse_member_cookie;
use crate::database::controller::entities::remove_entity;
@ -9,7 +9,7 @@ use crate::helper::translate_diesel_error::translate_diesel;
#[delete("/api/events/units/positions", format = "json", data = "<delete_list>")]
pub fn delete_event_unit_positions(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
delete_list: Json<Vec<uuid::Uuid>>,
) -> Result<(), Json<ApiErrorWrapper>> {
@ -23,7 +23,7 @@ pub fn delete_event_unit_positions(
let delete_list = delete_list.into_inner();
for position in delete_list {
match remove_entity(&settings, position){
match remove_entity(settings, position){
Ok(_) => {}
Err(e) => return Err(translate_diesel(e)),
}
@ -34,7 +34,7 @@ pub fn delete_event_unit_positions(
#[delete("/api/events/units/vehicle_positions", format = "json", data = "<delete_list>")]
pub fn delete_event_unit_vehicle_positions(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
delete_list: Json<Vec<uuid::Uuid>>,
) -> Result<(), Json<ApiErrorWrapper>> {
@ -48,7 +48,7 @@ pub fn delete_event_unit_vehicle_positions(
let delete_list = delete_list.into_inner();
for position in delete_list {
match remove_entity(&settings, position){
match remove_entity(settings, position){
Ok(_) => {}
Err(e) => return Err(translate_diesel(e)),
}

12
src/modules/api/events/event_units/position/read.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::database::model::events::EventUnitPosition;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
@ -17,7 +17,7 @@ pub struct EventUnitPositionList{
#[get("/api/events/units/positions?<limit>&<offset>&<q>", format = "json")]
pub fn read_event_unit_position(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
limit: Option<i64>,
offset: Option<i64>,
@ -39,12 +39,12 @@ pub fn read_event_unit_position(
None => 0,
};
let positions = match get_event_unit_positions(&settings, limit, offset, q){
let positions = match get_event_unit_positions(settings, limit, offset, q){
Ok(pos) => pos,
Err(e) => return Err(translate_diesel(e))
};
let total_position_count = match get_event_unit_positions_count(&settings){
let total_position_count = match get_event_unit_positions_count(settings){
Ok(count) => count,
Err(e) => return Err(translate_diesel(e))
};
@ -64,13 +64,13 @@ pub struct PositionCheckResult{
#[get("/api/events/units/positions/<position_id>/check_requirements?<target_to_check>", format = "json")]
pub fn get_check_position_requirements(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
position_id: String,
target_to_check: String,
) -> Result<Json<PositionCheckResult>, Json<ApiErrorWrapper>> {
let caller = parse_member_cookie(cookie.member)?;
match check_position_requirements(&settings, parse_uuid_string(position_id)?, parse_uuid_string(target_to_check)?){
match check_position_requirements(settings, parse_uuid_string(position_id)?, parse_uuid_string(target_to_check)?){
Ok(res) => Ok(Json(PositionCheckResult{
requirements_fulfilled: res
})),

6
src/modules/api/events/event_units/position/update.rs

@ -1,7 +1,7 @@
use crate::helper::session_cookies::model::SessionCookie;
use rocket::State;
use crate::helper::settings::Settings;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
@ -12,7 +12,7 @@ use crate::modules::api::events::event_units::position::create::CreatePositionDa
#[put("/api/events/units/positions/<entity_id>", format = "json", data = "<update_position_data>")]
pub fn update_event_unit_position(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
update_position_data: Json<CreatePositionData>,
entity_id : String,
@ -41,7 +41,7 @@ pub fn update_event_unit_position(
requirements
};
match set_event_unit_position(&settings, event_position){
match set_event_unit_position(settings, event_position){
Ok(eup) => Ok(Json(eup)),
Err(e) => Err(translate_diesel(e))
}

8
src/modules/api/events/event_units/templates/create.rs

@ -1,7 +1,7 @@
use rocket::State;
use crate::helper::settings::Settings;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::parse_member_cookie;
use crate::database::controller::entities::generate_entity;
@ -18,7 +18,7 @@ pub struct CreateTemplateData{
#[post("/api/events/units/templates", format = "json", data = "<create_template_data>")]
pub fn create_event_unit_template(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
create_template_data: Json<CreateTemplateData>,
) -> Result<Json<EventUnitTemplate>, Json<ApiErrorWrapper>> {
@ -30,7 +30,7 @@ pub fn create_event_unit_template(
}
let create_template_data = create_template_data.into_inner();
let entity_id = match generate_entity(&settings){
let entity_id = match generate_entity(settings){
Ok(entity) => entity,
Err(_e) => return Err(Json(ApiError::new(500, "Konnte keine neue Entität anlegen.".to_string()).to_wrapper())),
};
@ -41,7 +41,7 @@ pub fn create_event_unit_template(
description: create_template_data.description,
};
match add_event_unit_template(&settings, event_position){
match add_event_unit_template(settings, event_position){
Ok(eup) => Ok(Json(eup)),
Err(e) => Err(translate_diesel(e))
}

10
src/modules/api/events/event_units/templates/delete.rs

@ -1,7 +1,7 @@
use crate::helper::settings::Settings;
use rocket::State;
use crate::helper::session_cookies::model::SessionCookie;
use rocket_contrib::json::Json;
use rocket::serde::json::Json;
use crate::modules::api::model::api_outcome::{ApiErrorWrapper, ApiError};
use crate::modules::api::member_management::controller::parser::{parse_member_cookie, parse_uuid_string};
use crate::database::controller::entities::remove_entity;
@ -10,7 +10,7 @@ use crate::database::controller::events::remove_positions_from_template;
#[delete("/api/events/units/templates", format = "json", data = "<template_list>")]
pub fn delete_templates(
settings: State<Settings>,
settings: &State<Settings>,
cookie: SessionCookie,
template_list: Json<Vec<uuid::Uuid>>,
) -> Result<(), Json<ApiErrorWrapper>> {
@ -24,7 +24,7 @@ pub fn delete_templates(
let template_list = template_list.into_inner();
for template in template_list {
match remove_entity(&settings, template){
match remove_entity(settings, template){
Ok(_) => {}
Err(e) => return Err(translate_diesel(e)),
}
@ -35,7 +35,7 @@ pub fn delete_templates(