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