diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb
index bfbe148..c3a16f8 100644
--- a/app/controllers/notifications_controller.rb
+++ b/app/controllers/notifications_controller.rb
@@ -1,6 +1,12 @@
class NotificationsController < ApplicationController
before_action :require_login
- before_action :set_notification
+ before_action :set_notification, only: [:deliver]
+
+ # GET /notifications
+ def index
+ @scheduled = Notification.where(status: 'scheduled').order(to_be_sent_on: :asc)
+ @sent = Notification.where(status: 'sent').order(sent_at: :desc)
+ end
# POST /notifications/1/deliver
def deliver
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 5bb562a..4636d6a 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -16,6 +16,7 @@
- <%= link_to t('navigation.members'), members_path %>
- <%= link_to t('navigation.board'), edit_board_path %>
+ - <%= link_to t('navigation.notifications'), notifications_path %>
-
<%= button_to sign_out_path, method: :delete do %>
Sign out of <%= current_user.email %>
diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb
new file mode 100644
index 0000000..f2cff23
--- /dev/null
+++ b/app/views/notifications/index.html.erb
@@ -0,0 +1,53 @@
+
<%= t('notifications.index.title') %>
+
+
+ <%= t('notifications.index.scheduled') %>
+
+
+ <%= t('notifications.attributes.to_be_sent_on') %> |
+ <%= t('notifications.attributes.template') %> |
+ <%= t('notifications.attributes.member') %> |
+ <%= t('members.show.contribution_actions') %> |
+
+ <% @scheduled.each do |notification| %>
+
+ <%= notification.to_be_sent_on %> |
+ <%= notification.template %> |
+ <%= link_to notification.member do %><%= notification.member.display_name %> <<%= notification.member.email %>><% end %> |
+
+ <% if notification.status == 'scheduled' %>
+ <%= form_with url: deliver_notification_path(notification) do |form| %>
+ <%= form.submit t('members.show.actions.deliver_notification') %>
+ <% end %>
+ <% end %>
+ |
+
+ <% end %>
+
+
+
+
+ <%= t('notifications.index.sent') %>
+
+
+ <%= t('notifications.attributes.to_be_sent_on') %> |
+ <%= t('notifications.attributes.template') %> |
+ <%= t('notifications.attributes.status') %> |
+ <%= t('members.show.contribution_actions') %> |
+
+ <% @sent.each do |notification| %>
+
+ <%= notification.to_be_sent_on %> |
+ <%= notification.template %> |
+ <%= notification_status(notification.status) %> |
+
+ <% if notification.status == 'scheduled' %>
+ <%= form_with url: deliver_notification_path(notification) do |form| %>
+ <%= form.submit t('members.show.actions.deliver_notification') %>
+ <% end %>
+ <% end %>
+ |
+
+ <% end %>
+
+
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index c900b30..7fe654c 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -4,6 +4,8 @@ pt:
negative: "Não"
navigation:
members: "Lista de membros"
+ board: "Direcção"
+ notifications: "Notificações"
members:
delete:
confirmation_message: |
@@ -68,14 +70,6 @@ pt:
unemployed: "Desempregado"
student: "Estudante"
retired: "Reformado"
- notifications:
- attributes:
- to_be_sent_on: Data de envio
- template: Modelo
- status: Estado
- status:
- sent: Enviada
- scheduled: Agendada
contributions:
attributes:
amount: Montante
@@ -121,3 +115,15 @@ pt:
warning: |
Atenção: qualquer endereço que ficar omisso verá a sua conta suspensa e
deixará de poder aceder a este sistema.
+ notifications:
+ index:
+ title: "Notificações"
+ scheduled: "Agendadas"
+ sent: "Enviadas"
+ attributes:
+ to_be_sent_on: Data de envio
+ template: Modelo
+ status: Estado
+ status:
+ sent: Enviada
+ scheduled: Agendada
diff --git a/config/routes.rb b/config/routes.rb
index 95b06d8..96882fd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -19,7 +19,7 @@ Rails.application.routes.draw do
end
end
- resources :notifications, only: [] do
+ resources :notifications, only: [:index] do
member do
post :deliver
end