Compare commits
No commits in common. "d00570ff2fadcb2994f009c21f27bb0ab8128429" and "5f6cb9a12b4596ee58164c65ee267a95a69d88f3" have entirely different histories.
d00570ff2f
...
5f6cb9a12b
@ -98,7 +98,6 @@ FROM trip WHERE planned_event_id = ?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct EventUpdate<'a> {
|
pub struct EventUpdate<'a> {
|
||||||
pub name: &'a str,
|
pub name: &'a str,
|
||||||
pub planned_amount_cox: i32,
|
pub planned_amount_cox: i32,
|
||||||
@ -344,10 +343,6 @@ WHERE trip_details.id=?
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_cancelled(&self) -> bool {
|
|
||||||
self.max_people == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_ics_feed(db: &SqlitePool) -> String {
|
pub async fn get_ics_feed(db: &SqlitePool) -> String {
|
||||||
let mut calendar = ICalendar::new("2.0", "ics-rs");
|
let mut calendar = ICalendar::new("2.0", "ics-rs");
|
||||||
|
|
||||||
@ -360,22 +355,7 @@ WHERE trip_details.id=?
|
|||||||
event.day.replace('-', ""),
|
event.day.replace('-', ""),
|
||||||
event.planned_starting_time.replace(':', "")
|
event.planned_starting_time.replace(':', "")
|
||||||
)));
|
)));
|
||||||
let mut name = String::new();
|
vevent.push(Summary::new(event.name));
|
||||||
if event.is_cancelled() {
|
|
||||||
name.push_str("ABGESAGT! :-( ");
|
|
||||||
}
|
|
||||||
name.push_str(&format!("{} ", event.name));
|
|
||||||
|
|
||||||
let tripdetails = event.trip_details(db).await;
|
|
||||||
if let Some(triptype) = tripdetails.triptype(db).await {
|
|
||||||
name.push_str(&format!("• {} ", triptype.name))
|
|
||||||
}
|
|
||||||
if let Some(notes) = tripdetails.notes {
|
|
||||||
if !notes.is_empty() {
|
|
||||||
name.push_str(&format!("({notes}) "))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vevent.push(Summary::new(name));
|
|
||||||
calendar.add_event(vevent);
|
calendar.add_event(vevent);
|
||||||
}
|
}
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
@ -434,6 +414,6 @@ mod test {
|
|||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let actual = Event::get_ics_feed(&pool).await;
|
let actual = Event::get_ics_feed(&pool).await;
|
||||||
assert_eq!("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ics-rs\r\nBEGIN:VEVENT\r\nUID:1@rudernlinz.at\r\nDTSTAMP:19900101T180000\r\nDTSTART:19700101T100000\r\nSUMMARY:test-planned-event (trip_details for a planned event) \r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", actual);
|
assert_eq!("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ics-rs\r\nBEGIN:VEVENT\r\nUID:1@rudernlinz.at\r\nDTSTAMP:19900101T180000\r\nDTSTART:19700101T100000\r\nSUMMARY:test-planned-event\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ use sqlx::{FromRow, SqlitePool};
|
|||||||
use super::{
|
use super::{
|
||||||
notification::Notification,
|
notification::Notification,
|
||||||
trip::{Trip, TripWithUserAndType},
|
trip::{Trip, TripWithUserAndType},
|
||||||
triptype::TripType,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||||
@ -52,13 +51,6 @@ WHERE id like ?
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn triptype(&self, db: &SqlitePool) -> Option<TripType> {
|
|
||||||
match self.trip_type_id {
|
|
||||||
None => None,
|
|
||||||
Some(id) => TripType::find_by_id(db, id).await,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn find_by_startingdatetime(
|
pub async fn find_by_startingdatetime(
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
day: String,
|
day: String,
|
||||||
|
@ -4,7 +4,7 @@ use sqlx::{FromRow, SqlitePool};
|
|||||||
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct TripType {
|
pub struct TripType {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
name: String,
|
||||||
desc: String,
|
desc: String,
|
||||||
question: String,
|
question: String,
|
||||||
icon: String,
|
icon: String,
|
||||||
|
@ -40,7 +40,7 @@ async fn create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add constraints (e.g. planned_amount_cox > 0)
|
//TODO: add constraints (e.g. planned_amount_cox > 0)
|
||||||
#[derive(FromForm, Debug)]
|
#[derive(FromForm)]
|
||||||
struct UpdateEventForm<'r> {
|
struct UpdateEventForm<'r> {
|
||||||
id: i64,
|
id: i64,
|
||||||
name: &'r str,
|
name: &'r str,
|
||||||
|
@ -251,7 +251,6 @@
|
|||||||
{{ macros::input(label='', name='planned_amount_cox', type='hidden', value=event.planned_amount_cox) }}
|
{{ macros::input(label='', name='planned_amount_cox', type='hidden', value=event.planned_amount_cox) }}
|
||||||
{{ macros::input(label='', name='always_show', type='hidden', value=event.always_show) }}
|
{{ macros::input(label='', name='always_show', type='hidden', value=event.always_show) }}
|
||||||
{{ macros::input(label='', name='is_locked', type='hidden', value=event.is_locked) }}
|
{{ macros::input(label='', name='is_locked', type='hidden', value=event.is_locked) }}
|
||||||
{{ macros::input(label='', name='trip_type', type='hidden', value=event.trip_type_id) }}
|
|
||||||
<input value="Ausfahrt absagen" class="btn btn-alert" type="submit" />
|
<input value="Ausfahrt absagen" class="btn btn-alert" type="submit" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user