mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
Finish the user settings jsonb, also fix references throughout app
Closes SCI-1475.
This commit is contained in:
parent
c62002381b
commit
9227ea5854
|
@ -180,7 +180,7 @@ module Users
|
|||
message: sanitize_input(message)
|
||||
)
|
||||
|
||||
if target_user.assignments_notification
|
||||
if target_user.settings[:notifications][:assignments]
|
||||
UserNotification.create(notification: notification, user: target_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,15 +77,15 @@ module Users
|
|||
end
|
||||
|
||||
def notifications_settings
|
||||
@user.assignments_notification =
|
||||
@user.settings[:notifications][:assignments] =
|
||||
params[:assignments_notification] ? true : false
|
||||
@user.recent_notification =
|
||||
@user.settings[:notifications][:recent] =
|
||||
params[:recent_notification] ? true : false
|
||||
@user.recent_notification_email =
|
||||
@user.settings[:notifications][:recent_email] =
|
||||
params[:recent_notification_email] ? true : false
|
||||
@user.assignments_notification_email =
|
||||
@user.settings[:notifications][:assignments_email] =
|
||||
params[:assignments_notification_email] ? true : false
|
||||
@user.system_message_notification_email =
|
||||
@user.settings[:notifications][:system_message_email] =
|
||||
params[:system_message_notification_email] ? true : false
|
||||
|
||||
if @user.save
|
||||
|
@ -115,7 +115,7 @@ module Users
|
|||
|
||||
def update_params
|
||||
params.require(:user).permit(
|
||||
settings: :time_zone
|
||||
:time_zone
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -100,7 +100,7 @@ module ApplicationHelper
|
|||
title: sanitize_input(title),
|
||||
message: sanitize_input(message)
|
||||
)
|
||||
if target_user.assignments_notification
|
||||
if target_user.settings[:notifications][:assignments]
|
||||
UserNotification.create(notification: notification, user: target_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ module NotificationsHelper
|
|||
message: sanitize_input(message)
|
||||
)
|
||||
|
||||
if target_user.assignments_notification
|
||||
if target_user.settings[:notifications][:assignments]
|
||||
UserNotification.create(notification: notification, user: target_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -118,9 +118,9 @@ class Activity < ApplicationRecord
|
|||
|
||||
project.users.each do |project_user|
|
||||
next if project_user == user
|
||||
next if !project_user.assignments_notification &&
|
||||
next if !project_user.settings[:notifications][:assignments] &&
|
||||
notification.type_of == 'assignment'
|
||||
next if !project_user.recent_notification &&
|
||||
next if !project_user.settings[:notifications][:recent] &&
|
||||
notification.type_of == 'recent_changes'
|
||||
UserNotification.create(notification: notification, user: project_user)
|
||||
end
|
||||
|
|
|
@ -36,6 +36,8 @@ class User < ApplicationRecord
|
|||
size: { less_than: Constants::AVATAR_MAX_SIZE_MB.megabytes }
|
||||
validate :time_zone_check
|
||||
|
||||
store_accessor :settings, :time_zone
|
||||
|
||||
default_settings(
|
||||
time_zone: 'UTC',
|
||||
notifications: {
|
||||
|
|
|
@ -40,17 +40,17 @@ class UserNotification < ApplicationRecord
|
|||
send_email_notification(
|
||||
user,
|
||||
notification
|
||||
) if user.system_message_notification_email
|
||||
) if user.settings[:notifications][:system_message_email]
|
||||
when 'assignment'
|
||||
send_email_notification(
|
||||
user,
|
||||
notification
|
||||
) if user.assignments_notification_email
|
||||
) if user.settings[:notifications][:assignments_email]
|
||||
when 'recent_changes'
|
||||
send_email_notification(
|
||||
user,
|
||||
notification
|
||||
) if user.recent_notification_email
|
||||
) if user.settings[:notifications][:recent_email]
|
||||
when 'deliver'
|
||||
send_email_notification(
|
||||
user,
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
<%= form_for(@user,
|
||||
url: update_preferences_path(format: :json),
|
||||
remote: true,
|
||||
html: { method: :put, 'data-for' => 'settings[time_zone]' }) do |f| %>
|
||||
html: {
|
||||
method: :put,
|
||||
'data-for' => 'settings[time_zone]',
|
||||
'data-turbolinks' => false
|
||||
}) do |f| %>
|
||||
<div data-part="view">
|
||||
<div class="form-group">
|
||||
<%= f.label t("users.settings.account.preferences.edit.time_zone_label") %>
|
||||
|
@ -35,7 +39,7 @@
|
|||
<div class="well">
|
||||
<h4><%=t "users.settings.account.preferences.edit.time_zone_title" %></h4>
|
||||
<div class="form-group" style="max-width: 500px;">
|
||||
<%= f.select :time_zone, ActiveSupport::TimeZone.all.collect { |tz|
|
||||
<%= f.select :time_zone , ActiveSupport::TimeZone.all.collect { |tz|
|
||||
[tz.formatted_offset + " " + tz.name, tz.name]
|
||||
}, {}, {class: 'form-control selectpicker', 'ata-role' => 'clear'} %>
|
||||
<small><%= t("users.settings.account.preferences.edit.time_zone_sublabel") %></small>
|
||||
|
@ -75,7 +79,7 @@
|
|||
<%=t 'notifications.form.notification_scinote' %>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<%= check_box_tag :assignments_notification, @user.assignments_notification %>
|
||||
<%= check_box_tag :assignments_notification, @user.settings[:notifications][:assignments] %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -83,7 +87,7 @@
|
|||
<%=t 'notifications.form.notification_email' %>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<%= check_box_tag :assignments_notification_email, @user.assignments_notification_email %>
|
||||
<%= check_box_tag :assignments_notification_email, @user.settings[:notifications][:assignments_email] %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -100,7 +104,7 @@
|
|||
<%=t 'notifications.form.notification_scinote' %>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<%= check_box_tag :recent_notification, @user.recent_notification %>
|
||||
<%= check_box_tag :recent_notification, @user.settings[:notifications][:recent] %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -108,7 +112,7 @@
|
|||
<%=t 'notifications.form.notification_email' %>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<%= check_box_tag :recent_notification_email, @user.recent_notification_email %>
|
||||
<%= check_box_tag :recent_notification_email, @user.settings[:notifications][:recent_email] %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -133,7 +137,7 @@
|
|||
<%=t 'notifications.form.notification_email' %>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<%= check_box_tag :system_message_notification_email, @user.system_message_notification_email %>
|
||||
<%= check_box_tag :system_message_notification_email, @user.settings[:notifications][:system_message_email] %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue