From 1d84ca51d61ae2ac1cf59627587be3623f994485 Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Fri, 28 Oct 2016 13:15:13 -0200 Subject: [PATCH 1/6] Added pt-BR option --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 825bf9a5..6dabecad 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,7 +28,7 @@ module AgendaDuLibreRails Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] # config.i18n.default_locale = :de config.i18n.default_locale = :fr - config.i18n.available_locales = [:fr, :en] + config.i18n.available_locales = [:fr, :en, :'pt-BR'] config.action_mailer.default_options = { from: 'moderateurs@agendadulibre.org', From 14251ffceff792468749431073bd370232402263 Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Fri, 28 Oct 2016 13:43:05 -0200 Subject: [PATCH 2/6] Translation to new filter function --- config/locales/views/pt-BR.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config/locales/views/pt-BR.yml b/config/locales/views/pt-BR.yml index 0f790df9..d568d42e 100644 --- a/config/locales/views/pt-BR.yml +++ b/config/locales/views/pt-BR.yml @@ -36,6 +36,7 @@ pt-BR: index: calendar_in: Este calendário em %{rss}, %{webcal} ou %{ical} nb_events: "%{count} eventos" + filter: Busca avançada show: orga-list: Organizações no estado add_to_calendar: Adicionar ao meu calendário @@ -453,3 +454,31 @@ do evento no seguinte endereço:" update_html: destroy_html: feed: feed RSS + + application: + filter: + title: Busca Avançada + helper: Os parâmetros podem ser usados na agenda para consulta, ou integração em outro site + past: Passado + past_helper: Também inclui eventos passados em RSS feed, mapa e geojson + period_year: Ano + period_year_helper: Para definir o resumo semana/ano + period_week: Semana + near_location: Próximo a + near_location_helper: cidade ou local + near_distance: Distância de + near_distance_helper: cidade ou local + region: Estado + tag: Tag + iframe: Sem bordas + iframe_helper: Remove cabeçalho e rodapé para integração com um iframe + events: Agenda + map: Mapa + geojson: GeoJSON + json: JSON + rss: RSS + ics: iCal + xml: XML + digest: Resumo + orgas: Organizações + From 9b2039f5f806d277576b0e604f24738efdd8965e Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Fri, 28 Oct 2016 14:11:27 -0200 Subject: [PATCH 3/6] Send emails to moderators when orgas are manipuleted --- .../moderationorga_mailer/accept.text.haml | 10 ++++++++++ .../moderationorga_mailer/create.text.haml | 7 +++++++ .../moderationorga_mailer/destroy.text.haml | 10 ++++++++++ .../moderationorga_mailer/update.text.haml | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 app/views/moderationorga_mailer/accept.text.haml create mode 100644 app/views/moderationorga_mailer/create.text.haml create mode 100644 app/views/moderationorga_mailer/destroy.text.haml create mode 100644 app/views/moderationorga_mailer/update.text.haml diff --git a/app/views/moderationorga_mailer/accept.text.haml b/app/views/moderationorga_mailer/accept.text.haml new file mode 100644 index 00000000..95d41419 --- /dev/null +++ b/app/views/moderationorga_mailer/accept.text.haml @@ -0,0 +1,10 @@ += t '.body', author: @current_user +\ += t '.reminder' += render file: '/orgas/show' +\ += t '.access' += surround '<'.html_safe, '>'.html_safe do + = orga_url @orga +\ += t '.signature' diff --git a/app/views/moderationorga_mailer/create.text.haml b/app/views/moderationorga_mailer/create.text.haml new file mode 100644 index 00000000..d8cc166e --- /dev/null +++ b/app/views/moderationorga_mailer/create.text.haml @@ -0,0 +1,7 @@ += t '.body', subject: @orga.name += surround '<'.html_safe, '>'.html_safe do + = moderations_url +\ += render file: '/orgas/show' +\ += t '.signature' diff --git a/app/views/moderationorga_mailer/destroy.text.haml b/app/views/moderationorga_mailer/destroy.text.haml new file mode 100644 index 00000000..20356819 --- /dev/null +++ b/app/views/moderationorga_mailer/destroy.text.haml @@ -0,0 +1,10 @@ += t '.body', author: @current_user +\ += @reason +\ += t '.reclamation' +\ += t '.reminder' += render file: '/orgas/show' +\ += t '.signature' diff --git a/app/views/moderationorga_mailer/update.text.haml b/app/views/moderationorga_mailer/update.text.haml new file mode 100644 index 00000000..281ce7c9 --- /dev/null +++ b/app/views/moderationorga_mailer/update.text.haml @@ -0,0 +1,19 @@ += t '.body', subject: @orga.name, author: @current_user || t('.submitter') + +:ruby + new = render file: '/orgas/show' + + former = @orga + @orga = @orga.paper_trail.previous_version || @orga + + prev = render file: '/orgas/show' + @orga = former + + require 'differ/format/patch' + Differ.format = Differ::Format::Patch += Differ.diff new, prev +\ += surround '<'.html_safe, '>'.html_safe do + = edit_orga_url @orga +\ += t '.signature' From 369d7015df383ee9098f1ecbd55ecd767990147d Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Fri, 28 Oct 2016 15:14:24 -0200 Subject: [PATCH 4/6] Updates in functios to send emails to submitters and/or moderators --- app/assets/stylesheets/orgas.sass | 3 +- app/mailers/event_mailer.rb | 12 ++++ app/mailers/moderationorga_mailer.rb | 64 ++++++++++++++++++++ app/models/event_callbacks.rb | 3 + app/models/orga.rb | 8 +++ app/views/event_mailer/accept.text.haml | 1 + app/views/event_mailer/update.text.haml | 19 ++++++ app/views/moderation_mailer/accept.text.haml | 1 + app/views/moderation_mailer/update.text.haml | 5 +- app/views/orga_mailer/update.text.haml | 5 +- 10 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 app/mailers/moderationorga_mailer.rb create mode 100644 app/views/event_mailer/update.text.haml diff --git a/app/assets/stylesheets/orgas.sass b/app/assets/stylesheets/orgas.sass index f1ab0a0b..b3edd3c1 100644 --- a/app/assets/stylesheets/orgas.sass +++ b/app/assets/stylesheets/orgas.sass @@ -5,7 +5,7 @@ img.favicon form#orga_search right: 5% - width: 12em + width: 15em position: absolute font-size: larger text-align: right @@ -23,6 +23,7 @@ form#orga_search padding-left: 1.5em padding-right: 1.2em background-color: transparent + width: 14em button.search color: #258 diff --git a/app/mailers/event_mailer.rb b/app/mailers/event_mailer.rb index e8d213e8..3626c164 100644 --- a/app/mailers/event_mailer.rb +++ b/app/mailers/event_mailer.rb @@ -12,6 +12,18 @@ class EventMailer < ApplicationMailer subject: event.title}" end +# Send email to submitter too. Before, only moderators were receiving emails when an event was updated + def update(event) + @event = event + @current_user = User.find_by id: event.paper_trail.originator + + mail 'In-Reply-To' => + "", + to: event.submitter, + subject: "#{t 'mail_prefix'}#{t 'event_mailer.update.subject', + subject: event.title}" + end + def accept(event) @event = event @current_user = User.find_by id: event.paper_trail.originator diff --git a/app/mailers/moderationorga_mailer.rb b/app/mailers/moderationorga_mailer.rb new file mode 100644 index 00000000..60a71fe2 --- /dev/null +++ b/app/mailers/moderationorga_mailer.rb @@ -0,0 +1,64 @@ +# Send mails to check on organisations life cycle +class ModerationorgaMailer < ApplicationMailer + helper :events + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.orga_mailer.create.subject + # + def create(orga) + @orga = orga + + mail 'Message-ID' => + "", + subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.create.subject', + subject: orga.name}" + end + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.orga_mailer.update.subject + # + def update(orga) + @orga = orga + @current_user = User.find_by id: orga.paper_trail.originator + + mail 'In-Reply-To' => + "", + subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.update.subject', + subject: orga.name}" + end + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.orga_mailer.accept.subject + # + def accept(orga) + @orga = orga + @current_user = User.find_by id: orga.paper_trail.originator + + mail 'In-Reply-To' => + "", + subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.accept.subject', + subject: orga.name}" + end + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.orga_mailer.destroy.subject + # + def destroy(orga, reason = '') + @orga = orga + @current_user = User.find_by id: orga.paper_trail.originator + @reason = reason + + mail 'In-Reply-To' => + "", + subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.destroy.subject', + subject: orga.name}" + end +end diff --git a/app/models/event_callbacks.rb b/app/models/event_callbacks.rb index e390b5b4..16090ffe 100644 --- a/app/models/event_callbacks.rb +++ b/app/models/event_callbacks.rb @@ -39,6 +39,9 @@ class EventCallbacks elsif ActionMailer::Base.default_url_options[:host] # Send an update mail to moderators ModerationMailer.update(event).deliver_now + + # Included to Send an update mail to its author + EventMailer.update(event).deliver_now end end diff --git a/app/models/orga.rb b/app/models/orga.rb index 61d7ecb2..37189637 100644 --- a/app/models/orga.rb +++ b/app/models/orga.rb @@ -51,18 +51,26 @@ class Orga < ActiveRecord::Base if moderated_changed? OrgaMailer.accept(self).deliver_now! +# Send email to moderators when an orga is accepted + ModerationorgaMailer.accept(self).deliver_now! else OrgaMailer.update(self).deliver_now! +# Send email to moderators when an orga is updated + ModerationorgaMailer.update(self).deliver_now! end end end before_destroy do OrgaMailer.destroy(self).deliver_now! unless submitter.blank? +# Send email to moderators when an orga is deleted + ModerationorgaMailer.destroy(self).deliver_now! unless submitter.blank? end def send_secret OrgaMailer.create(self).deliver_now! +# Send email to moderators when an new orga is received + ModerationorgaMailer.create(self).deliver_now! end def name_as_tag diff --git a/app/views/event_mailer/accept.text.haml b/app/views/event_mailer/accept.text.haml index 87867ac4..27eabbec 100644 --- a/app/views/event_mailer/accept.text.haml +++ b/app/views/event_mailer/accept.text.haml @@ -19,6 +19,7 @@ = surround '<'.html_safe, '>'.html_safe do = cancel_event_url e, secret: e.secret \ += t '.reminder' = render file: '/events/show' \ = t '.signature' diff --git a/app/views/event_mailer/update.text.haml b/app/views/event_mailer/update.text.haml new file mode 100644 index 00000000..36473891 --- /dev/null +++ b/app/views/event_mailer/update.text.haml @@ -0,0 +1,19 @@ += t '.body', subject: @event.title, author: @current_user || t('.submitter') + +:ruby + new = render file: '/events/show' + + former = @event + @event = @event.paper_trail.previous_version || @event + + prev = render file: '/events/show' + @event = former + + require 'differ/format/patch' + Differ.format = Differ::Format::Patch += Differ.diff new, prev +\ += surround '<'.html_safe, '>'.html_safe do + = edit_event_url @event, secret: @event.secret +\ += t '.signature' diff --git a/app/views/moderation_mailer/accept.text.haml b/app/views/moderation_mailer/accept.text.haml index e18ae90d..7fd241db 100644 --- a/app/views/moderation_mailer/accept.text.haml +++ b/app/views/moderation_mailer/accept.text.haml @@ -1,5 +1,6 @@ = t '.body', author: @current_user \ += t '.reminder = render file: '/events/show' \ = t '.access' diff --git a/app/views/moderation_mailer/update.text.haml b/app/views/moderation_mailer/update.text.haml index c195b996..0751b56b 100644 --- a/app/views/moderation_mailer/update.text.haml +++ b/app/views/moderation_mailer/update.text.haml @@ -14,9 +14,6 @@ = Differ.diff new, prev \ = surround '<'.html_safe, '>'.html_safe do - - if @current_user - = edit_moderation_url @event - - else - = edit_event_url @event, secret: @event.secret + = edit_moderation_url @event \ = t '.signature' diff --git a/app/views/orga_mailer/update.text.haml b/app/views/orga_mailer/update.text.haml index b447f31b..416ee740 100644 --- a/app/views/orga_mailer/update.text.haml +++ b/app/views/orga_mailer/update.text.haml @@ -12,9 +12,8 @@ require 'differ/format/patch' Differ.format = Differ::Format::Patch = Differ.diff new, prev - -= t '.access' +\ = surround '<'.html_safe, '>'.html_safe do - = orga_url @orga + = edit_orga_url @orga, secret: @orga.secret \ = t '.signature' From 1bb504493ac0eb7093604adb2700364439505c62 Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Fri, 28 Oct 2016 15:46:58 -0200 Subject: [PATCH 5/6] Updates in functios to send emails to submitters and/or moderators --- app/views/moderation_mailer/accept.text.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/moderation_mailer/accept.text.haml b/app/views/moderation_mailer/accept.text.haml index 7fd241db..ffd075f0 100644 --- a/app/views/moderation_mailer/accept.text.haml +++ b/app/views/moderation_mailer/accept.text.haml @@ -1,6 +1,6 @@ = t '.body', author: @current_user \ -= t '.reminder += t '.reminder' = render file: '/events/show' \ = t '.access' From 5c80aa8aa5d78b7e93f680e05e5102445bafccae Mon Sep 17 00:00:00 2001 From: Paulo Henrique de Lima Santana Date: Sat, 29 Oct 2016 00:21:40 -0200 Subject: [PATCH 6/6] Fixed some phrases --- config/locales/views/pt-BR.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/views/pt-BR.yml b/config/locales/views/pt-BR.yml index d568d42e..54387554 100644 --- a/config/locales/views/pt-BR.yml +++ b/config/locales/views/pt-BR.yml @@ -368,7 +368,7 @@ descrição mais completa." body: "O evento foi aprovado por %{author}." access: "Você pode consultá-lo aqui:" reminder: "Detalhes do evento:" - signature: "Abraços,." + signature: "Abraços," destroy: subject: "O evento '%{subject}' foi recusado" body: "O evento '%{subject}' foi recusado por %{author} ou cancelado pelo remetente,