code climate

This commit is contained in:
Devin Howard 2016-12-11 18:03:59 -05:00
parent 95671010eb
commit 4324ba31c5
7 changed files with 20 additions and 17 deletions

View file

@ -38,7 +38,9 @@ class AccessController < ApplicationController
# who we then send an email to # who we then send an email to
user = User.find(user_id) user = User.find(user_id)
mail = MapMailer.invite_to_edit_email(@map, current_user, user) mail = MapMailer.invite_to_edit_email(@map, current_user, user)
user.notify(mail.subject, 'invite to edit', UserMap.find_by(user: user, map: @map), true, MAILBOXER_CODE_INVITED_TO_EDIT) user.notify(mail.subject, 'invite to edit',
UserMap.find_by(user: user, map: @map),
true, MAILBOXER_CODE_INVITED_TO_EDIT)
end end
@map.remove_old_collaborators(user_ids) @map.remove_old_collaborators(user_ids)

View file

@ -95,6 +95,8 @@ class UsersController < ApplicationController
private private
def user_params def user_params
params.require(:user).permit(:name, :email, :image, :password, :password_confirmation, :emails_allowed) params.require(:user).permit(
:name, :email, :image, :password, :password_confirmation, :emails_allowed
)
end end
end end

View file

@ -40,7 +40,7 @@ module ApplicationHelper
def user_unread_notification_count def user_unread_notification_count
return 0 if current_user.nil? return 0 if current_user.nil?
@user_unread_notification_count ||= current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt| @uunc ||= current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt|
receipt.is_read ? total : total + 1 receipt.is_read ? total : total + 1
end end
end end

View file

@ -7,10 +7,10 @@ class AccessRequest < ApplicationRecord
self.answered = true self.answered = true
self.save self.save
Mailboxer::Notification.where(notified_object: self).each do |notification| Mailboxer::Notification.where(notified_object: self).find_each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end end
user_map = UserMap.create(user: user, map: map) user_map = UserMap.create(user: user, map: map)
mail = MapMailer.invite_to_edit_email(map, map.user, user) mail = MapMailer.invite_to_edit_email(map, map.user, user)
user.notify(mail.subject, 'invite to edit', user_map, true, MAILBOXER_CODE_INVITED_TO_EDIT) user.notify(mail.subject, 'invite to edit', user_map, true, MAILBOXER_CODE_INVITED_TO_EDIT)
@ -21,7 +21,7 @@ class AccessRequest < ApplicationRecord
self.answered = true self.answered = true
self.save self.save
Mailboxer::Notification.where(notified_object: self).each do |notification| Mailboxer::Notification.where(notified_object: self).find_each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end end
end end

View file

@ -4,7 +4,7 @@ class UserMap < ApplicationRecord
belongs_to :user belongs_to :user
def mark_invite_notifications_as_read def mark_invite_notifications_as_read
Mailboxer::Notification.where(notified_object: self).each do |notification| Mailboxer::Notification.where(notified_object: self).find_each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end end
end end

View file

@ -8,7 +8,7 @@ import NotificationIconComponent from '../../components/NotificationIcon'
const NotificationIcon = { const NotificationIcon = {
unreadNotificationsCount: null, unreadNotificationsCount: null,
init: function(serverData) { init: function(serverData) {
const self = NotificationIcon const self = NotificationIcon
self.unreadNotificationsCount = serverData.unreadNotificationsCount self.unreadNotificationsCount = serverData.unreadNotificationsCount
@ -18,7 +18,7 @@ const NotificationIcon = {
if (newUnreadCount !== null) { if (newUnreadCount !== null) {
NotificationIcon.unreadNotificationsCount = newUnreadCount NotificationIcon.unreadNotificationsCount = newUnreadCount
} }
if (Active.Mapper !== null) { if (Active.Mapper !== null) {
ReactDOM.render(React.createElement(NotificationIconComponent, { ReactDOM.render(React.createElement(NotificationIconComponent, {
unreadNotificationsCount: NotificationIcon.unreadNotificationsCount unreadNotificationsCount: NotificationIcon.unreadNotificationsCount
@ -27,4 +27,4 @@ const NotificationIcon = {
} }
} }
export default NotificationIcon export default NotificationIcon

View file

@ -9,14 +9,14 @@ class NotificationIcon extends Component {
} }
render = () => { render = () => {
var linkClasses = "notificationsIcon upperRightEl upperRightIcon " let linkClasses = 'notificationsIcon upperRightEl upperRightIcon '
if (this.props.unreadNotificationsCount > 0) { if (this.props.unreadNotificationsCount > 0) {
linkClasses += "unread" linkClasses += 'unread'
} else { } else {
linkClasses += "read" linkClasses += 'read'
} }
return ( return (
<a className={linkClasses} href="/notifications"> <a className={linkClasses} href="/notifications">
<div className="tooltipsUnder"> <div className="tooltipsUnder">
@ -26,8 +26,7 @@ class NotificationIcon extends Component {
<div className="unread-notifications-dot"></div> <div className="unread-notifications-dot"></div>
)} )}
</a> </a>
) )
} }
} }