diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index e9a9f1057..9152955dc 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -253,6 +253,10 @@ a { max-width: none; } +.button.float-right ~ .button.float-right { + margin: 0 $line-height/2; +} + // 02. Header // ---------- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c5f2e6aca..1f52f0eea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -35,4 +35,9 @@ module ApplicationHelper } Redcarpet::Markdown.new(renderer, extensions).render(text).html_safe end + + def author_of?(authorable, user) + return false if authorable.blank? || user.blank? + authorable.author_id == user.id + end end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 5f7dc5391..d987e34cc 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -64,7 +64,7 @@ class Mailer < ApplicationMailer @notifications = user.notifications.where(notifiable_type: "ProposalNotification") with_user(user) do - mail(to: user.email, subject: "Email digest") + mail(to: user.email, subject: t('mailers.proposal_notification_digest.title', org_name: Setting['org_name'])) end end diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index e0533ca50..f90b8e39d 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -32,6 +32,10 @@

<%= setting['org_name'] %>

+ +

+ <%= t('mailers.no_reply') %>

+ diff --git a/app/views/mailer/direct_message_for_receiver.html.erb b/app/views/mailer/direct_message_for_receiver.html.erb index a6b366ce9..eb1e56fe7 100644 --- a/app/views/mailer/direct_message_for_receiver.html.erb +++ b/app/views/mailer/direct_message_for_receiver.html.erb @@ -20,4 +20,18 @@ + + + + + + + +
+

+ <%= t('mailers.direct_message_for_receiver.unsubscribe', + account: link_to(t('mailers.proposal_notification_digest.unsubscribe_account'), + account_path, style: "color: #2895F1; text-decoration: none;")).html_safe %> +

+
diff --git a/app/views/mailer/direct_message_for_sender.html.erb b/app/views/mailer/direct_message_for_sender.html.erb index 219337705..4cf832414 100644 --- a/app/views/mailer/direct_message_for_sender.html.erb +++ b/app/views/mailer/direct_message_for_sender.html.erb @@ -1,9 +1,13 @@ -

<%= @direct_message.receiver.name %>

-

+

+ <%= t('mailers.direct_message_for_sender.title_html', + receiver: @direct_message.receiver.name ) %> +

+ +

<%= @direct_message.title %> -

+

<%= @direct_message.body %> diff --git a/app/views/mailer/proposal_notification_digest.html.erb b/app/views/mailer/proposal_notification_digest.html.erb index 500a0fade..626d46885 100644 --- a/app/views/mailer/proposal_notification_digest.html.erb +++ b/app/views/mailer/proposal_notification_digest.html.erb @@ -4,7 +4,8 @@

- <%= t('mailers.proposal_notification_digest.title') %> + <%= t('mailers.proposal_notification_digest.title', + org_name: Setting['org_name']) %>

@@ -17,7 +18,7 @@

- <%= link_to notification.notifiable.title, notification_url(notification) %> + <%= link_to notification.notifiable.title, notification_url(notification), style: "color: #2895F1; text-decoration: none;" %>

<%= notification.notifiable.proposal.title %> •  @@ -50,4 +51,18 @@ <% end %> + + + + + + + +
+

+ <%= t('mailers.proposal_notification_digest.unsubscribe', + account: link_to(t('mailers.proposal_notification_digest.unsubscribe_account'), + account_path, style: "color: #2895F1; text-decoration: none;")).html_safe %> +

+
diff --git a/app/views/proposal_notifications/new.html.erb b/app/views/proposal_notifications/new.html.erb index a5f829ecc..678e00088 100644 --- a/app/views/proposal_notifications/new.html.erb +++ b/app/views/proposal_notifications/new.html.erb @@ -1,5 +1,5 @@

-
+
<%= render 'shared/back_link' %>

<%= t("proposal_notifications.new.title") %>

@@ -7,13 +7,16 @@

<%= t("proposal_notifications.new.info_about_receivers_html", - count: @proposal.voters.count) %> - - <%= link_to t("proposal_notifications.new.proposal_page"), - proposal_path(@proposal) %> + count: @proposal.voters.count, + proposal_page: link_to(t("proposal_notifications.new.proposal_page"), + proposal_path(@proposal, anchor: "comments"))).html_safe %>

+
+
+
+
<%= form_for @notification do |f| %> <%= render "shared/errors", resource: @notification %> diff --git a/app/views/proposals/_comments.html.erb b/app/views/proposals/_comments.html.erb index 094814cf1..ed52b1b66 100644 --- a/app/views/proposals/_comments.html.erb +++ b/app/views/proposals/_comments.html.erb @@ -2,13 +2,6 @@
- <% if @notifications.blank? %> -

