Skip to content

Added push notifications setting #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ label[required]::after{
}
}

form .checkbox input[type="checkbox"] {
margin-left: 5px;
position: relative;
}

.back-overlay {
background-color: $black;
background-size: cover;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def scoped_users

def user_params
fields_to_permit = %w"gender username email date_of_birth phone
alt_phone active description notifications"
alt_phone active description notifications push_notifications"
fields_to_permit += %w"admin registration_number
registration_date" if admin?
fields_to_permit += %w"organization_id superadmin" if superadmin?
Expand Down
28 changes: 17 additions & 11 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= simple_form_for @user do |f| %>
<div class="form-inputs">
<%= f.input :username %>

<% if admin? %>
<%= f.input :email %>
<% if @user.unconfirmed_email.present? %>
Expand All @@ -10,24 +11,29 @@
<% else %>
<%= f.input :email, readonly: true %>
<% end %>
<%# if current_user.try :superadmin? %>
<%#= f.association :organization, include_blank: false %>
<%#= f.input :superadmin, as: :boolean, label: false, inline_label: true %>
<%# end %>
<%# if current_user.try :admin? %>
<%#= f.input :admin, as: :boolean, label: false, inline_label: true, hint: t(".admin_warning") %>
<%# end %>

<%= f.input :phone %>
<%= f.input :alt_phone %>
<%= f.input :date_of_birth,
start_year: Date.today.year - 90,
end_year: Date.today.year - 12,
include_blank: :true %>
<%= f.input :description, as: "text" %>
<%#= f.association :categories, label_method: :fqn, input_html: {style: 'width: 100%'} %>
<div class="checkbox">
<%= f.label :notifications %>
<%= f.check_box :notifications %>

<div class='form-group'>
<label><%= t('.notifications') %></label>
<div class="checkbox">
<%= f.label :notifications do %>
<%= f.check_box :notifications %>
<%= t('activerecord.attributes.user.notifications') %>
<% end %>
</div>
<div class="checkbox">
<%= f.label :push_notifications do %>
<%= f.check_box :push_notifications %>
<%= t('activerecord.attributes.user.push_notifications') %>
<% end %>
</div>
</div>
</div>
<div class="form-actions">
Expand Down
3 changes: 1 addition & 2 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ ca:
edit:
edit_user: Canviar usuari
form:
admin_warning: Atenció!!! Estàs atorgant poders a aquest usuari!!
superadmin_warning: Atenció!!! Estàs atorgant PODERS DIVINS a aquest usuari!!
notifications: Notificacions
give_time:
give_time: Donar Temps a
index:
Expand Down
6 changes: 3 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ en:
gender: Gender
identity_document: Identity Document
last_sign_in_at: Last login
notifications: Receive notifications
notifications: Receive email notifications
push_notifications: Receive mobile notifications
organization: Organization
phone: Phone
registration_date: Registration date
Expand Down Expand Up @@ -494,8 +495,7 @@ en:
edit:
edit_user: Update user
form:
admin_warning: Warning!!! You are giving privileges to this user!!
superadmin_warning: Warning!!! You are giving GOD PRIVILEGES to this user!!
notifications: Notifications
give_time:
give_time: Give time to
index:
Expand Down
6 changes: 3 additions & 3 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ es:
gender: Género
identity_document: DNI
last_sign_in_at: Fecha último login
notifications: Recibir notificaciones
notifications: Recibir notificaciones por email
push_notifications: Recibir notificaciones en el móbil
organization: Organización
phone: Teléfono
registration_date: Fecha de alta
Expand Down Expand Up @@ -494,8 +495,7 @@ es:
edit:
edit_user: Cambiar usuario
form:
admin_warning: Atención!!! Estás dando poderes a este usuario!!
superadmin_warning: Atención!!! Estás dando PODERES DIVINOS a este usuario!!
notifications: Notificaciones
give_time:
give_time: Dar Tiempo a
index:
Expand Down
3 changes: 1 addition & 2 deletions config/locales/eu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,7 @@ eu:
edit:
edit_user: Erabiltzailea aldatu
form:
admin_warning: Kontuz!!! Erabiltzaile honi boterea ematen ari zara.
superadmin_warning: Kontuz!!! Erabiltzaile honi izugarrizko boterea ematen ari zara.
notifications: Jakinarazpen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use locale app for this? cc/ @sseerrggii

give_time:
give_time: honi denbora eman
index:
Expand Down
3 changes: 1 addition & 2 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ pt-BR:
edit:
edit_user: Trocar usuário
form:
admin_warning: Atenção!!! Você está dando poderes a este usuário!!
superadmin_warning: Atenção!!! Você está dando PODERES DIVINOS a este usuário!!
notifications: Notificações
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very professional

give_time:
give_time: Dar Tempo a
index:
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20180530180546_add_push_notifications_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPushNotificationsToUsers < ActiveRecord::Migration
def change
add_column :users, :push_notifications, :boolean, default: true, null: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180529144243) do
ActiveRecord::Schema.define(version: 20180530180546) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -215,6 +215,7 @@
t.datetime "locked_at"
t.string "locale", default: "es"
t.boolean "notifications", default: true
t.boolean "push_notifications", default: true, null: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a data migration for the existing records?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the default makes it unnecessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existing records will default to true

end

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