Skip to content

Commit

Permalink
adjust permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDavenport committed Apr 16, 2024
1 parent 195a968 commit 15b1f19
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 14 deletions.
8 changes: 3 additions & 5 deletions gamercade_app/src/local_directory/permission_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ pub struct PermissionLevelId(pub usize);
#[derive(Default, Debug)]
pub struct PermissionLevel {
pub name: String,
pub strength: i32,
}

impl From<&rusqlite::Row<'_>> for PermissionLevel {
fn from(value: &rusqlite::Row<'_>) -> Self {
Self {
name: value.get_unwrap(1),
strength: value.get_unwrap(2),
}
}
}
Expand All @@ -34,23 +32,23 @@ impl DictionaryTrait<PermissionLevelId, PermissionLevel>
}

fn upsert_table_query() -> &'static str {
"CREATE TABLE IF NOT EXISTS permission_levels(id INTEGER PRIMARY KEY, level_name TEXT NOT NULL, strength INTEGER NOT NULL) STRICT;"
"CREATE TABLE IF NOT EXISTS permission_levels(id INTEGER PRIMARY KEY, level_name TEXT NOT NULL) STRICT;"
}

fn drop_table_query() -> &'static str {
"DROP TABLE IF EXISTS permission_levels;"
}

fn insert_query() -> &'static str {
"INSERT INTO permission_levels(id, level_name, strength) VALUES (?, ?, ?)"
"INSERT INTO permission_levels(id, level_name) VALUES (?, ?)"
}

fn insert_statement(
statement: &mut rusqlite::Statement,
(key, value): &(PermissionLevelId, PermissionLevel),
) {
statement
.execute((key.0 as i32, value.name.clone(), value.strength))
.execute((key.0 as i32, value.name.clone()))
.unwrap();
}
}
7 changes: 3 additions & 4 deletions gamercade_app/src/task_manager/authors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ impl TaskRequest<AuthorManagerState> for AuthorRequest {
let levels = response
.levels
.drain(..)
.map(|tag| {
.map(|level| {
(
PermissionLevelId(tag.level_id as usize),
PermissionLevelId(level.id as usize),
PermissionLevel {
name: tag.level_name,
strength: tag.level_strength as i32,
name: level.level_name,
},
)
})
Expand Down
3 changes: 1 addition & 2 deletions gamercade_interface/proto/author.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ message GlobalPermissionLevels {
}

message PermissionLevel {
int32 level_id = 1;
int32 id = 1;
string level_name = 2;
int32 level_strength = 3;
}
1 change: 1 addition & 0 deletions gamercade_interface/src/output/auth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SignUpRequest {
Expand Down
5 changes: 2 additions & 3 deletions gamercade_interface/src/output/author.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AdjustAuthorRequest {
Expand Down Expand Up @@ -38,11 +39,9 @@ pub struct GlobalPermissionLevels {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PermissionLevel {
#[prost(int32, tag = "1")]
pub level_id: i32,
pub id: i32,
#[prost(string, tag = "2")]
pub level_name: ::prost::alloc::string::String,
#[prost(int32, tag = "3")]
pub level_strength: i32,
}
/// Generated client implementations.
pub mod author_service_client {
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/chat.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChatChannel {
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Empty {}
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/game.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateGameRequest {
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
pub mod auth {
include!("auth.rs");
}
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/release.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateReleaseRequest {
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/tag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AdjustGameTagRequest {
Expand Down
1 change: 1 addition & 0 deletions gamercade_interface/src/output/users.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UserRequest {
Expand Down

0 comments on commit 15b1f19

Please sign in to comment.