Event refusals was not properly sent to the submitter
This commit is contained in:
parent
76f78baa4d
commit
6a7895095e
@ -1,5 +1,5 @@
|
||||
$(document).ready ->
|
||||
$('body.moderations .field.closer input[type=radio]').click ->
|
||||
$('body.moderations #reason_text').parent().slideUp()
|
||||
$('body.moderations #event_reason_text').parent().slideUp()
|
||||
$('body.moderations .field.opener input[type=radio]').click ->
|
||||
$('body.moderations #reason_text').parent().slideDown()
|
||||
$('body.moderations #event_reason_text').parent().slideDown()
|
||||
|
@ -1,5 +1,6 @@
|
||||
# The top level controller, where can be centralised almost everything
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :set_paper_trail_whodunnit
|
||||
before_action :set_locale
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
|
@ -44,7 +44,8 @@ class ModerationsController < ApplicationController
|
||||
# DELETE /events/1
|
||||
# DELETE /events/1.json
|
||||
def destroy
|
||||
@moderation.reason_for_deletion = get_reason_from_params params[:reason]
|
||||
@moderation.reason = params[:event][:reason] ||
|
||||
t("moderations.refuse.reason_#{params[:reason]}_long")
|
||||
@moderation.destroy!
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :moderations, notice: t('.ok') }
|
||||
@ -77,12 +78,4 @@ class ModerationsController < ApplicationController
|
||||
def locked
|
||||
redirect_to edit_moderation_url(@moderation), alert: t('staleObjectError')
|
||||
end
|
||||
|
||||
def get_reason_from_params(reason)
|
||||
if reason == 'r_4'
|
||||
reason
|
||||
else
|
||||
t "moderations.refuse.reason_#{reason}_long"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,3 @@
|
||||
# encoding: utf-8
|
||||
|
||||
# This is the central ADL class, where are managed all events
|
||||
class Event < ActiveRecord::Base
|
||||
extend SimpleCalendar
|
||||
@ -25,7 +23,7 @@ class Event < ActiveRecord::Base
|
||||
after_validation :geocode
|
||||
|
||||
# Mechanism to store some reason which can be used when sending notifications
|
||||
attr_accessor :reason_for_deletion
|
||||
attr_accessor :reason
|
||||
|
||||
after_create EventCallbacks
|
||||
after_update EventCallbacks
|
||||
@ -71,10 +69,8 @@ class Event < ActiveRecord::Base
|
||||
end
|
||||
|
||||
before_validation on: :update do
|
||||
if address_changed?
|
||||
self.latitude = nil
|
||||
self.longitude = nil
|
||||
end
|
||||
self.latitude = nil if address_changed?
|
||||
self.longitude = nil if address_changed?
|
||||
end
|
||||
|
||||
before_create do
|
||||
@ -113,7 +109,8 @@ class Event < ActiveRecord::Base
|
||||
def to_tweet
|
||||
url = Rails.application.routes.url_helpers.event_url(
|
||||
self,
|
||||
host: ActionMailer::Base.default_url_options[:host])
|
||||
host: ActionMailer::Base.default_url_options[:host]
|
||||
)
|
||||
|
||||
tweet = "#{self} #{url}"
|
||||
if tweet.size >= 140
|
||||
@ -125,8 +122,7 @@ class Event < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def end_after_start
|
||||
return if end_time.blank? || start_time.blank?
|
||||
|
||||
errors.add :end_time, :before_start if end_time <= start_time
|
||||
errors.add :end_time, :before_start if
|
||||
!end_time.blank? && !start_time.blank? && end_time <= start_time
|
||||
end
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ class Orga < ActiveRecord::Base
|
||||
scope :locality, -> {}
|
||||
scope :daylimit, -> {}
|
||||
scope :future, -> {}
|
||||
scope :period, ->(year, week) {}
|
||||
scope :period, ->(_year, _week) {}
|
||||
|
||||
scope :region, ->(region) { where region: region unless region == 'all' }
|
||||
scope :tag, ->(tag) { where 'tags like ?', "%#{tag}%" }
|
||||
|
@ -1,6 +1,6 @@
|
||||
= t '.body', author: @current_user
|
||||
\
|
||||
= @event.reason_for_deletion
|
||||
= @event.reason
|
||||
\
|
||||
= t '.reclamation'
|
||||
\
|
||||
|
@ -1,6 +1,6 @@
|
||||
= t '.body', subject: @event.title, author: @current_user
|
||||
\
|
||||
= @event.reason_for_deletion
|
||||
= @event.reason
|
||||
\
|
||||
= t '.reminder'
|
||||
= render file: '/events/show'
|
||||
|
@ -1,35 +1,37 @@
|
||||
%h2
|
||||
%em.fa.fa-exclamation-triangle
|
||||
=t '.title'
|
||||
= t '.title'
|
||||
|
||||
= form_tag moderation_path(@moderation), method: :delete do |f|
|
||||
.field.closer(title="#{t '.reason_r_1_long'}")
|
||||
= form_for @moderation, url: { action: :destroy },
|
||||
html: { method: :delete } do |f|
|
||||
.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')
|
||||
|
||||
.field.closer(title="#{t '.reason_r_2_long'}")
|
||||
.field.closer{ title: t('.reason_r_2_long') }
|
||||
= radio_button_tag :reason, :r_2, params[:event] == 'reason_r_2'
|
||||
= label_tag :reason_r_2, t('.reason_r_2')
|
||||
|
||||
.field.closer(title="#{t '.reason_r_3_long'}")
|
||||
.field.closer{ title: t('.reason_r_3_long') }
|
||||
= radio_button_tag :reason, :r_3, params[:event] == 'reason_r_3'
|
||||
= label_tag :reason_r_3, t('.reason_r_3')
|
||||
|
||||
.field.opener(title="#{t '.reason_r_4_long'}")
|
||||
= radio_button_tag :reason, :r_4, params[:event] == 'reason_r_4' || !params[:event]
|
||||
.field.opener{ title: t('.reason_r_4_long') }
|
||||
= radio_button_tag :reason, :r_4,
|
||||
params[:event] == 'reason_r_4' || !params[:event]
|
||||
= label_tag :reason_r_4, t('.reason_r_4')
|
||||
|
||||
.field
|
||||
= label_tag :reason_text, t('.reason')
|
||||
= text_area_tag :reason_text, nil, cols: 40, rows: 5
|
||||
= label_tag :reason
|
||||
= f.text_area :reason, cols: 40, rows: 5
|
||||
|
||||
= link_to moderations_path do
|
||||
%em.fa.fa-arrow-left
|
||||
=t '.ko'
|
||||
= t '.ko'
|
||||
|
||||
= button_tag do
|
||||
%em.fa.fa-thumbs-down
|
||||
=t '.ok'
|
||||
= t '.ok'
|
||||
|
||||
%fieldset
|
||||
%legend
|
||||
|
1
config/initializers/paper_trail.rb
Normal file
1
config/initializers/paper_trail.rb
Normal file
@ -0,0 +1 @@
|
||||
PaperTrail.config.track_associations = false
|
@ -208,7 +208,7 @@ don't hesitate to repeat each time these informations, they are important.
|
||||
\nWe strongly invite you to submit again this event with a more complete
|
||||
description."
|
||||
reason_r_3_long: Your event is relevant, but has already been submitted.
|
||||
reason: Your reason
|
||||
reason_text: Your reason
|
||||
destroy:
|
||||
ok: Event rejected
|
||||
notes:
|
||||
|
@ -209,7 +209,7 @@ répéter à chaque fois ces informations, elles sont importantes.
|
||||
description plus complète."
|
||||
reason_r_3_long: Votre événement a tout à fait sa place ici, mais il a
|
||||
déjà été enregistré.
|
||||
reason: Votre raison
|
||||
reason_text: Votre raison
|
||||
destroy:
|
||||
ok: Événement rejeté
|
||||
notes:
|
||||
|
@ -5,12 +5,11 @@ module Differ
|
||||
module Patch
|
||||
class << self
|
||||
def format(change)
|
||||
case
|
||||
when change.change?
|
||||
if change.change?
|
||||
as_change change
|
||||
when change.delete?
|
||||
elsif change.delete?
|
||||
as_delete change
|
||||
when change.insert?
|
||||
elsif change.insert?
|
||||
as_insert change
|
||||
else
|
||||
''
|
||||
|
@ -92,7 +92,7 @@ class ModerationsControllerTest < ActionController::TestCase
|
||||
|
||||
test 'should reject event' do
|
||||
assert_difference 'Event.count', -1 do
|
||||
delete :destroy, id: @moderation
|
||||
delete :destroy, id: @moderation, event: {}
|
||||
end
|
||||
|
||||
assert_empty assigns(:moderation).errors
|
||||
@ -102,7 +102,7 @@ class ModerationsControllerTest < ActionController::TestCase
|
||||
|
||||
test 'should reject event with a reason' do
|
||||
assert_difference 'Event.count', -1 do
|
||||
delete :destroy, id: @moderation, reason: 'r_4'
|
||||
delete :destroy, id: @moderation, reason: 'r_4', event: {}
|
||||
end
|
||||
|
||||
assert_empty assigns(:moderation).errors
|
||||
|
@ -24,7 +24,7 @@ class EventMailerTest < ActionMailer::TestCase
|
||||
|
||||
test 'destroy' do
|
||||
event = Event.last
|
||||
event.reason_for_deletion = 'hello world'
|
||||
event.reason = 'hello world'
|
||||
mail = EventMailer.destroy Event.last
|
||||
assert_match(/Événement .* refusé/, mail.subject)
|
||||
assert_equal [Event.last.contact], mail.to
|
||||
|
@ -42,7 +42,7 @@ hello world'
|
||||
|
||||
test 'destroy' do
|
||||
event = Event.unscoped.last
|
||||
event.reason_for_deletion = 'hello world'
|
||||
event.reason = 'hello world'
|
||||
mail = ModerationMailer.destroy event
|
||||
assert_match(/Événement .* refusé/, mail.subject)
|
||||
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
||||
|
@ -16,7 +16,7 @@ class EventMailerPreview < ActionMailer::Preview
|
||||
def destroy
|
||||
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
||||
event = Event.last
|
||||
event.reason_for_deletion = 'hello world'
|
||||
event.reason = 'hello world'
|
||||
EventMailer.destroy event
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ hello world'
|
||||
def destroy
|
||||
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
||||
event = Event.last
|
||||
event.reason_for_deletion = 'hello world'
|
||||
event.reason = 'hello world'
|
||||
ModerationMailer.destroy event
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ class OrgaMailerPreview < ActionMailer::Preview
|
||||
def destroy
|
||||
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
||||
orga = Orga.last
|
||||
# orga.reason_for_deletion = 'hello world'
|
||||
# orga.reason = 'hello world'
|
||||
OrgaMailer.destroy orga
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user