diff --git a/app/controllers/moderations_controller.rb b/app/controllers/moderations_controller.rb index f25c8946..4311be90 100644 --- a/app/controllers/moderations_controller.rb +++ b/app/controllers/moderations_controller.rb @@ -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 diff --git a/app/views/moderations/refuse.html.haml b/app/views/moderations/refuse.html.haml index 194a75ab..a1cada24 100644 --- a/app/views/moderations/refuse.html.haml +++ b/app/views/moderations/refuse.html.haml @@ -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') diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index 8f67ac8f..bb6232a3 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -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 diff --git a/config/locales/views/fr.yml b/config/locales/views/fr.yml index ab3424f0..734d51bb 100644 --- a/config/locales/views/fr.yml +++ b/config/locales/views/fr.yml @@ -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 diff --git a/config/locales/views/pt-BR.yml b/config/locales/views/pt-BR.yml index 005dcbc6..ac247e75 100644 --- a/config/locales/views/pt-BR.yml +++ b/config/locales/views/pt-BR.yml @@ -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 diff --git a/test/controllers/moderations_controller_test.rb b/test/controllers/moderations_controller_test.rb index e33f04de..75cda8c3 100644 --- a/test/controllers/moderations_controller_test.rb +++ b/test/controllers/moderations_controller_test.rb @@ -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: '' }