mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-21 00:47:46 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1c0a70165a
3 changed files with 28 additions and 1 deletions
|
@ -2,5 +2,23 @@ class AnswerController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@answer = Answer.find(params[:id])
|
@answer = Answer.find(params[:id])
|
||||||
@display_all = true
|
@display_all = true
|
||||||
|
|
||||||
|
if user_signed_in?
|
||||||
|
notif = Notification.where(target_type: "Answer", target_id: @answer.id, recipient_id: current_user.id, new: true).first
|
||||||
|
unless notif.nil?
|
||||||
|
notif.new = false
|
||||||
|
notif.save
|
||||||
|
end
|
||||||
|
notif = Notification.where(target_type: "Comment", target_id: @answer.comments.pluck(:id), recipient_id: current_user.id, new: true).first
|
||||||
|
unless notif.nil?
|
||||||
|
notif.new = false
|
||||||
|
notif.save
|
||||||
|
end
|
||||||
|
notif = Notification.where(target_type: "Smile", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true).first
|
||||||
|
unless notif.nil?
|
||||||
|
notif.new = false
|
||||||
|
notif.save
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,15 @@ class UserController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
||||||
@answers = @user.answers.reverse_order.paginate(page: params[:page])
|
@answers = @user.answers.reverse_order.paginate(page: params[:page])
|
||||||
|
|
||||||
|
if user_signed_in?
|
||||||
|
notif = Notification.where(target_type: "Relationship", target_id: @user.active_relationships.where(target_id: current_user.id).pluck(:id), recipient_id: current_user.id, new: true).first
|
||||||
|
unless notif.nil?
|
||||||
|
notif.new = false
|
||||||
|
notif.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js
|
format.js
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Notification < ActiveRecord::Base
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def for(recipient, options={})
|
def for(recipient, options={})
|
||||||
self.where(options.merge!(recipient: recipient)).order(:updated_at).reverse_order
|
self.where(options.merge!(recipient: recipient)).order(:created_at).reverse_order
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify(recipient, target)
|
def notify(recipient, target)
|
||||||
|
|
Loading…
Reference in a new issue