Instance about page

Fixes #39
This commit is contained in:
Bat
2018-09-01 17:39:40 +01:00
parent b66e8942a9
commit 092ad5b795
12 changed files with 207 additions and 9 deletions
+12
View File
@@ -72,6 +72,14 @@ impl Instance {
.len() > 0
}
pub fn main_admin(&self, conn: &PgConnection) -> User {
users::table.filter(users::instance_id.eq(self.id))
.filter(users::is_admin.eq(true))
.limit(1)
.get_result::<User>(conn)
.expect("Couldn't load admins")
}
pub fn compute_box(&self, prefix: &'static str, name: String, box_name: &'static str) -> String {
ap_url(format!(
"{instance}/{prefix}/{name}/{box_name}",
@@ -96,4 +104,8 @@ impl Instance {
)).get_result::<Instance>(conn)
.expect("Couldn't update instance")
}
pub fn count(conn: &PgConnection) -> i64 {
instances::table.count().get_result(conn).expect("Couldn't count instances")
}
}