- <%= t("proposals.show.comments_title") %> - (<%= @proposal.comments_count %>) -

- <% end %> - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> <% if user_signed_in? %> diff --git a/app/views/proposals/_notifications.html.erb b/app/views/proposals/_notifications.html.erb index 44bb9f4a2..69389b2c5 100644 --- a/app/views/proposals/_notifications.html.erb +++ b/app/views/proposals/_notifications.html.erb @@ -1,6 +1,12 @@
+ <% if @notifications.blank? %> +
+ <%= t('proposals.show.no_notifications') %> +
+ <% end %> + <% @notifications.each do |notification| %>

<%= notification.title %>

<%= notification.created_at.to_date %>

diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 2153b23e5..3a9869d83 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -12,6 +12,11 @@
<%= render "shared/back_link" %> + <% if author_of?(@proposal, current_user) %> + <%= link_to t("proposals.show.send_notification"), new_proposal_notification_path(proposal_id: @proposal.id), + class: 'button hollow float-right' %> + <% end %> + <% if current_user && @proposal.editable_by?(current_user) %> <%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow float-right' do %> <%= t("proposals.show.edit_proposal_link") %> @@ -119,10 +124,8 @@ <% end %>
- <% if @notifications.present? %> - <%= render "proposals/filter_subnav" %> - <%= render "proposals/notifications" %> - <% end %> + <%= render "proposals/filter_subnav" %> + <%= render "proposals/notifications" %>
<%= render "proposals/comments" %> diff --git a/app/views/users/_proposals.html.erb b/app/views/users/_proposals.html.erb index a56b096f6..f50045635 100644 --- a/app/views/users/_proposals.html.erb +++ b/app/views/users/_proposals.html.erb @@ -9,7 +9,7 @@ <% if author? %> - <%= link_to t("users.proposals.send_message"), new_proposal_notification_path(proposal_id: proposal.id), + <%= link_to t("users.proposals.send_notification"), new_proposal_notification_path(proposal_id: proposal.id), class: 'button hollow' %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index eb28cf18d..64ee8fb6f 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -356,7 +356,6 @@ en: other: "%{count} comments" zero: No comments comments_tab: Comments - comments_title: Comments edit_proposal_link: Edit flag: This proposal has been flagged as inappropriate by several users. login_to_comment: You must %{signin} or %{signup} to leave a comment. @@ -365,6 +364,8 @@ en: retired_warning_link_to_explanation: Read the explanation before voting for it. retired: Proposal retired by the author share: Share + send_notification: Send notification + no_notifications: "This proposal has any notifications." update: form: submit_button: Save changes @@ -374,7 +375,7 @@ en: title_label: "Title" body_label: "Message" submit_button: "Send message" - info_about_receivers_html: "This message will be send to %{count} people and it will be visible in " + info_about_receivers_html: "This message will be send to %{count} people and it will be visible in %{proposal_page}.
Message are not sent immediately, users will receive periodically an email with all proposal notifications." proposal_page: "the proposal's page" show: back: "Go back to my activity" @@ -539,7 +540,7 @@ en: private_activity: This user decided to keep the activity list private send_private_message: "Send private message" proposals: - send_message: "Send message" + send_notification: "Send notification" retire: "Retire" retired: "Retired" votes: diff --git a/config/locales/es.yml b/config/locales/es.yml index bf46a8258..a3922ef5f 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -357,7 +357,6 @@ es: other: "%{count} Comentarios" zero: Sin comentarios comments_tab: Comentarios - comments_title: Comentarios edit_proposal_link: Editar propuesta flag: Esta propuesta ha sido marcada como inapropiada por varios usuarios. login_to_comment: Necesitas %{signin} o %{signup} para comentar. @@ -365,7 +364,9 @@ es: retired_warning: "El autor de esta propuesta considera que ya no debe seguir recogiendo apoyos." retired_warning_link_to_explanation: Revisa su explicación antes de apoyarla. retired: Propuesta retirada por el autor + send_notification: Enviar notificación share: Compartir + no_notifications: "Esta propuesta no tiene notificaciones." update: form: submit_button: Guardar cambios @@ -375,7 +376,7 @@ es: title_label: "Título" body_label: "Mensaje" submit_button: "Enviar mensaje" - info_about_receivers_html: "Este mensaje se enviará a %{count} usuarios y se publicará en " + info_about_receivers_html: "Este mensaje se enviará a %{count} usuarios y se publicará en %{proposal_page}.
El mensaje no se enviará inmediatamente, los usuarios recibirán periódicamente un email con todas las notificaciones de propuestas." proposal_page: "la página de la propuesta" show: back: "Volver a mi actividad" @@ -540,7 +541,7 @@ es: private_activity: Este usuario ha decidido mantener en privado su lista de actividades send_private_message: "Enviar un mensaje privado" proposals: - send_message: "Enviar mensaje" + send_notification: "Enviar notificación" retire: "Retirar" retired: "Retirada" votes: diff --git a/config/locales/mailers.en.yml b/config/locales/mailers.en.yml index 7270f81ae..c2e2b5d85 100755 --- a/config/locales/mailers.en.yml +++ b/config/locales/mailers.en.yml @@ -1,6 +1,7 @@ --- en: mailers: + no_reply: "This message was sent from an email address that does not accept replies." comment: hi: Hi new_comment_by_html: There is a new comment from %{commenter} @@ -31,11 +32,16 @@ en: subject: "Your investment project '%{code}' has been marked as unfeasible" unfeasible_html: "From the Madrid City Council we want to thank you for your participation in the participatory budgets of the city of Madrid. We regret to inform you that your proposal '%{title}' will be excluded from this participatory process for the following reason:" proposal_notification_digest: - title: You received the following notifications - share: Share + title: "Proposal notifications in %{org_name}" + share: Share proposal comment: Comment proposal + unsubscribe: "If you don't want receive proposal's notification, visit %{account} and unckeck 'Receive a summary of proposal notifications'." + unsubscribe_account: My account direct_message_for_receiver: subject: "You have received a new private message" reply: Reply to %{sender} + unsubscribe: "If you don't want receive direct messages, visit %{account} and unckeck 'Receive emails about direct messages'." + unsubscribe_account: My account direct_message_for_sender: - subject: "You have send a new private message" \ No newline at end of file + subject: "You have send a new private message" + title_html: "You have send a new private message to %{receiver} with the content:" \ No newline at end of file diff --git a/config/locales/mailers.es.yml b/config/locales/mailers.es.yml index 288fa189e..bde81ec86 100644 --- a/config/locales/mailers.es.yml +++ b/config/locales/mailers.es.yml @@ -1,6 +1,7 @@ --- es: mailers: + no_reply: "Este mensaje se ha enviado desde una dirección de correo electrónico que no admite respuestas." comment: hi: Hola new_comment_by_html: Hay un nuevo comentario de %{commenter} en @@ -31,11 +32,16 @@ es: subject: "Tu propuesta de inversión '%{code}' ha sido marcada como inviable" unfeasible_html: "Desde el Ayuntamiento de Madrid queremos agradecer tu participación en los Presupuestos Participativos de la ciudad de Madrid. Lamentamos informarte de que tu propuesta '%{title}' quedará excluida de este proceso participativo por el siguiente motivo:" proposal_notification_digest: - title: Has recibido las siguientes notificaciones - share: Compartir + title: "Notificaciones de propuestas en %{org_name}" + share: Compartir propuesta comment: Comentar propuesta + unsubscribe: "Si no quieres recibir notificaciones de propuestas, puedes entrar en %{account} y desmarcar la opción 'Recibir resumen de notificaciones sobre propuestas'." + unsubscribe_account: Mi cuenta direct_message_for_receiver: subject: "Has recibido un nuevo mensaje privado" reply: Responder a %{sender} + unsubscribe: "Si no quieres recibir mensajes privados, puedes entrar en %{account} y desmarcar la opción 'Recibir emails con mensajes directos'." + unsubscribe_account: Mi cuenta direct_message_for_sender: - subject: "Has enviado un nuevo mensaje privado" \ No newline at end of file + subject: "Has enviado un nuevo mensaje privado" + title_html: "Has enviado un nuevo mensaje privado a %{receiver} con el siguiente contenido:" \ No newline at end of file diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 000000000..61137912d --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +describe ApplicationHelper do + + describe "#author_of?" do + it "should be true if user is the author" do + user = create(:user) + proposal = create(:proposal, author: user) + expect(author_of?(proposal, user)).to eq true + end + + it "should be false if user is not the author" do + user = create(:user) + proposal = create(:proposal) + expect(author_of?(proposal, user)).to eq false + end + + it "should be false if user or authorable is nil" do + user = create(:user) + proposal = create(:proposal) + + expect(author_of?(nil, user)).to eq false + expect(author_of?(proposal, nil)).to eq false + end + end + +end \ No newline at end of file