Skip to content
Extraits de code Groupes Projets
Valider ec02f546 rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #5122 from jaideng123/5113-mark-as-read-by-filter

Added Mark all in filter as read feature
parents fa9c0799 c68eeb70
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
* Add Terms of Service as an option for podmins, includes base template [#5104](https://github.com/diaspora/diaspora/pull/5104) * Add Terms of Service as an option for podmins, includes base template [#5104](https://github.com/diaspora/diaspora/pull/5104)
* Add rake task to send a mail to all users [#5111](https://github.com/diaspora/diaspora/pull/5111) * Add rake task to send a mail to all users [#5111](https://github.com/diaspora/diaspora/pull/5111)
* Expose which services are configured in /statistics.json [#5121](https://github.com/diaspora/diaspora/pull/5121) * Expose which services are configured in /statistics.json [#5121](https://github.com/diaspora/diaspora/pull/5121)
* In filtered notification views, replace "Mark all as read" with "Mark shown as read" [#5122](https://github.com/diaspora/diaspora/pull/5122)
# 0.4.0.1 # 0.4.0.1
......
...@@ -65,13 +65,22 @@ class NotificationsController < ApplicationController ...@@ -65,13 +65,22 @@ class NotificationsController < ApplicationController
end end
def read_all def read_all
Notification.where(:recipient_id => current_user.id).update_all(:unread => false) current_type = Notification.types[params[:type]]
notifications = Notification.where(:recipient_id => current_user.id)
notifications = notifications.where(:type => current_type) if params[:type]
notifications.update_all(:unread => false)
respond_to do |format| respond_to do |format|
format.html { redirect_to stream_path } if current_user.unread_notifications.count > 0
format.mobile{ redirect_to stream_path} format.html { redirect_to notifications_path }
format.mobile { redirect_to notifications_path }
else
format.html { redirect_to stream_path }
format.mobile { redirect_to stream_path }
end
format.xml { render :xml => {}.to_xml } format.xml { render :xml => {}.to_xml }
format.json { render :json => {}.to_json } format.json { render :json => {}.to_json }
end end
end end
end end
...@@ -36,8 +36,11 @@ ...@@ -36,8 +36,11 @@
= t('.show_all') = t('.show_all')
%a.btn.btn-default{ :class => ('active' if params[:show] == 'unread'), :href => '/notifications?show=unread' + (params[:type] ? '&type=' + params[:type] : '') } %a.btn.btn-default{ :class => ('active' if params[:show] == 'unread'), :href => '/notifications?show=unread' + (params[:type] ? '&type=' + params[:type] : '') }
= t('.show_unread') = t('.show_unread')
%a.btn.btn-default{:href => notifications_read_all_path, :class => ('disabled' unless @unread_notification_count > 0)} %a.btn.btn-default{:href => read_all_notifications_path(:type => params[:type] ), :class => ('disabled' unless @unread_notification_count > 0)}
= t('.mark_all_as_read') -if params[:type]
= t('.mark_all_shown_as_read')
-else
= t('.mark_all_as_read')
- @group_days.each do |day, notes| - @group_days.each do |day, notes|
.day_group.row-fluid .day_group.row-fluid
.date.span2 .date.span2
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
= t('.notifications') = t('.notifications')
.right .right
= link_to t('.mark_all_as_read'), notifications_read_all_path, :class => 'btn' -if params[:type]
= link_to t('.mark_all_shown_as_read'), read_all_notifications_path(:type => params[:type] ), :class => 'btn'
-else
= link_to t('.mark_all_as_read'), read_all_notifications_path, :class => 'btn'
%ul.notifications %ul.notifications
- @group_days.each do |day, notes| - @group_days.each do |day, notes|
%li %li
......
...@@ -709,6 +709,7 @@ en: ...@@ -709,6 +709,7 @@ en:
index: index:
notifications: "Notifications" notifications: "Notifications"
mark_all_as_read: "Mark all as read" mark_all_as_read: "Mark all as read"
mark_all_shown_as_read: "Mark all shown as read"
mark_read: "Mark read" mark_read: "Mark read"
mark_unread: "Mark unread" mark_unread: "Mark unread"
show_all: "show all" show_all: "show all"
......
...@@ -79,9 +79,12 @@ Diaspora::Application.routes.draw do ...@@ -79,9 +79,12 @@ Diaspora::Application.routes.draw do
delete 'visibility' => 'conversation_visibilities#destroy' delete 'visibility' => 'conversation_visibilities#destroy'
end end
get 'notifications/read_all' => 'notifications#read_all'
resources :notifications, :only => [:index, :update] do resources :notifications, :only => [:index, :update] do
collection do
get :read_all
end
end end
resources :tags, :only => [:index] resources :tags, :only => [:index]
......
...@@ -42,33 +42,6 @@ describe NotificationsController do ...@@ -42,33 +42,6 @@ describe NotificationsController do
end end
end end
describe "#read_all" do
it 'marks all notifications as read' do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
FactoryGirl.create(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
Notification.where(:unread => true).count.should == 2
get :read_all
Notification.where(:unread => true).count.should == 0
end
it "should redirect to the stream in the html version" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :html
response.should redirect_to(stream_path)
end
it "should redirect to the stream in the mobile version" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :mobile
response.should redirect_to(stream_path)
end
it "should return a dummy value in the json version" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :json
response.should_not be_redirect
end
end
describe '#index' do describe '#index' do
before do before do
@post = FactoryGirl.create(:status_message) @post = FactoryGirl.create(:status_message)
...@@ -137,4 +110,51 @@ describe NotificationsController do ...@@ -137,4 +110,51 @@ describe NotificationsController do
end end
end end
end end
describe "#read_all" do
it 'marks all notifications as read' do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
FactoryGirl.create(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
Notification.where(:unread => true).count.should == 2
get :read_all
Notification.where(:unread => true).count.should == 0
end
it 'marks all notifications in the current filter as read' do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
FactoryGirl.create(:notification, :recipient => alice)
eve.share_with(alice.person, eve.aspects.first)
Notification.where(:unread => true).count.should == 2
get :read_all, "type" => "started_sharing"
Notification.where(:unread => true).count.should == 1
end
it "should redirect back in the html version if it has > 0 notifications" do
FactoryGirl.create(:notification, :recipient => alice)
eve.share_with(alice.person, eve.aspects.first)
get :read_all, :format => :html, "type" => "started_sharing"
response.should redirect_to(notifications_path)
end
it "should redirect back in the mobile version if it has > 0 notifications" do
FactoryGirl.create(:notification, :recipient => alice)
eve.share_with(alice.person, eve.aspects.first)
get :read_all, :format => :mobile, "type" => "started_sharing"
response.should redirect_to(notifications_path)
end
it "should redirect to stream in the html version if it has 0 notifications" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :html
response.should redirect_to(stream_path)
end
it "should redirect back in the mobile version if it has 0 notifications" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :mobile
response.should redirect_to(stream_path)
end
it "should return a dummy value in the json version" do
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :json
response.should_not be_redirect
end
end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter