Skip to content

Commit

Permalink
Fix #701 Preferable default theme (#746)
Browse files Browse the repository at this point in the history
* Make it possible to update users.preferred_theme to NULL

* Make preferred them null when 'Default theme' is selected

* Run cargo fmt
  • Loading branch information
KitaitiMakoto authored Apr 12, 2020
1 parent 506fe99 commit b834d1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions plume-models/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub enum Role {
}

#[derive(Queryable, Identifiable, Clone, Debug, AsChangeset)]
#[changeset_options(treat_none_as_null = "true")]
pub struct User {
pub id: i32,
pub username: String,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ pub fn update(
)
.0,
);
user.preferred_theme = form.theme.clone();
user.preferred_theme = form
.theme
.clone()
.and_then(|t| if &t == "" { None } else { Some(t) });
user.hide_custom_css = form.hide_custom_css;
let _: User = user.save_changes(&*conn).map_err(Error::from)?;

Expand Down

0 comments on commit b834d1c

Please sign in to comment.