Skip to content

Commit

Permalink
add organizer field to events
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Jan 18, 2019
1 parent 2171e02 commit d056cf1
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 0 deletions.
@@ -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;
2 changes: 2 additions & 0 deletions openapi.yaml
Expand Up @@ -563,6 +563,8 @@ components:
- homepage
example: telephone
description: Type of registration
organizer:
type: string
example:
title: A great event
start: 1547403505
Expand Down
1 change: 1 addition & 0 deletions src/core/entities.rs
Expand Up @@ -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)]
Expand Down
7 changes: 7 additions & 0 deletions src/core/usecases/create_new_event.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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()?;
Expand Down
2 changes: 2 additions & 0 deletions src/infrastructure/db/sqlite/connection.rs
Expand Up @@ -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
Expand Down Expand Up @@ -386,6 +387,7 @@ impl EventGateway for SqliteConnection {
tags,
created_by,
registration,
organizer,
})
}

Expand Down
1 change: 1 addition & 0 deletions src/infrastructure/db/sqlite/models.rs
Expand Up @@ -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)]
Expand Down
6 changes: 6 additions & 0 deletions src/infrastructure/db/sqlite/schema.rs
Expand Up @@ -99,6 +99,7 @@ table! {
homepage -> Nullable<Text>,
created_by -> Nullable<Text>,
registration -> Nullable<SmallInt>,
organizer -> Nullable<Text>,
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/infrastructure/db/sqlite/util.rs
Expand Up @@ -131,6 +131,7 @@ impl From<e::Event> for Event {
homepage,
created_by,
registration,
organizer,
..
} = e;

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

0 comments on commit d056cf1

Please sign in to comment.