Merge branch 'proposal-notifications' of github.com:AyuntamientoMadrid/participacion into proposal-notifications

This commit is contained in:
rgarcia
2016-06-16 11:23:23 +02:00
17 changed files with 127 additions and 35 deletions

View File

@@ -253,6 +253,10 @@ a {
max-width: none;
}
.button.float-right ~ .button.float-right {
margin: 0 $line-height/2;
}
// 02. Header
// ----------

View File

@@ -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

View File

@@ -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

View File

@@ -32,6 +32,10 @@
<td style="text-align: center; border-top: 1px solid #dadfe1; padding-top: 20px;">
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; margin: 0;padding: 0;line-height: 1.5em;color: #797f7f; font-size: 12px;">
<%= setting['org_name'] %></p>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; margin: 0;padding: 0;line-height: 1.5em;color: #222; font-size: 10px; margin-top: 12px;">
<%= t('mailers.no_reply') %></p>
</td>
</tr>
</tbody>

View File

@@ -20,4 +20,18 @@
</tr>
</tbody>
</table>
<table style="width: 100%;">
<tbody>
<tr>
<td style="padding-left: 10px;">
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px; margin: 0; font-style: italic; padding-bottom: 20px;">
<%= 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 %>
</p>
</td>
</tr>
</tbody>
</table>
</td>

View File

@@ -1,9 +1,13 @@
<td style="padding-bottom: 20px; padding-left: 10px;">
<p><%= @direct_message.receiver.name %></p>
<h1 style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;">
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; font-size: 20px;">
<%= t('mailers.direct_message_for_sender.title_html',
receiver: @direct_message.receiver.name ) %>
</p>
<h2 style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; font-size: 18px;">
<%= @direct_message.title %>
</h1>
</h2>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= @direct_message.body %>

View File

@@ -4,7 +4,8 @@
<tr>
<td style="padding-left: 10px;">
<h1 style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;">
<%= t('mailers.proposal_notification_digest.title') %>
<%= t('mailers.proposal_notification_digest.title',
org_name: Setting['org_name']) %>
</h1>
</td>
</tr>
@@ -17,7 +18,7 @@
<tr>
<td style="padding-bottom: 20px; padding-left: 10px;">
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 20px;font-weight: bold;line-height: 24px; margin: 0;">
<%= link_to notification.notifiable.title, notification_url(notification) %>
<%= link_to notification.notifiable.title, notification_url(notification), style: "color: #2895F1; text-decoration: none;" %>
</p>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px; margin-top: 0; color: #cccccc;">
<%= notification.notifiable.proposal.title %>&nbsp;&bull;&nbsp;
@@ -50,4 +51,18 @@
</tbody>
</table>
<% end %>
<table style="width: 100%;">
<tbody>
<tr>
<td style="padding-left: 10px;">
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px; margin: 0; font-style: italic; padding-bottom: 20px;">
<%= 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 %>
</p>
</td>
</tr>
</tbody>
</table>
</td>

View File

@@ -1,5 +1,5 @@
<div class="row">
<div class="small-12 medium-9 column">
<div class="small-12 column">
<%= render 'shared/back_link' %>
<h1><%= t("proposal_notifications.new.title") %></h1>
@@ -7,13 +7,16 @@
<div class="callout primary">
<p>
<%= 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 %>
</p>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-9 column">
<%= form_for @notification do |f| %>
<%= render "shared/errors", resource: @notification %>

View File

@@ -2,13 +2,6 @@
<section class="comments">
<div class="row">
<div id="comments" class="small-12 column">
<% if @notifications.blank? %>
<h2>
<%= t("proposals.show.comments_title") %>
<span class="js-comments-count">(<%= @proposal.comments_count %>)</span>
</h2>
<% end %>
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %>

View File

@@ -1,6 +1,12 @@
<div class="tabs-panel" id="tab-notifications">
<div class="row">
<div class="small-12 column">
<% if @notifications.blank? %>
<div class="callout primary text-center">
<%= t('proposals.show.no_notifications') %>
</div>
<% end %>
<% @notifications.each do |notification| %>
<h3><%= notification.title %></h3>
<p class="more-info"><%= notification.created_at.to_date %></p>

View File

@@ -12,6 +12,11 @@
<div class="small-12 medium-9 column">
<%= 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 %>
<div class="tabs-content" data-tabs-content="example-tabs">
<% if @notifications.present? %>
<%= render "proposals/filter_subnav" %>
<%= render "proposals/notifications" %>
<% end %>
<%= render "proposals/filter_subnav" %>
<%= render "proposals/notifications" %>
<div class="tabs-panel is-active" id="tab-comments">
<%= render "proposals/comments" %>

View File

@@ -9,7 +9,7 @@
<% if author? %>
<td class="text-center">
<%= 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' %>
</td>
<% end %>

View File

@@ -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 <strong>%{count} people</strong> and it will be visible in "
info_about_receivers_html: "This message will be send to <strong>%{count} people</strong> and it will be visible in %{proposal_page}.<br> 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:

View File

@@ -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 <strong>%{count} usuarios</strong> y se publicará en "
info_about_receivers_html: "Este mensaje se enviará a <strong>%{count} usuarios</strong> y se publicará en %{proposal_page}.<br> 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:

View File

@@ -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 <b>%{commenter}</b>
@@ -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 <strong>participatory budgets of the city of Madrid</strong>. We regret to inform you that your proposal <strong>'%{title}'</strong> 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"
subject: "You have send a new private message"
title_html: "You have send a new private message to <strong>%{receiver}</strong> with the content:"

View File

@@ -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 <b>%{commenter}</b> 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 <strong>Presupuestos Participativos de la ciudad de Madrid</strong>. Lamentamos informarte de que tu propuesta <strong>'%{title}'</strong> 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"
subject: "Has enviado un nuevo mensaje privado"
title_html: "Has enviado un nuevo mensaje privado a <strong>%{receiver}</strong> con el siguiente contenido:"

View File

@@ -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