mirror of https://github.com/raftario/filite.git
Removed highlight field for tets
This commit is contained in:
parent
e60e3d625f
commit
2888af37e4
|
@ -1,6 +1,5 @@
|
|||
CREATE TABLE texts (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
contents TEXT NOT NULL,
|
||||
highlight INTEGER NOT NULL,
|
||||
created INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||
);
|
||||
|
|
|
@ -63,8 +63,6 @@ pub mod texts {
|
|||
pub id: i32,
|
||||
/// Text contents
|
||||
pub contents: String,
|
||||
/// Whether to use syntax highlighting or not when serving that text
|
||||
pub highlight: i32,
|
||||
/// Creation date and time as a UNIX timestamp
|
||||
pub created: i32,
|
||||
}
|
||||
|
@ -77,7 +75,5 @@ pub mod texts {
|
|||
pub id: i32,
|
||||
/// Text contents
|
||||
pub contents: &'a str,
|
||||
/// Whether to use syntax highlighting or not when serving that text
|
||||
pub highlight: i32,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,20 +174,11 @@ pub mod texts {
|
|||
find!(texts, Text);
|
||||
|
||||
/// REPLACE a text entry
|
||||
pub fn replace(
|
||||
r_id: i32,
|
||||
r_contents: &str,
|
||||
r_highlight: bool,
|
||||
pool: Data<Pool>,
|
||||
) -> QueryResult<Text> {
|
||||
pub fn replace(r_id: i32, r_contents: &str, pool: Data<Pool>) -> QueryResult<Text> {
|
||||
let conn: &SqliteConnection = &pool.get().unwrap();
|
||||
let new_text = NewText {
|
||||
id: r_id,
|
||||
contents: r_contents,
|
||||
highlight: match r_highlight {
|
||||
true => 1,
|
||||
false => 2,
|
||||
},
|
||||
};
|
||||
diesel::replace_into(table)
|
||||
.values(&new_text)
|
||||
|
|
|
@ -461,7 +461,6 @@ pub mod texts {
|
|||
#[derive(Deserialize)]
|
||||
pub struct PutText {
|
||||
pub contents: String,
|
||||
pub highlight: bool,
|
||||
}
|
||||
|
||||
/// PUT a new text entry
|
||||
|
@ -476,10 +475,8 @@ pub mod texts {
|
|||
future::result(auth(identity, request, &token_hash))
|
||||
.and_then(move |_| future::result(parse_id(&path)))
|
||||
.and_then(move |id| {
|
||||
web::block(move || {
|
||||
queries::texts::replace(id, &body.contents, body.highlight, pool)
|
||||
})
|
||||
.then(|result| match_replace_result(result))
|
||||
web::block(move || queries::texts::replace(id, &body.contents, pool))
|
||||
.then(|result| match_replace_result(result))
|
||||
})
|
||||
.from_err()
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ table! {
|
|||
texts (id) {
|
||||
id -> Integer,
|
||||
contents -> Text,
|
||||
highlight -> Integer,
|
||||
created -> Integer,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue