Skip to content
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

Added push notifications setting #356

Merged
merged 2 commits into from Jun 20, 2018

Conversation

mllocs
Copy link
Collaborator

@mllocs mllocs commented May 13, 2018

Added a "push notifications" global setting in the users table.

Eventually, we'll need to create a user_settings table, moving all the settings from the users table to the new one. I thought that using this new approach (user_settings table) only for this new setting would actually create complexity instead of reducing it. I think that it would be better to implement user_settings once we can move all the other user attributes that are settings.

I fixed the markup of the form and removed a css hack that is not needed when the markup is correct. I also removed some code and translations that were not being used.

screen shot 2018-05-13 at 11 12 04

@mllocs
Copy link
Collaborator Author

mllocs commented May 13, 2018

Notification settings

Copy link
Collaborator

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

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

Eventually, we'll need to create a user_settings table, moving all the settings from the users table to the new one. I thought that using this new approach (user_settings table) only for this new setting would actually create complexity instead of reducing it. I think that it would be better to implement user_settings once we can move all the other user attributes that are settings.

Totally agree

@@ -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

@@ -0,0 +1,5 @@
class AddPushNotificationsToUsers < ActiveRecord::Migration
def change
add_column :users, :push_notifications, :boolean, default: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add null: false. If I'm not mistaken, as it is, nothing prevents null values.

@mllocs mllocs force-pushed the feature/adds-user-push-notification-attribute branch from 1a3f5eb to 72eedbf Compare May 15, 2018 21:56
Copy link
Contributor

@enricostano enricostano left a comment

Choose a reason for hiding this comment

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

Thanks @mllocs 💪

db/schema.rb Outdated
t.datetime "created_at"
t.datetime "updated_at"
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooops 🔥

db/schema.rb Outdated
end

add_index "user_settings", ["user_id"], name: "index_user_settings_on_user_id", using: :btree

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops 🔥

def change
add_column :users, :push_notifications, :boolean, default: true, null: false
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any change in the User model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you gotta love Rails 😏

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess he meant we still need to validate the presence of push_notifications to get a human-readable error message?

@mllocs mllocs force-pushed the feature/adds-user-push-notification-attribute branch 2 times, most recently from 265cbab to 5af6e0e Compare May 22, 2018 15:28
@mllocs
Copy link
Collaborator Author

mllocs commented May 22, 2018

Ready @sauloperez @enricostano

@@ -208,6 +208,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

@@ -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

@@ -208,6 +208,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
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.

@mllocs
Copy link
Collaborator Author

mllocs commented May 28, 2018

This job: https://github.com/coopdevs/timeoverflow/pull/367/files will need to check this setting

@mllocs mllocs force-pushed the feature/adds-user-push-notification-attribute branch from 5af6e0e to c57afda Compare May 28, 2018 14:43
@enricostano
Copy link
Contributor

Rebase please @mllocs

@mllocs mllocs force-pushed the feature/adds-user-push-notification-attribute branch 2 times, most recently from b24621c to ff463cd Compare June 19, 2018 14:49
@enricostano
Copy link
Contributor

Tested on staging 🍏

@enricostano enricostano merged commit 879bbf0 into develop Jun 20, 2018
@enricostano enricostano deleted the feature/adds-user-push-notification-attribute branch June 20, 2018 14:25
@enricostano enricostano mentioned this pull request Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants