Allow editing blogs with custom_domain
n.b.: no validation yet
This commit is contained in:
parent
df47cddb87
commit
064dd79eef
@ -8,8 +8,9 @@ use openssl::{
|
|||||||
sign::{Signer, Verifier},
|
sign::{Signer, Verifier},
|
||||||
};
|
};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
http::RawStr,
|
||||||
outcome::IntoOutcome,
|
outcome::IntoOutcome,
|
||||||
request::{self, FromRequest, Request},
|
request::{self, FromFormValue, FromRequest, Request},
|
||||||
};
|
};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -71,6 +72,15 @@ impl<'a, 'r> FromRequest<'a, 'r> for Host {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'v> FromFormValue<'v> for Host {
|
||||||
|
type Error = &'v RawStr;
|
||||||
|
|
||||||
|
fn from_form_value(form_value: &'v RawStr) -> std::result::Result<Host, &'v RawStr> {
|
||||||
|
let val = String::from_form_value(form_value)?;
|
||||||
|
Ok(Host::new(&val))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, Clone, AsChangeset)]
|
#[derive(Queryable, Identifiable, Clone, AsChangeset)]
|
||||||
#[changeset_options(treat_none_as_null = "true")]
|
#[changeset_options(treat_none_as_null = "true")]
|
||||||
pub struct Blog {
|
pub struct Blog {
|
||||||
|
@ -333,6 +333,7 @@ pub struct EditForm {
|
|||||||
pub summary: String,
|
pub summary: String,
|
||||||
pub icon: Option<i32>,
|
pub icon: Option<i32>,
|
||||||
pub banner: Option<i32>,
|
pub banner: Option<i32>,
|
||||||
|
pub custom_domain: Option<Host>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/~/<name>/edit")]
|
#[get("/~/<name>/edit")]
|
||||||
@ -359,6 +360,7 @@ pub fn edit(name: String, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {
|
|||||||
summary: blog.summary.clone(),
|
summary: blog.summary.clone(),
|
||||||
icon: blog.icon_id,
|
icon: blog.icon_id,
|
||||||
banner: blog.banner_id,
|
banner: blog.banner_id,
|
||||||
|
custom_domain: blog.custom_domain.clone(),
|
||||||
},
|
},
|
||||||
ValidationErrors::default()
|
ValidationErrors::default()
|
||||||
)))
|
)))
|
||||||
|
Loading…
Reference in New Issue
Block a user