Skip to content

Commit

Permalink
Preselect more fields when creating new user
Browse files Browse the repository at this point in the history
- use default language from config to preselect language of new user
- add config option "profile_data_public_by_default"; if enabled, the privacy options ("phone/email/name is public") will be pre-checked when creating a new user
  • Loading branch information
twothreenine authored and yksflip committed Jul 4, 2024
1 parent ad05870 commit da1e191
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ def ordergroup

before_validation :set_password
after_initialize do
settings.defaults['profile'] = { 'language' => I18n.default_locale } unless settings.profile
settings.defaults['messages'] = { 'send_as_email' => true } unless settings.messages
unless settings.profile
settings.defaults['profile'] = { 'language' => FoodsoftConfig[:default_locale] || I18n.default_locale } unless settings.profile
if FoodsoftConfig[:profile_data_public_by_default]
settings.defaults['profile']['phone_is_public'] = true
settings.defaults['profile']['email_is_public'] = true
settings.defaults['profile']['name_is_public'] = true
end
end
settings.defaults['messages'] = { 'send_as_email' => true } unless settings.messages
settings.defaults['notify'] = { 'upcoming_tasks' => true } unless settings.notify
end

Expand Down
1 change: 1 addition & 0 deletions app/views/admin/configs/_tab_others.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
= config_input form, :use_nick, as: :boolean
= config_input form, :profile_data_public_by_default, as: :boolean
= config_input form, :tolerance_is_costly, as: :boolean
- distribution_strategy_options = FoodsoftConfig::DistributionStrategy.constants.map { |c| FoodsoftConfig::DistributionStrategy.const_get(c) }
= config_input form, :distribution_strategy, as: :select, collection: distribution_strategy_options,
Expand Down
2 changes: 2 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ de:
use_iban: Zusätzlich Feld für die internationale Kontonummer bei Benutzern und Lieferanten anzeigen
use_financial_links: Wenn aktiviert, werden Optionen zum Anlegen von Finanzlinks angezeigt, die zusammenhängende Kontotransaktionen, Rechnungen und Banktransaktionen gruppieren können. Außerdem werden Optionen zum Anlegen von Foodcoop-Transaktionen angezeigt (Transaktionen, die keiner Bestellgruppe zugeordnet sind, sondern als Ausgleichsbuchungen zwecks doppelter Buchführung dienen).
use_nick: Benutzernamen anstatt reale Namen zeigen und verwenden, jeder Benutzer muss dazu einen Benutzernamen (Spitznamen) haben.
profile_data_public_by_default: Beim Anlegen einer neuen Benutzer:in werden bei den Privatsphäre-Optionen "Telefon/E-Mail/Name ist für Mitglieder sichtbar" standardmäßig Haken gesetzt. Wenn Benutzernamen deaktiviert sind, sind Namen immer für alle sichtbar.
use_self_service: Wenn aktiviert, können Benutzer_innen selbständig dafür freigegebene Abrechungsfunktionen nutzen.
webstats_tracking_code: Tracking Code für Webseitenanalyse (wie Piwik oder Google Analytics), leer lassen wenn keine Analyse erfolgt
keys:
Expand Down Expand Up @@ -694,6 +695,7 @@ de:
use_iban: IBAN verwenden
use_financial_links: Finanzlinks & Foodcoop-Transaktionen verwenden
use_nick: Benutzernamen verwenden
profile_data_public_by_default: Profildaten standardmäßig für andere sichtbar
use_self_service: Selbstbedienung verwenden
webstats_tracking_code: Code für Websiteanalysetool
tabs:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ en:
use_iban: When enabled, supplier and user provide an additonal field for storing the international bank account number.
use_financial_links: When enabled, options to create financial links will be shown, which can group associated financial transactions, invoices, and bank transactions. Also, options to create foodcoop transactions will be shown (transactions which aren't assigned to any ordergroup, but serve as balancing entries for double-entry accounting.)
use_nick: Show and use nicknames instead of real names. When enabling this, please check that each user has a nickname.
profile_data_public_by_default: When creating a new user, the pricacy options "Phone number / Email / Name is visible for other members" will be checked by default. If nicknames are disabled, name will be visible either way.
use_self_service: When enabled, members are able to use selected balancing functions on their own.
webstats_tracking_code: Tracking code for web analytics (like Piwik or Google analytics). Leave empty for no tracking.
keys:
Expand Down Expand Up @@ -694,6 +695,7 @@ en:
use_iban: Use IBAN
use_financial_links: Use financial links & foodcoop transactions
use_nick: Use nicknames
profile_data_public_by_default: Profile data visible to others by default
use_self_service: Use self service
webstats_tracking_code: Tracking code
tabs:
Expand Down

0 comments on commit da1e191

Please sign in to comment.