Fix #701 Preferable default theme #746

Apvienots
KitaitiMakoto Iekļāva 3 iesūtījumus no preferred-default-theme zarā master 2020-04-12 15:36:01 +00:00
KitaitiMakoto pievienoja piebildi 2020-04-12 01:08:13 +00:00 (Pārcelta no github.com)

This patch fixes #701 .

The issue occurs because form value of email is empty string "" when user selects "Default theme" and it is set as preferred theme name. There's no theme named "", so any theme is not applied. By setting NULL to users.preferred_theme when "Default theme" is selected, instance theme is used as the user's preferred theme.

I used Diesel's #[changeset_options(treat_none_as_null="true")] attribute on User model. This may not be preferred but save_changes doesn't have option to set NULL sometimes and keep current value otherwise(See http://diesel.rs/guides/all-about-updates/ . It says "Diesel doesn't currently provide a way to explicitly assign a field to its default value"). This is the reason why I used that attribute, but it may have too wide inpact. Could you consider?

This patch fixes #701 . The issue occurs because form value of `email` is empty string `""` when user selects "Default theme" and it is set as preferred theme name. There's no theme named `""`, so any theme is not applied. By setting `NULL` to `users.preferred_theme` when "Default theme" is selected, instance theme is used as the user's preferred theme. I used Diesel's `#[changeset_options(treat_none_as_null="true")]` attribute on `User` model. This may not be preferred but `save_changes` doesn't have option to set `NULL` sometimes and keep current value otherwise(See http://diesel.rs/guides/all-about-updates/ . It says "Diesel doesn't currently provide a way to explicitly assign a field to its default value"). This is the reason why I used that attribute, but it may have too wide inpact. Could you consider?
codecov[bot] pievienoja piebildi 2020-04-12 01:52:19 +00:00 (Pārcelta no github.com)

Codecov Report

Merging #746 into master will not change coverage by %.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master     #746   +/-   ##
=======================================
  Coverage   39.00%   39.00%           
=======================================
  Files          73       73           
  Lines        9699     9699           
  Branches     2229     2229           
=======================================
  Hits         3783     3783           
- Misses       4754     4787   +33     
+ Partials     1162     1129   -33     
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/746?src=pr&el=h1) Report > Merging [#746](https://codecov.io/gh/Plume-org/Plume/pull/746?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/506fe9955dbda055f70655c8e862c77678e9c567&el=desc) will **not change** coverage by `%`. > The diff coverage is `0.00%`. ```diff @@ Coverage Diff @@ ## master #746 +/- ## ======================================= Coverage 39.00% 39.00% ======================================= Files 73 73 Lines 9699 9699 Branches 2229 2229 ======================================= Hits 3783 3783 - Misses 4754 4787 +33 + Partials 1162 1129 -33 ```
elegaanz (Pārcelta no github.com) izskatīja 2020-04-12 15:35:27 +00:00
elegaanz (Pārcelta no github.com) pievienoja piebildi

I did a quick check to see if it could impact something else, but it looks like it is safe. Thanks for contributing!

I did a quick check to see if it could impact something else, but it looks like it is safe. Thanks for contributing!
elegaanz (Pārcelta no github.com) apstiprināja šīs izmaiņas 2020-04-12 15:35:55 +00:00
elegaanz (Pārcelta no github.com) pievienoja piebildi

Woops, forgot to approve

Woops, forgot to approve
KitaitiMakoto pievienoja piebildi 2020-04-12 15:43:43 +00:00 (Pārcelta no github.com)

Thank you for merging!

Thank you for merging!
verymilan pievienoja piebildi 2020-06-21 20:49:15 +00:00 (Pārcelta no github.com)

Sadly a new user of mine still just ran into missing CSS on 0.5.0 :(

Sadly a new user of mine still just ran into missing CSS on 0.5.0 :(
KitaitiMakoto pievienoja piebildi 2020-06-21 23:59:59 +00:00 (Pārcelta no github.com)

@verymilan Can you re-save configuration again, please?

@verymilan Can you re-save configuration again, please?
verymilan pievienoja piebildi 2020-06-22 06:47:05 +00:00 (Pārcelta no github.com)

I am not sure what you mean, but as usual, i have made them selecting a theme and save, which was fixing their issue as always

I am not sure what you mean, but as usual, i have made them selecting a theme and save, which was fixing their issue as always
KitaitiMakoto pievienoja piebildi 2020-06-22 07:14:33 +00:00 (Pārcelta no github.com)

Sorry for my poor English. What I did mean is...

Can you have your users select "Default theme" and save it? It might be fix the issue?

Under the hood, their current theme is saved as empty string "" but re-saving theme makes it NULL. And then default theme is applied.

Sorry for my poor English. What I did mean is... Can you have your users select "Default theme" and save it? It might be fix the issue? Under the hood, their current theme is saved as empty string `""` but re-saving theme makes it `NULL`. And then default theme is applied.
verymilan pievienoja piebildi 2020-06-22 07:26:58 +00:00 (Pārcelta no github.com)

Yes, i know, and this is how we did it - i was just expecting assuming that this workaround wasn't needed anymore.

Yes, i know, and this is how we did it - i was just ~expecting~ assuming that this workaround wasn't needed anymore.
KitaitiMakoto pievienoja piebildi 2020-06-22 07:42:09 +00:00 (Pārcelta no github.com)

Ah, sorry, I missed your point.

i was just expecting assuming that this workaround wasn't needed anymore.

Yes, your realization is correct.

Ah, sorry, I missed your point. > i was just ~expecting~ assuming that this workaround wasn't needed anymore. Yes, your realization is correct.
Nepieciešams pieteikties, lai pievienotos šai sarunai.
Nav izskatītāju
Nav atskaites punkta
Nav projektu
Nav atbildīgo
1 dalībnieks
Paziņojumi
Izpildes datums
Izpildes datums nav derīgs vai tas ir ārpus datumu apgabala. Lūgums izmantot pierakstu "gggg-mm-dd".

Nav uzstādīts izpildes datums.

Atkarības

Nav atkarību.

Atsauce: Plume/Plume#746
Nav sniegts apraksts.