SPAM removal will not send an email or version data

This commit is contained in:
echarp 2017-05-06 15:46:22 +02:00
parent 8112a4056f
commit 45722dc224
6 changed files with 29 additions and 1 deletions

View File

@ -45,7 +45,12 @@ class ModerationsController < ApplicationController
# DELETE /events/1
# DELETE /events/1.json
def destroy
@moderation.destroy!
if @moderation.reason == 'r_0'
logger.info 'SPAM! SPAM! SPAM!'
@moderation.paper_trail.without_versioning :destroy
else
@moderation.destroy!
end
respond_to do |format|
format.html { redirect_to :moderations, notice: t('.ok') }
format.json { head :no_content }
@ -81,6 +86,8 @@ class ModerationsController < ApplicationController
def generate_destroy_reason
if params[:reason] == 'r_4'
@moderation.reason = params[:event][:reason]
elsif params[:reason] == 'r_0'
@moderation.reason = 'r_0'
else
@moderation.reason = t "moderations.refuse.reason_#{params[:reason]}_long"
end

View File

@ -4,6 +4,10 @@
= form_for @moderation, url: { action: :destroy },
html: { method: :delete } do |f|
.field.closer{ title: t('.reason_r_0_long') }
= radio_button_tag :reason, :r_0, params[:event] == 'reason_r_0'
= label_tag :reason_r_0, t('.reason_r_0')
.field.closer{ title: t('.reason_r_1_long') }
= radio_button_tag :reason, :r_1, params[:event] == 'reason_r_1'
= label_tag :reason_r_1, t('.reason_r_1')

View File

@ -193,10 +193,12 @@ it more readable or agreable.
motif: Motive
ok: Reject
ko: Moderation
reason_r_0: SPAM!
reason_r_1: Off-topic
reason_r_2: Not enough information
reason_r_3: Event already recorded
reason_r_4: Specific reason (specify)
reason_r_0_long: SPAM! SPAM! SPAM!
reason_r_1_long: Nonetheless, the proposed event hasn't yet retained the
moderators' attention. As it were, the proposed event isn't about Free
Software, or does not relate to Free Software, or the link with Free

View File

@ -188,10 +188,12 @@ fr:
motif: Motif
ok: Rejeter
ko: Modération
reason_r_0: SPAM!
reason_r_1: Hors sujet
reason_r_2: Pas assez d'informations
reason_r_3: Événement déjà enregistré
reason_r_4: Raison spécifique (précisez)
reason_r_0_long: SPAM! SPAM! SPAM!
reason_r_1_long: Toutefois, l'événement proposé n'a pour l'instant pas
retenu l'attention des modérateurs. En effet, l'événement proposé ne
concerne pas le Logiciel Libre, ou bien le lien avec le Logiciel Libre

View File

@ -193,10 +193,12 @@ completa, deixando o texto mais legível e agradável.
motif: Motivo
ok: Rejeitar
ko: Moderação
reason_r_0: SPAM!
reason_r_1: Off-topic
reason_r_2: As informação não são suficientes
reason_r_3: O evento já existe
reason_r_4: Jutificativas específicas (especifique)
reason_r_0_long: SPAM! SPAM! SPAM!
reason_r_1_long: O evento inscrito até agora não chamou a atenção
dos moderadores. Na verdade, o evento proposto não é sobre Software
Livre, ou a relação com Software Livre não é evidente considerando a

View File

@ -89,6 +89,17 @@ class ModerationsControllerTest < ActionController::TestCase
assert_redirected_to edit_moderation_path @moderation
end
test 'should reject spam' do
assert_difference 'Event.count', -1 do
delete :destroy, id: @moderation, reason: 'r_0', event: { reason: '' }
end
assert_not_empty assigns(:moderation).reason
assert_empty assigns(:moderation).errors
assert_redirected_to :moderations
end
test 'should reject event' do
assert_difference 'Event.count', -1 do
delete :destroy, id: @moderation, reason: 'r_1', event: { reason: '' }