[Draft] Implement Early deletion by Submitter #37 #38
11 changed files with 539 additions and 341 deletions
update/upgrade dependencies
- and fix build afterwards - fix generate_thirdparty.sh script
commit
a1c6b3b03b
791
Cargo.lock
generated
791
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
26
Cargo.toml
26
Cargo.toml
|
|
@ -13,33 +13,33 @@ readme = "README.md"
|
|||
|
||||
[workspace.dependencies]
|
||||
actix-files = "0.6.2"
|
||||
actix-web = "4.2.1"
|
||||
actix-web = "4.3.0"
|
||||
actix-session = { version = "0.7.2", features = ["cookie-session"] }
|
||||
actix-multipart = "0.4.0"
|
||||
actix-multipart = "0.5.0"
|
||||
better_toml_datetime = { path = "packages/better_toml_datetime" }
|
||||
cargo-bundle-licenses = { version = "1.0.1", default-features = false }
|
||||
chrono = { version = "0.4.22", default-features = false, features = ["std","clock"] }
|
||||
chrono-tz = "0.6.3"
|
||||
clap = { version = "4.0.10", features = ["derive", "env"] }
|
||||
futures-util = "0.3.24"
|
||||
handlebars = { version = "4.3.5", features = ["dir_source"] }
|
||||
chrono = { version = "0.4.23", default-features = false, features = ["std","clock"] }
|
||||
chrono-tz = "0.8.1"
|
||||
clap = { version = "4.1.4", features = ["derive", "env"] }
|
||||
futures-util = "0.3.25"
|
||||
handlebars = { version = "4.3.6", features = ["dir_source"] }
|
||||
http = "0.2.8"
|
||||
lettre = { version = "0.10.1", default-features = false, features = ["sendmail-transport", "tokio1", "builder", "serde"] }
|
||||
# use rustls a native tls library rather than openssl,
|
||||
# as depending on c dependencies can get annoying even when vendoring
|
||||
ldap3 = { version = "0.10.5", default-features = false, features = ["tls-rustls"] }
|
||||
ldap3 = { version = "0.11.1", default-features = false, features = ["tls-rustls"] }
|
||||
listenfd = "1.0.0"
|
||||
log = "0.4.17"
|
||||
mime_guess = "2.0.4"
|
||||
multipart_helper = {path = "packages/multipart_helper"}
|
||||
pretty_env_logger = "0.4.0"
|
||||
rand = "0.8.5"
|
||||
serde = { version = "1.0.145", features = ["derive"] } # https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
serde_json = "1.0.85"
|
||||
serde = { version = "1.0.152", features = ["derive"] } # https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
serde_json = "1.0.91"
|
||||
tempfile = "3.3.0"
|
||||
thiserror = "1.0.37"
|
||||
toml = "0.5.9"
|
||||
tokio = "1.21.2"
|
||||
thiserror = "1.0.38"
|
||||
toml = "0.7.0"
|
||||
tokio = "1.24.2"
|
||||
url = { version = "2.3.1", features = ["serde"] }
|
||||
|
||||
[profile.release]
|
||||
|
|
|
|||
|
|
@ -156,14 +156,14 @@ impl TryFrom<toml::value::Datetime> for Time {
|
|||
#[derive(Clone, Debug, Hash)]
|
||||
pub enum Offset {
|
||||
Z,
|
||||
Custom { hours: i8, minutes: u8 },
|
||||
Custom { minutes: i16 },
|
||||
}
|
||||
|
||||
impl From<toml::value::Offset> for Offset {
|
||||
fn from(toml_offset: toml::value::Offset) -> Self {
|
||||
match toml_offset {
|
||||
toml::value::Offset::Z => Self::Z,
|
||||
toml::value::Offset::Custom { hours, minutes } => Self::Custom { hours, minutes },
|
||||
toml::value::Offset::Custom { minutes } => Self::Custom { minutes },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ impl From<Offset> for toml::value::Offset {
|
|||
fn from(our_offset: Offset) -> Self {
|
||||
match our_offset {
|
||||
Offset::Z => Self::Z,
|
||||
Offset::Custom { hours, minutes } => Self::Custom { hours, minutes },
|
||||
Offset::Custom { minutes } => Self::Custom { minutes },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
packages/jobboerse/THIRDPARTY.toml
(Stored with Git LFS)
BIN
packages/jobboerse/THIRDPARTY.toml
(Stored with Git LFS)
Binary file not shown.
|
|
@ -411,13 +411,12 @@ impl JobOffer<PathBuf> {
|
|||
.map(|date| toml_date_to_chrono_date(&date.0))
|
||||
.unwrap_or_else(|| {
|
||||
toml_datetime_to_chrono_datetime(&self.date_of_submission)
|
||||
.date()
|
||||
.add(chrono::Duration::days(6 * 30))
|
||||
});
|
||||
|
||||
use chrono::Offset as _;
|
||||
let now = crate::util::now();
|
||||
let now_date = now.with_timezone(&now.offset().fix()).date();
|
||||
let now_date = now.with_timezone(&now.offset().fix());
|
||||
|
||||
now_date > expires_after
|
||||
}
|
||||
|
|
@ -727,7 +726,7 @@ impl JobOffers {
|
|||
Tz: TimeZone,
|
||||
Tz::Offset: std::fmt::Display,
|
||||
{
|
||||
let submission_date = submission_time.date().format("%Y-%m-%d").to_string();
|
||||
let submission_date = submission_time.format("%F").to_string();
|
||||
let seconds_since_midnight = submission_time.num_seconds_from_midnight();
|
||||
|
||||
let guard = self.data.write().await;
|
||||
|
|
@ -960,7 +959,7 @@ mod test {
|
|||
|
||||
println!("{}", serialized);
|
||||
|
||||
toml::de::from_str::<'_, JobOfferStatus>(&serialized).expect_err(
|
||||
toml::de::from_str::<JobOfferStatus>(&serialized).expect_err(
|
||||
"V1 should not parse as current, this will prevent migration from applying",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ fn base<'a>(
|
|||
banner: config.config.banner.clone(),
|
||||
operation_mode: config.args.mode.clone(),
|
||||
dev_build: dev_available,
|
||||
date: crate::util::now().date().format("%F").to_string(),
|
||||
date: crate::util::now().format("%F").to_string(),
|
||||
};
|
||||
|
||||
Ok(data)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ impl JobOfferSubmitForm {
|
|||
}
|
||||
name => {
|
||||
warn!(
|
||||
"Unknown field `{}` in multipart form: {}",
|
||||
"Unknown field `{}` in multipart form: {:?}",
|
||||
name,
|
||||
field.content_type()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ impl JobOfferEditForm {
|
|||
}
|
||||
name => {
|
||||
warn!(
|
||||
"Unknown field `{}` in multipart form: {}",
|
||||
"Unknown field `{}` in multipart form: {:?}",
|
||||
name,
|
||||
field.content_type()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -284,4 +284,3 @@ pub(crate) enum FormProcessingError {
|
|||
#[error("invalid hash")]
|
||||
InvalidHash,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::job_offers::{Attachment, Link};
|
||||
use better_toml_datetime::Offset;
|
||||
use chrono::{DateTime, FixedOffset, NaiveDate, Offset as _, TimeZone, Utc};
|
||||
use chrono::{DateTime, FixedOffset, NaiveDate, NaiveTime, Offset as _, TimeZone, Utc};
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use std::str::FromStr;
|
||||
use tempfile::NamedTempFile;
|
||||
|
|
@ -20,7 +20,6 @@ pub fn chrono_datetime_to_toml_datetime<Tz: chrono::TimeZone>(
|
|||
|
||||
let offset_seconds = datetime.offset().fix().local_minus_utc();
|
||||
let offset_minutes = offset_seconds / 60;
|
||||
let offset_hours = offset_minutes / 60;
|
||||
|
||||
toml::value::Datetime {
|
||||
date: Some(toml::value::Date {
|
||||
|
|
@ -53,25 +52,22 @@ pub fn chrono_datetime_to_toml_datetime<Tz: chrono::TimeZone>(
|
|||
nanosecond: datetime.nanosecond(),
|
||||
}),
|
||||
offset: Some(toml::value::Offset::Custom {
|
||||
hours: offset_hours.try_into().expect(
|
||||
"the hours of the offset should be in the range -12 to 12 and as such fit in an i8",
|
||||
),
|
||||
minutes: (offset_minutes % 60).abs().try_into().expect(
|
||||
"the minutes of the offset should be in the range 0 to 59 and as such fit in an i8",
|
||||
// especially since we have a % 60 and abs() here
|
||||
),
|
||||
minutes: offset_minutes as i16,
|
||||
}),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn toml_date_to_chrono_date(date: &toml::value::Date) -> chrono::Date<FixedOffset> {
|
||||
let local_date = NaiveDate::from_ymd(date.year.into(), date.month.into(), date.day.into());
|
||||
pub fn toml_date_to_chrono_date(date: &toml::value::Date) -> chrono::DateTime<FixedOffset> {
|
||||
let local_date =
|
||||
NaiveDate::from_ymd_opt(date.year.into(), date.month.into(), date.day.into()).unwrap();
|
||||
let offset = chrono_tz::Europe::Berlin
|
||||
.offset_from_local_date(&local_date)
|
||||
.map(|offset| offset.fix())
|
||||
.unwrap();
|
||||
offset.from_local_date(&local_date).unwrap()
|
||||
offset
|
||||
.from_local_datetime(&local_date.and_time(NaiveTime::default()))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn toml_datetime_to_chrono_datetime(
|
||||
|
|
@ -91,32 +87,28 @@ pub fn toml_datetime_to_chrono_datetime(
|
|||
.into()
|
||||
});
|
||||
|
||||
let local_datetime = chrono::NaiveDate::from_ymd(
|
||||
let local_datetime = chrono::NaiveDate::from_ymd_opt(
|
||||
toml_date.year.into(),
|
||||
toml_date.month.into(),
|
||||
toml_date.day.into(),
|
||||
)
|
||||
.and_hms_nano(
|
||||
.unwrap()
|
||||
.and_hms_nano_opt(
|
||||
toml_time.hour.into(),
|
||||
toml_time.minute.into(),
|
||||
toml_time.second.into(),
|
||||
toml_time.nanosecond,
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let offset: FixedOffset = datetime
|
||||
.offset
|
||||
.as_ref()
|
||||
.map(|offset| match offset {
|
||||
Offset::Z => 0,
|
||||
Offset::Custom { hours, minutes } => {
|
||||
let hours: i32 = (*hours).into();
|
||||
let minutes: i32 = (*minutes).into();
|
||||
|
||||
let offset_in_minutes = 60 * hours + hours.signum() * minutes;
|
||||
offset_in_minutes * 60
|
||||
}
|
||||
Offset::Custom { minutes } => *minutes as i32 * 60,
|
||||
})
|
||||
.map(FixedOffset::east)
|
||||
.and_then(|sec_offset| FixedOffset::east_opt(sec_offset))
|
||||
.unwrap_or_else(|| {
|
||||
// try to interpret timestamp as local Europe/Berlin time
|
||||
let tz_result = chrono_tz::Europe::Berlin
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
|
||||
OUT="${DIR}/../packages/jobboerse/THIRDPARTY.toml"
|
||||
RUN_DIR="${DIR}/../packages/jobboerse"
|
||||
|
||||
cargo bundle-licenses --format toml --output packages/jobboerse/THIRDPARTY.toml
|
||||
pushd "${RUN_DIR}"
|
||||
|
||||
cargo bundle-licenses \
|
||||
--format toml \
|
||||
--output "${OUT}"
|
||||
|
||||
popd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue