Skip to content

Commit 879bbf0

Browse files
authored
Merge pull request #356 from coopdevs/feature/adds-user-push-notification-attribute
Added push notifications setting
2 parents 25791a7 + 6bed3f2 commit 879bbf0

File tree

10 files changed

+34
-30
lines changed

10 files changed

+34
-30
lines changed

app/assets/stylesheets/application.css.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,6 @@ label[required]::after{
361361
}
362362
}
363363

364-
form .checkbox input[type="checkbox"] {
365-
margin-left: 5px;
366-
position: relative;
367-
}
368-
369364
.back-overlay {
370365
background-color: $black;
371366
background-size: cover;

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def scoped_users
7070

7171
def user_params
7272
fields_to_permit = %w"gender username email date_of_birth phone
73-
alt_phone active description notifications"
73+
alt_phone active description notifications push_notifications"
7474
fields_to_permit += %w"admin registration_number
7575
registration_date" if admin?
7676
fields_to_permit += %w"organization_id superadmin" if superadmin?

app/views/users/_form.html.erb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<%= simple_form_for @user do |f| %>
33
<div class="form-inputs">
44
<%= f.input :username %>
5+
56
<% if admin? %>
67
<%= f.input :email %>
78
<% if @user.unconfirmed_email.present? %>
@@ -10,24 +11,29 @@
1011
<% else %>
1112
<%= f.input :email, readonly: true %>
1213
<% end %>
13-
<%# if current_user.try :superadmin? %>
14-
<%#= f.association :organization, include_blank: false %>
15-
<%#= f.input :superadmin, as: :boolean, label: false, inline_label: true %>
16-
<%# end %>
17-
<%# if current_user.try :admin? %>
18-
<%#= f.input :admin, as: :boolean, label: false, inline_label: true, hint: t(".admin_warning") %>
19-
<%# end %>
14+
2015
<%= f.input :phone %>
2116
<%= f.input :alt_phone %>
2217
<%= f.input :date_of_birth,
2318
start_year: Date.today.year - 90,
2419
end_year: Date.today.year - 12,
2520
include_blank: :true %>
2621
<%= f.input :description, as: "text" %>
27-
<%#= f.association :categories, label_method: :fqn, input_html: {style: 'width: 100%'} %>
28-
<div class="checkbox">
29-
<%= f.label :notifications %>
30-
<%= f.check_box :notifications %>
22+
23+
<div class='form-group'>
24+
<label><%= t('.notifications') %></label>
25+
<div class="checkbox">
26+
<%= f.label :notifications do %>
27+
<%= f.check_box :notifications %>
28+
<%= t('activerecord.attributes.user.notifications') %>
29+
<% end %>
30+
</div>
31+
<div class="checkbox">
32+
<%= f.label :push_notifications do %>
33+
<%= f.check_box :push_notifications %>
34+
<%= t('activerecord.attributes.user.push_notifications') %>
35+
<% end %>
36+
</div>
3137
</div>
3238
</div>
3339
<div class="form-actions">

config/locales/ca.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ ca:
494494
edit:
495495
edit_user: Canviar usuari
496496
form:
497-
admin_warning: Atenció!!! Estàs atorgant poders a aquest usuari!!
498-
superadmin_warning: Atenció!!! Estàs atorgant PODERS DIVINS a aquest usuari!!
497+
notifications: Notificacions
499498
give_time:
500499
give_time: Donar Temps a
501500
index:

config/locales/en.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ en:
6464
gender: Gender
6565
identity_document: Identity Document
6666
last_sign_in_at: Last login
67-
notifications: Receive notifications
67+
notifications: Receive email notifications
68+
push_notifications: Receive mobile notifications
6869
organization: Organization
6970
phone: Phone
7071
registration_date: Registration date
@@ -494,8 +495,7 @@ en:
494495
edit:
495496
edit_user: Update user
496497
form:
497-
admin_warning: Warning!!! You are giving privileges to this user!!
498-
superadmin_warning: Warning!!! You are giving GOD PRIVILEGES to this user!!
498+
notifications: Notifications
499499
give_time:
500500
give_time: Give time to
501501
index:

config/locales/es.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ es:
6464
gender: Género
6565
identity_document: DNI
6666
last_sign_in_at: Fecha último login
67-
notifications: Recibir notificaciones
67+
notifications: Recibir notificaciones por email
68+
push_notifications: Recibir notificaciones en el móbil
6869
organization: Organización
6970
phone: Teléfono
7071
registration_date: Fecha de alta
@@ -494,8 +495,7 @@ es:
494495
edit:
495496
edit_user: Cambiar usuario
496497
form:
497-
admin_warning: Atención!!! Estás dando poderes a este usuario!!
498-
superadmin_warning: Atención!!! Estás dando PODERES DIVINOS a este usuario!!
498+
notifications: Notificaciones
499499
give_time:
500500
give_time: Dar Tiempo a
501501
index:

config/locales/eu.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@ eu:
500500
edit:
501501
edit_user: Erabiltzailea aldatu
502502
form:
503-
admin_warning: Kontuz!!! Erabiltzaile honi boterea ematen ari zara.
504-
superadmin_warning: Kontuz!!! Erabiltzaile honi izugarrizko boterea ematen ari zara.
503+
notifications: Jakinarazpen
505504
give_time:
506505
give_time: honi denbora eman
507506
index:

config/locales/pt-BR.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ pt-BR:
494494
edit:
495495
edit_user: Trocar usuário
496496
form:
497-
admin_warning: Atenção!!! Você está dando poderes a este usuário!!
498-
superadmin_warning: Atenção!!! Você está dando PODERES DIVINOS a este usuário!!
497+
notifications: Notificações
499498
give_time:
500499
give_time: Dar Tempo a
501500
index:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddPushNotificationsToUsers < ActiveRecord::Migration
2+
def change
3+
add_column :users, :push_notifications, :boolean, default: true, null: false
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20180529144243) do
14+
ActiveRecord::Schema.define(version: 20180530180546) do
1515

1616
# These are extensions that must be enabled in order to support this database
1717
enable_extension "plpgsql"
@@ -215,6 +215,7 @@
215215
t.datetime "locked_at"
216216
t.string "locale", default: "es"
217217
t.boolean "notifications", default: true
218+
t.boolean "push_notifications", default: true, null: false
218219
end
219220

220221
add_index "users", ["email"], name: "index_users_on_email", using: :btree

0 commit comments

Comments
 (0)