Skip to content

Commit 3a80bb1

Browse files
authored
Merge pull request #371 from linuxfrorg/unblock_and_unplonk
Be able to un-plonk and un-block an account
2 parents 57065f7 + cebe4e1 commit 3a80bb1

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

app/controllers/moderation/block_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ def create
66
nb_days = (params[:nb_days] || 2).to_i
77
@account = Account.find(params[:account_id])
88
@account.block(nb_days, current_user.id)
9-
Board.amr_notification("Les commentaires de #{@account.login} #{user_url @account.login} ont été bloqués pendant #{pluralize nb_days, "jour"} par #{current_user.name} #{user_url(current_user)}")
10-
render json: { notice: "Les commentaires de #{@account.login} sont bloqués pendant #{pluralize nb_days, "jour"}" }
9+
if nb_days > 0
10+
Board.amr_notification("Les commentaires de #{@account.login} #{user_url @account.login} ont été bloqués pendant #{pluralize nb_days, "jour"} par #{current_user.name} #{user_url(current_user)}")
11+
render json: { notice: "Les commentaires de #{@account.login} sont bloqués pendant #{pluralize nb_days, "jour"}" }
12+
else
13+
Board.amr_notification("Les commentaires de #{@account.login} #{user_url @account.login} ont été débloqués par #{current_user.name} #{user_url(current_user)}")
14+
render json: { notice: "Les commentaires de #{@account.login} sont débloqués" }
15+
end
1116
end
1217
end

app/controllers/moderation/plonk_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ def create
66
nb_days = (params[:nb_days] || 2).to_i
77
@account = Account.find(params[:account_id])
88
@account.plonk(nb_days, current_user.id)
9-
Board.amr_notification("Le compte #{@account.login} #{user_url @account.login} a été plonké pendant #{pluralize nb_days, "jour"} par #{current_user.name} #{user_url(current_user)}")
10-
render json: { notice: "#{@account.login} a été plonké pendant #{pluralize nb_days, "jour"}" }
9+
if nb_days > 0
10+
Board.amr_notification("Le compte #{@account.login} #{user_url @account.login} a été privé de tribune pendant #{pluralize nb_days, "jour"} par #{current_user.name} #{user_url(current_user)}")
11+
render json: { notice: "#{@account.login} a été privé de tribune pendant #{pluralize nb_days, "jour"}" }
12+
else
13+
Board.amr_notification("Le compte #{@account.login} #{user_url @account.login} a été réautorisé sur la tribune par #{current_user.name} #{user_url(current_user)}")
14+
render json: { notice: "#{@account.login} a été réautorisé sur la tribune" }
15+
end
1116
end
1217
end

app/models/account.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ def blocked?
288288
def block(nb_days, user_id)
289289
$redis.set("block/#{self.id}", 1)
290290
$redis.expire("block/#{self.id}", nb_days * 86400)
291-
logs.create(description: "Interdiction de poster des commentaires pendant #{pluralize nb_days, "jour"}", user_id: user_id)
291+
if nb_days > 0
292+
logs.create(description: "Interdiction de poster des commentaires pendant #{pluralize nb_days, "jour"}", user_id: user_id)
293+
else
294+
logs.create(description: "Réautorisation de poster des commentaires", user_id: user_id)
295+
end
292296
end
293297

294298
def can_block?
@@ -304,7 +308,11 @@ def plonked?
304308
def plonk(nb_days, user_id)
305309
$redis.set("plonk/#{self.id}", 1)
306310
$redis.expire("plonk/#{self.id}", nb_days * 86400)
307-
logs.create(description: "Interdiction de tribune pendant #{pluralize nb_days, "jour"}", user_id: user_id)
311+
if nb_days > 0
312+
logs.create(description: "Interdiction de tribune pendant #{pluralize nb_days, "jour"}", user_id: user_id)
313+
else
314+
logs.create(description: "Réautorisation de poster des commentaires", user_id: user_id)
315+
end
308316
end
309317

310318
def can_plonk?

app/views/admin/accounts/index.html.haml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
= image_tag "/images/icones/x_red.svg", alt: "Inactif", title: "Inactif", width: "15px"
2727
- else
2828
= image_tag "/images/icones/check.svg", alt: "Actif", title: "Actif", width: "16px"
29+
- if account.plonked?
30+
📢 #{ image_tag "/images/icones/denied.png", alt: "interdiction de tribune", title: "interdiction de tribune", width: "16px" }
31+
- if account.blocked?
32+
🖍️ #{ image_tag "/images/icones/denied.png", alt: "interdiction de commentaire", title: "interdiction de commentaire", width: "16px" }
2933
%br
3034
= account.email
3135
- if account.user.homesite.present?

app/views/users/_recent.html.haml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
- if current_account.admin?
2121
%p Visibilité
2222
%ul
23+
- if @user.account.plonked?
24+
%li interdiction de tribune ;
25+
- if @user.account.blocked?
26+
%li interdiction de commentaire ;
2327
- if @user.comments.count > 0
2428
%li commentaires : #{ @user.comments.published.count } sur #{ @user.comments.count } ;
2529
- else
@@ -39,6 +43,7 @@
3943
%button.more.block Interdire de commenter
4044
.more_actions.block(style="display: none;")
4145
%ul
46+
%li= button_to "réautorisation", moderation_block_index_path(nb_days: 0, account_id: @user.account.id), remote: true, class: "block"
4247
%li= button_to "24 h", moderation_block_index_path(nb_days: 1, account_id: @user.account.id), remote: true, class: "block"
4348
%li= button_to "48 h", moderation_block_index_path(nb_days: 2, account_id: @user.account.id), remote: true, class: "block"
4449
%li= button_to "une semaine", moderation_block_index_path(nb_days: 7, account_id: @user.account.id), remote: true, class: "block"
@@ -47,6 +52,7 @@
4752
%button.more.plonk Interdire de tribune
4853
.more_actions.plonk(style="display: none;")
4954
%ul
55+
%li= button_to "réautorisation", moderation_plonk_index_path(nb_days: 0, account_id: @user.account.id), remote: true, class: "plonk"
5056
%li= button_to "24 heures", moderation_plonk_index_path(nb_days: 1, account_id: @user.account.id), remote: true, class: "plonk"
5157
%li= button_to "48 heures", moderation_plonk_index_path(nb_days: 2, account_id: @user.account.id), remote: true, class: "plonk"
5258
%li= button_to "une semaine", moderation_plonk_index_path(nb_days: 7, account_id: @user.account.id), remote: true, class: "plonk"

0 commit comments

Comments
 (0)