Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "Admin" role to "Host" to be consistent with design decisions #15

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ argon2 = { version = "0.5.3", features = ["password-hash"] }
async-tempfile = "0.6.0"
axum-extra = { version = "0.10.0", features = ["typed-header"] }
axum = { version = "0.8.1", features = ["macros", "ws"] }
bedrock = { git = "https://github.com/basalt-rs/bedrock.git", rev = "4257d82", features = ["tokio"] }
bedrock = { git = "https://github.com/basalt-rs/bedrock.git", rev = "52ff607", features = ["tokio"] }
clap = { version = "4.5.23", features = ["derive"] }
dashmap = "6.1.0"
derive_more = { version = "2.0.1", features = ["debug", "from", "deref"] }
Expand Down
8 changes: 4 additions & 4 deletions src/repositories/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ use crate::storage::SqliteLayer;
#[serde(rename_all = "kebab-case")]
pub enum Role {
Competitor = 0,
Admin = 1,
Host = 1,
}

impl From<i32> for Role {
fn from(value: i32) -> Self {
match value {
1 => Role::Admin,
1 => Role::Host,
_ => Role::Competitor,
}
}
Expand All @@ -30,7 +30,7 @@ impl From<i32> for Role {
impl From<i64> for Role {
fn from(value: i64) -> Self {
match value {
1 => Role::Admin,
1 => Role::Host,
_ => Role::Competitor,
}
}
Expand All @@ -40,7 +40,7 @@ impl From<Role> for i32 {
fn from(value: Role) -> Self {
match value {
Role::Competitor => 0,
Role::Admin => 1,
Role::Host => 1,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/services/questions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::server::AppState;
use axum::{extract::State, Json};
use bedrock::packet::{Problem, Test};
use std::collections::BTreeSet;
use std::ops::Deref;
use std::sync::Arc;
use std::{collections::HashSet, ops::Deref};
use utoipa_axum::{router::OpenApiRouter, routes};

#[derive(serde::Serialize, utoipa::ToSchema)]
Expand All @@ -22,7 +23,7 @@ impl From<&Test> for TestResponse {

#[derive(serde::Serialize, utoipa::ToSchema)]
pub struct QuestionResponse {
languages: Option<HashSet<String>>,
languages: Option<BTreeSet<String>>,
title: String,
description: Option<String>,
tests: Vec<TestResponse>,
Expand Down
6 changes: 3 additions & 3 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ impl SqliteLayer {
.context("Failed to create user")?;
}

for admin in &cfg.accounts.admins {
create_user(&mut *tx, &admin.name, &admin.password, Role::Admin)
for host in &cfg.accounts.hosts {
create_user(&mut *tx, &host.name, &host.password, Role::Host)
.await
.context("Failed to create admin user")?;
.context("Failed to create host user")?;
}

tx.commit()
Expand Down
2 changes: 1 addition & 1 deletion tests/single.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trim_output = true
max_memory = { compile = 128, run = 64 }
max_file_size = 8192

[[accounts.admins]]
[[accounts.hosts]]
name = "Teacher"
password = "abc123"

Expand Down