2020-04-23 03:28:51 +00:00
|
|
|
use super::schema::events;
|
2021-01-16 19:58:46 +00:00
|
|
|
use chrono::{NaiveDateTime, Utc};
|
2020-04-23 03:28:51 +00:00
|
|
|
|
2020-05-01 21:29:09 +00:00
|
|
|
#[derive(Queryable, Clone, Debug)]
|
2020-04-23 03:28:51 +00:00
|
|
|
pub struct Event {
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event ID
|
2020-04-23 03:28:51 +00:00
|
|
|
pub id: i32,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event name
|
2020-04-23 03:28:51 +00:00
|
|
|
pub event_name: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event long description
|
2020-04-23 03:28:51 +00:00
|
|
|
pub event_desc: String,
|
2020-05-02 18:35:47 +00:00
|
|
|
/// Event location
|
|
|
|
pub event_loc: String,
|
|
|
|
/// Event organizer
|
|
|
|
pub organizer: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event datetime
|
2020-04-23 03:28:51 +00:00
|
|
|
pub event_time: NaiveDateTime,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event discord message id
|
2020-04-23 03:28:51 +00:00
|
|
|
pub message_id: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event message thumbnail link
|
2020-04-23 03:28:51 +00:00
|
|
|
pub thumbnail_link: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Reminder sent tracker
|
2020-04-26 01:04:13 +00:00
|
|
|
pub reminder_sent: i32,
|
2020-04-23 03:28:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 22:13:23 +00:00
|
|
|
impl Into<NewEvent> for Event {
|
|
|
|
fn into(self) -> NewEvent {
|
|
|
|
NewEvent {
|
|
|
|
event_name: self.event_name.clone(),
|
|
|
|
event_desc: self.event_desc.clone(),
|
2020-05-02 18:35:47 +00:00
|
|
|
organizer: self.organizer.clone(),
|
|
|
|
event_loc: self.event_loc.clone(),
|
2021-01-16 03:51:26 +00:00
|
|
|
event_time: self.event_time,
|
2020-04-27 22:13:23 +00:00
|
|
|
message_id: self.message_id.clone(),
|
|
|
|
thumbnail_link: self.message_id.clone(),
|
|
|
|
reminder_sent: self.reminder_sent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 21:29:09 +00:00
|
|
|
#[derive(Insertable, Clone, Debug)]
|
2020-04-26 20:06:55 +00:00
|
|
|
#[table_name = "events"]
|
2020-04-24 00:45:02 +00:00
|
|
|
pub struct NewEvent {
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event name
|
2020-04-24 00:45:02 +00:00
|
|
|
pub event_name: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event long description
|
2020-04-24 00:45:02 +00:00
|
|
|
pub event_desc: String,
|
2020-05-02 18:35:47 +00:00
|
|
|
/// Event location
|
|
|
|
pub event_loc: String,
|
|
|
|
/// Event organizer
|
|
|
|
pub organizer: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event datetime
|
2020-04-24 00:45:02 +00:00
|
|
|
pub event_time: NaiveDateTime,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event discord message id
|
2020-04-24 00:45:02 +00:00
|
|
|
pub message_id: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Event message thumbnail link
|
2020-04-24 00:45:02 +00:00
|
|
|
pub thumbnail_link: String,
|
2020-04-26 20:06:55 +00:00
|
|
|
/// Reminder sent tracker
|
2020-04-26 01:04:13 +00:00
|
|
|
pub reminder_sent: i32,
|
2020-04-23 03:28:51 +00:00
|
|
|
}
|
2021-01-16 19:58:46 +00:00
|
|
|
|
|
|
|
impl Default for NewEvent {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
message_id: String::default(),
|
|
|
|
event_time: Utc::now().naive_utc(),
|
|
|
|
event_name: String::default(),
|
|
|
|
organizer: String::default(),
|
|
|
|
event_desc: String::default(),
|
|
|
|
event_loc: String::default(),
|
|
|
|
thumbnail_link: String::default(),
|
|
|
|
reminder_sent: i32::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|