Moderation + Mod Editing (#101)

* Moderation + Mod Editing WIP

* Run prepare, fix perms

* Make it compile

* Finish moderation and edit routes

* More fixes

* Use better queries

* Final Fixes
This commit is contained in:
Geometrically
2020-11-15 19:58:11 -07:00
committed by GitHub
parent da911bfeb8
commit 0500994def
14 changed files with 1830 additions and 332 deletions

View File

@@ -58,7 +58,7 @@ pub struct Mod {
/// Draft - Mod is not displayed on search, and not accessible by URL
/// Unlisted - Mod is not displayed on search, but accessible by URL
/// Processing - Mod is not displayed on search, and not accessible by URL (Temporary state, mod under review)
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ModStatus {
Approved,
@@ -103,6 +103,24 @@ impl ModStatus {
ModStatus::Unknown => "unknown",
}
}
pub fn is_hidden(&self) -> bool {
match self {
ModStatus::Approved => false,
ModStatus::Rejected => true,
ModStatus::Draft => true,
ModStatus::Unlisted => false,
ModStatus::Processing => true,
ModStatus::Unknown => true,
}
}
pub fn is_searchable(&self) -> bool {
match self {
ModStatus::Approved => true,
_ => false,
}
}
}
/// A specific version of a mod

View File

@@ -45,4 +45,11 @@ impl Role {
_ => Role::Developer,
}
}
pub fn is_mod(&self) -> bool {
match self {
Role::Developer => false,
Role::Moderator | Role::Admin => true,
}
}
}