Permalink
Browse files

add organizer field to events

  • Loading branch information...
Markus Kohlhase
Markus Kohlhase committed Jan 18, 2019
1 parent 2171e02 commit d056cf1b755d6ae950bfbbda87f64a4069952824
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE events ADD COLUMN organizer TEXT;
@@ -563,6 +563,8 @@ components:
- homepage
example: telephone
description: Type of registration
organizer:
type: string
example:
title: A great event
start: 1547403505
@@ -71,6 +71,7 @@ pub struct Event {
pub homepage : Option<String>,
pub created_by : Option<String>,
pub registration : Option<RegistrationType>,
pub organizer : Option<String>,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -29,6 +29,7 @@ pub struct NewEvent {
pub created_by : Option<String>,
pub token : Option<String>,
pub registration : Option<String>,
pub organizer : Option<String>,
}

// TODO: move this into an adapter
@@ -92,6 +93,7 @@ pub fn try_into_new_event<D: Db>(db: &mut D, e: NewEvent) -> Result<Event> {
created_by,
registration,
token,
organizer,
..
} = e;
let org = if let Some(ref token) = token {
@@ -187,6 +189,10 @@ pub fn try_into_new_event<D: Db>(db: &mut D, e: NewEvent) -> Result<Event> {
None => None,
};

let organizer = organizer
.map(|x| x.trim().to_owned())
.filter(|x| !x.is_empty());

let event = Event {
id,
title,
@@ -199,6 +205,7 @@ pub fn try_into_new_event<D: Db>(db: &mut D, e: NewEvent) -> Result<Event> {
tags,
created_by,
registration,
organizer,
};
let event = event.auto_correct();
event.validate()?;
@@ -334,6 +334,7 @@ impl EventGateway for SqliteConnection {
homepage,
created_by,
registration,
organizer,
} = e_dsl::events.filter(e_dsl::id.eq(e_id)).first(self)?;

let tags = e_t_dsl::event_tag_relations
@@ -386,6 +387,7 @@ impl EventGateway for SqliteConnection {
tags,
created_by,
registration,
organizer,
})
}

@@ -43,6 +43,7 @@ pub struct Event {
pub homepage: Option<String>,
pub created_by: Option<String>,
pub registration: Option<i16>,
pub organizer: Option<String>,
}

#[derive(Queryable, Insertable)]
@@ -99,6 +99,7 @@ table! {
homepage -> Nullable<Text>,
created_by -> Nullable<Text>,
registration -> Nullable<SmallInt>,
organizer -> Nullable<Text>,
}
}

@@ -145,6 +146,9 @@ joinable!(entry_category_relations -> categories (category_id));
joinable!(entry_tag_relations -> tags (tag_id));
joinable!(event_tag_relations -> events (event_id));
joinable!(event_tag_relations -> tags (tag_id));
joinable!(events -> users (created_by));
joinable!(org_tag_relations -> organizations (org_id));
joinable!(org_tag_relations -> tags (tag_id));

allow_tables_to_appear_in_same_query!(
bbox_subscriptions,
@@ -155,6 +159,8 @@ allow_tables_to_appear_in_same_query!(
entry_tag_relations,
event_tag_relations,
events,
org_tag_relations,
organizations,
ratings,
tags,
users,
@@ -131,6 +131,7 @@ impl From<e::Event> for Event {
homepage,
created_by,
registration,
organizer,
..
} = e;

@@ -176,6 +177,7 @@ impl From<e::Event> for Event {
homepage,
created_by,
registration,
organizer,
}
}
}
@@ -275,6 +277,7 @@ impl From<(Event, &Vec<EventTagRelation>)> for e::Event {
homepage,
created_by,
registration,
organizer,
..
} = e;
let tags = tag_rels
@@ -323,6 +326,7 @@ impl From<(Event, &Vec<EventTagRelation>)> for e::Event {
tags,
created_by,
registration,
organizer,
}
}
}

0 comments on commit d056cf1

Please sign in to comment.