Added Location and location ownership/rights to gamenight.

This commit is contained in:
2025-12-24 14:48:54 +01:00
parent 8a48119c80
commit ff88029a4b
57 changed files with 3034 additions and 995 deletions
@@ -1,11 +1,13 @@
use diesel::{BoolExpressionMethods, ExpressionMethods, Insertable, QueryDsl, Queryable, RunQueryDsl};
use serde::{Serialize, Deserialize};
use diesel::{
BoolExpressionMethods, ExpressionMethods, Insertable, QueryDsl, Queryable, RunQueryDsl,
};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::schema::gamenight_participant;
use super::error::DatabaseError;
use super::DbConnection;
use super::error::DatabaseError;
#[derive(Serialize, Deserialize, Debug, Insertable, Queryable)]
#[diesel(belongs_to(Gamenight))]
@@ -23,14 +25,23 @@ pub fn get_participants(conn: &mut DbConnection, id: &Uuid) -> Result<Vec<Uuid>,
.get_results(conn)?)
}
pub fn insert_gamenight_participant(conn: &mut DbConnection, gp: GamenightParticipant) -> Result<usize, DatabaseError> {
pub fn insert_gamenight_participant(
conn: &mut DbConnection,
gp: GamenightParticipant,
) -> Result<usize, DatabaseError> {
Ok(gp.insert_into(gamenight_participant::table).execute(conn)?)
}
pub fn delete_gamenight_participant(conn: &mut DbConnection, gp: GamenightParticipant) -> Result<usize, DatabaseError> {
Ok(diesel::delete(gamenight_participant::table
.filter(gamenight_participant::gamenight_id.eq(&gp.gamenight_id)
.and(gamenight_participant::user_id.eq(gp.user_id))))
.execute(conn)?)
}
pub fn delete_gamenight_participant(
conn: &mut DbConnection,
gp: GamenightParticipant,
) -> Result<usize, DatabaseError> {
Ok(diesel::delete(
gamenight_participant::table.filter(
gamenight_participant::gamenight_id
.eq(&gp.gamenight_id)
.and(gamenight_participant::user_id.eq(gp.user_id)),
),
)
.execute(conn)?)
}