aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/controllers/film.rs4
-rw-r--r--src/controllers/room.rs4
-rw-r--r--src/controllers/screening.rs2
-rw-r--r--src/db.rs16
-rw-r--r--src/lib.rs2
-rw-r--r--src/models.rs4
6 files changed, 18 insertions, 14 deletions
diff --git a/src/controllers/film.rs b/src/controllers/film.rs
index e61a543..827b3ab 100644
--- a/src/controllers/film.rs
+++ b/src/controllers/film.rs
@@ -18,7 +18,7 @@
use crate::{
db,
- models::film,
+ models,
};
use rocket::get;
@@ -27,6 +27,6 @@ use rocket_contrib::{
};
#[get("/")]
-pub fn get_films(db: db::Connection) -> Json<Vec<film::Film>> {
+pub fn get_films(db: db::Connection) -> Json<Vec<models::Film>> {
Json(db.get_films().unwrap())
}
diff --git a/src/controllers/room.rs b/src/controllers/room.rs
index a203454..419afae 100644
--- a/src/controllers/room.rs
+++ b/src/controllers/room.rs
@@ -18,7 +18,7 @@
use crate::{
db,
- models::room,
+ models,
};
use rocket::get;
@@ -27,6 +27,6 @@ use rocket_contrib::{
};
#[get("/")]
-pub fn get_rooms(db: db::Connection) -> Json<Vec<room::Room>> {
+pub fn get_rooms(db: db::Connection) -> Json<Vec<models::Room>> {
Json(db.get_rooms().unwrap())
}
diff --git a/src/controllers/screening.rs b/src/controllers/screening.rs
index 622e9cb..29b6afa 100644
--- a/src/controllers/screening.rs
+++ b/src/controllers/screening.rs
@@ -18,7 +18,7 @@
use crate::{
db,
- models::{screening::Screening, film::Film, room::Room},
+ models::{Film, Room, Screening},
};
use rocket::get;
diff --git a/src/db.rs b/src/db.rs
index 53c4ea4..d7a12b0 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -34,13 +34,13 @@ pub struct Connection(diesel::PgConnection);
impl Connection {
pub fn create_screening(
&self,
- room: &models::room::Room,
- film: &models::film::Film,
+ room: &models::Room,
+ film: &models::Film,
date: chrono::NaiveDate,
start_time: chrono::NaiveTime,
end_time: chrono::NaiveTime) -> QueryResult<usize>
{
- let s = models::screening::NewScreening {
+ let s = models::NewScreening {
room_id: room.id,
film_id: film.id,
date: date,
@@ -53,7 +53,7 @@ impl Connection {
.execute(&**self)
}
- pub fn get_screenings(&self) -> QueryResult<Vec<(models::screening::Screening, Option<models::film::Film>, Option<models::room::Room>)>> {
+ pub fn get_screenings(&self) -> QueryResult<Vec<(models::Screening, Option<models::Film>, Option<models::Room>)>> {
use crate::schema::screenings::dsl::*;
screenings
.left_join(films::table)
@@ -61,24 +61,24 @@ impl Connection {
.get_results(&**self)
}
- pub fn get_rooms(&self) -> QueryResult<Vec<models::room::Room>> {
+ pub fn get_rooms(&self) -> QueryResult<Vec<models::Room>> {
use crate::schema::rooms::dsl::*;
rooms.load(&**self)
}
- pub fn get_room_by_name(&self, room_name: &str) -> QueryResult<models::room::Room> {
+ pub fn get_room_by_name(&self, room_name: &str) -> QueryResult<models::Room> {
use crate::schema::rooms::dsl::*;
rooms
.filter(name.eq(&room_name))
.get_result(&**self)
}
- pub fn get_films(&self) -> QueryResult<Vec<models::film::Film>> {
+ pub fn get_films(&self) -> QueryResult<Vec<models::Film>> {
use crate::schema::films::dsl::*;
films.load(&**self)
}
- pub fn get_film_by_title(&self, film_title: &str) -> QueryResult<models::film::Film> {
+ pub fn get_film_by_title(&self, film_title: &str) -> QueryResult<models::Film> {
use crate::schema::films::dsl::*;
films
.filter(title.eq(&film_title))
diff --git a/src/lib.rs b/src/lib.rs
index 6554e7c..9ae797d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#![feature(proc_macro_hygiene, decl_macro)]
+#![feature(proc_macro_hygiene, decl_macro, uniform_paths)]
#[macro_use] extern crate diesel;
diff --git a/src/models.rs b/src/models.rs
index 40d910c..fc45d88 100644
--- a/src/models.rs
+++ b/src/models.rs
@@ -19,3 +19,7 @@
pub mod film;
pub mod room;
pub mod screening;
+
+pub use film::{Film, NewFilm};
+pub use room::Room;
+pub use screening::{NewScreening, Screening};