Skip to content

Commit

Permalink
Adding a setting to show / hide scores. Fixes #1503
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Mar 31, 2021
1 parent 1a3a215 commit 2f63fdb
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/api/src/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ impl Perform for SaveUserSettings {
email,
password_encrypted,
show_nsfw: data.show_nsfw,
show_scores: data.show_scores,
theme: data.theme.to_owned(),
default_sort_type,
default_listing_type,
Expand Down
3 changes: 2 additions & 1 deletion crates/api_common/src/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub struct CaptchaResponse {
#[derive(Deserialize)]
pub struct SaveUserSettings {
pub show_nsfw: Option<bool>,
pub show_scores: Option<bool>,
pub show_avatars: Option<bool>,
pub theme: Option<String>,
pub default_sort_type: Option<i16>,
pub default_listing_type: Option<i16>,
Expand All @@ -60,7 +62,6 @@ pub struct SaveUserSettings {
pub new_password: Option<String>,
pub new_password_verify: Option<String>,
pub old_password: Option<String>,
pub show_avatars: Option<bool>,
pub send_notifications_to_email: Option<bool>,
pub auth: String,
}
Expand Down
1 change: 1 addition & 0 deletions crates/api_crud/src/user/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl PerformCrud for Register {
default_listing_type: Some(ListingType::Subscribed as i16),
lang: Some("browser".into()),
show_avatars: Some(true),
show_scores: Some(true),
send_notifications_to_email: Some(false),
};

Expand Down
2 changes: 2 additions & 0 deletions crates/db_queries/src/source/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod safe_settings_type {
show_avatars,
send_notifications_to_email,
validator_time,
show_scores,
);

impl ToSafeSettings for LocalUser {
Expand All @@ -43,6 +44,7 @@ mod safe_settings_type {
show_avatars,
send_notifications_to_email,
validator_time,
show_scores,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ table! {
show_avatars -> Bool,
send_notifications_to_email -> Bool,
validator_time -> Timestamp,
show_scores -> Bool,
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/source/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct LocalUser {
pub show_avatars: bool,
pub send_notifications_to_email: bool,
pub validator_time: chrono::NaiveDateTime,
pub show_scores: bool,
}

// TODO redo these, check table defaults
Expand All @@ -32,6 +33,7 @@ pub struct LocalUserForm {
pub lang: Option<String>,
pub show_avatars: Option<bool>,
pub send_notifications_to_email: Option<bool>,
pub show_scores: Option<bool>,
}

/// A local user view that removes password encrypted
Expand All @@ -49,4 +51,5 @@ pub struct LocalUserSettings {
pub show_avatars: bool,
pub send_notifications_to_email: bool,
pub validator_time: chrono::NaiveDateTime,
pub show_scores: bool,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_user drop column show_scores;
1 change: 1 addition & 0 deletions migrations/2021-03-31-103917_add_show_score_setting/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_user add column show_scores boolean default true not null;

0 comments on commit 2f63fdb

Please sign in to comment.