mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-05 10:15:09 +02:00
Notifications template CRUD
This commit is contained in:
parent
0052b54967
commit
9c35dbc7a6
47
app/controllers/check_notifications_controller.rb
Normal file
47
app/controllers/check_notifications_controller.rb
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||||
|
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||||
|
|
||||||
|
class CheckNotificationsController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
before_action :set_notification, except: [:create]
|
||||||
|
|
||||||
|
def create
|
||||||
|
check = Check.find(params[:check_id])
|
||||||
|
@notification = check.notifications.build(notification_params)
|
||||||
|
authorize @notification
|
||||||
|
|
||||||
|
if @notification.save
|
||||||
|
flash[:notice] = "Your notification has been saved."
|
||||||
|
redirect_to check_path
|
||||||
|
else
|
||||||
|
flash.now[:alert] = "An error occured."
|
||||||
|
render "checks/edit"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@notification.destroy!
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_notification
|
||||||
|
# joins the check because policy use the check relation
|
||||||
|
@notification = Notification
|
||||||
|
.joins(:check)
|
||||||
|
.find_by!(id: params[:id], check_id: params[:check_id])
|
||||||
|
authorize @notification
|
||||||
|
end
|
||||||
|
|
||||||
|
def notification_params
|
||||||
|
params.require(:notification).permit(:channel, :recipient, :interval)
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_path
|
||||||
|
edit_check_path(check_id: params[:check_id])
|
||||||
|
end
|
||||||
|
end
|
|
@ -35,10 +35,10 @@ class ChecksController < ApplicationController
|
||||||
authorize @check
|
authorize @check
|
||||||
|
|
||||||
if @check.save
|
if @check.save
|
||||||
flash[:notice] = t(".saved")
|
flash[:notice] = t("checks.created", scope: :flashes)
|
||||||
redirect_to checks_path
|
redirect_to checks_path
|
||||||
else
|
else
|
||||||
flash.now[:alert] = t(".invalid")
|
flash.now[:alert] = t("checks.invalid", scope: :flashes)
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -49,10 +49,10 @@ class ChecksController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @check.update(update_check_params)
|
if @check.update(update_check_params)
|
||||||
flash[:notice] = "Your check has been updated."
|
flash[:notice] = t("checks.updated", scope: :flashes)
|
||||||
redirect_to checks_path
|
redirect_to checks_path
|
||||||
else
|
else
|
||||||
flash.now[:alert] = "An error occured."
|
flash.now[:alert] = t("checks.invalid", scope: :flashes)
|
||||||
build_empty_notification
|
build_empty_notification
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ class ChecksController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
@check.destroy!
|
@check.destroy!
|
||||||
|
|
||||||
flash[:notice] = "Your check has been destroyed."
|
flash[:notice] = t("checks.destroyed", scope: :flashes)
|
||||||
redirect_to checks_path
|
redirect_to checks_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,45 +3,62 @@
|
||||||
|
|
||||||
class NotificationsController < ApplicationController
|
class NotificationsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :set_notification, except: [:create]
|
before_action :set_notification, except: [:index, :new, :create]
|
||||||
|
after_action :verify_authorized, except: :index
|
||||||
|
after_action :verify_policy_scoped, only: :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@notifications = policy_scope(Notification).order(checks_count: :desc)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new;
|
||||||
|
@notification = Notification.new
|
||||||
|
authorize @notification
|
||||||
|
@notification.recipient = current_user.email
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
check = Check.find(params[:check_id])
|
@notification = Notification.new(notification_params)
|
||||||
@notification = check.notifications.build(notification_params)
|
@notification.user = current_user
|
||||||
authorize @notification
|
authorize @notification
|
||||||
|
|
||||||
if @notification.save
|
if @notification.save
|
||||||
flash[:notice] = "Your notification has been saved."
|
flash[:notice] = t("notifications.created", scope: :flashes)
|
||||||
redirect_to check_path
|
redirect_to notifications_path
|
||||||
else
|
else
|
||||||
flash.now[:alert] = "An error occured."
|
flash.now[:alert] = t("notifications.invalid", scope: :flashes)
|
||||||
render "checks/edit"
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def edit; end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @notification.update(notification_params)
|
||||||
|
flash[:notice] = t("notifications.updated", scope: :flashes)
|
||||||
|
redirect_to notifications_path
|
||||||
|
else
|
||||||
|
flash.now[:alert] = t("notifications.error", scope: :flashes)
|
||||||
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@notification.destroy!
|
@notification.destroy!
|
||||||
|
|
||||||
respond_to do |format|
|
flash[:notice] = t("notifications.destroyed", scope: :flashes)
|
||||||
format.js
|
redirect_to notifications_path
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_notification
|
def set_notification
|
||||||
# joins the check because policy use the check relation
|
@notification = Notification.find(params[:id])
|
||||||
@notification = Notification
|
|
||||||
.joins(:check)
|
|
||||||
.find_by!(id: params[:id], check_id: params[:check_id])
|
|
||||||
authorize @notification
|
authorize @notification
|
||||||
end
|
end
|
||||||
|
|
||||||
def notification_params
|
def notification_params
|
||||||
params.require(:notification).permit(:channel, :recipient, :interval)
|
params.require(:notification).permit(:label, :recipient, :interval)
|
||||||
end
|
|
||||||
|
|
||||||
def check_path
|
|
||||||
edit_check_path(check_id: params[:check_id])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
51
app/frontend/scss/components/callouts.scss
Normal file
51
app/frontend/scss/components/callouts.scss
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Taken from Bootstrap 4 documentation
|
||||||
|
|
||||||
|
.bd-callout {
|
||||||
|
padding: 1.25rem;
|
||||||
|
margin-top: 1.25rem;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-left-width: .25rem;
|
||||||
|
border-radius: .25rem
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout h4 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: .25rem
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout p:last-child {
|
||||||
|
margin-bottom: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout code {
|
||||||
|
border-radius: .25rem
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout+.bd-callout {
|
||||||
|
margin-top: -.25rem
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-info {
|
||||||
|
border-left-color: #5bc0de
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-info h4 {
|
||||||
|
color: #5bc0de
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-warning {
|
||||||
|
border-left-color: #f0ad4e
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-warning h4 {
|
||||||
|
color: #f0ad4e
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-danger {
|
||||||
|
border-left-color: #d9534f
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-callout-danger h4 {
|
||||||
|
color: #d9534f
|
||||||
|
}
|
8
app/frontend/scss/components/notifications.scss
Normal file
8
app/frontend/scss/components/notifications.scss
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||||
|
// License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||||
|
|
||||||
|
.notifications-table {
|
||||||
|
.action a {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,5 +5,7 @@
|
||||||
@import '~bootstrap/scss/bootstrap';
|
@import '~bootstrap/scss/bootstrap';
|
||||||
@import 'layout';
|
@import 'layout';
|
||||||
@import 'icons';
|
@import 'icons';
|
||||||
|
@import 'components/callouts';
|
||||||
@import 'components/users';
|
@import 'components/users';
|
||||||
@import 'components/checks';
|
@import 'components/checks';
|
||||||
|
@import 'components/notifications';
|
||||||
|
|
8
app/helpers/check_notifications_helper.rb
Normal file
8
app/helpers/check_notifications_helper.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||||
|
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||||
|
|
||||||
|
module CheckNotificationsHelper
|
||||||
|
def recipient_col_class
|
||||||
|
many_channels_available? ? "col-md-7" : "col-md-9"
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,12 +1,5 @@
|
||||||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
|
||||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
|
||||||
|
|
||||||
module NotificationsHelper
|
module NotificationsHelper
|
||||||
def many_channels_available?
|
def many_channels_available?
|
||||||
Notification.channels.many?
|
Notification.channels.many?
|
||||||
end
|
end
|
||||||
|
|
||||||
def recipient_col_class
|
|
||||||
many_channels_available? ? "col-md-7" : "col-md-9"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
|
|
||||||
class Notification < ApplicationRecord
|
class Notification < ApplicationRecord
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :check_notifications
|
has_many :check_notifications, dependent: :destroy
|
||||||
has_many :checks, through: :notifications
|
has_many :checks, -> { order(domain_expires_at: :asc) }, through: :check_notifications
|
||||||
|
|
||||||
enum channel: [:email]
|
enum channel: [:email]
|
||||||
|
|
||||||
|
|
24
app/policies/check_notification_policy.rb
Normal file
24
app/policies/check_notification_policy.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||||
|
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||||
|
|
||||||
|
class CheckNotificationPolicy < ApplicationPolicy
|
||||||
|
class Scope < Scope
|
||||||
|
def resolve
|
||||||
|
scope.joins(:check).where(checks: { user: user })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy?
|
||||||
|
check_owner?
|
||||||
|
end
|
||||||
|
|
||||||
|
def show?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_owner?
|
||||||
|
record.check.user == user
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,21 +4,25 @@
|
||||||
class NotificationPolicy < ApplicationPolicy
|
class NotificationPolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
def resolve
|
||||||
scope.joins(:check).where(checks: { user: user })
|
scope.where(user: user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
def create?
|
||||||
check_owner?
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def update?
|
||||||
false
|
owner?
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy?
|
||||||
|
owner?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_owner?
|
def owner?
|
||||||
record.check.user == user
|
record.user == user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,6 +53,5 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<%= f.button :submit, class: "btn-primary mt-5" %>
|
<%= f.button :submit, class: "btn-primary mt-5" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -7,16 +7,20 @@
|
||||||
<th scope="col"></th>
|
<th scope="col"></th>
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
<%= t(".th.domain") %>
|
<%= t(".th.domain") %>
|
||||||
<span class="sort-links mx-sm-2 text-nowrap">
|
<% unless defined?(skip_sort) %>
|
||||||
<%== checks_sort_links(:domain) %>
|
<span class="sort-links mx-sm-2 text-nowrap">
|
||||||
</span>
|
<%== checks_sort_links(:domain) %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
<span class="d-none d-sm-inline"><%= t(".th.expiry_date") %></span>
|
<span class="d-none d-sm-inline"><%= t(".th.expiry_date") %></span>
|
||||||
<span class="d-inline d-sm-none"><%= t(".th.expiry_date_short") %></span>
|
<span class="d-inline d-sm-none"><%= t(".th.expiry_date_short") %></span>
|
||||||
<span class="sort-links mx-sm-2 text-nowrap">
|
<% unless defined?(skip_sort) %>
|
||||||
<%== checks_sort_links(:domain_expires_at) %>
|
<span class="sort-links mx-sm-2 text-nowrap">
|
||||||
</span>
|
<%== checks_sort_links(:domain_expires_at) %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" class="text-right"><%= t(".th.edit") %></th>
|
<th scope="col" class="text-right"><%= t(".th.edit") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -48,4 +52,4 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= paginate @checks %>
|
<%= paginate checks unless defined?(skip_pagination)%>
|
||||||
|
|
13
app/views/notifications/_form.html.erb
Normal file
13
app/views/notifications/_form.html.erb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
|
<%= simple_form_for(notification) do |f| %>
|
||||||
|
<%= f.input :label, hint: t(".label_hint")%>
|
||||||
|
|
||||||
|
<%= f.input :recipient, as: :email,
|
||||||
|
input_html: { autocapitalize: :none, autocorrect: :off }
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%= f.input :interval, as: :integer, required: true %>
|
||||||
|
|
||||||
|
<%= f.button :submit, class: "btn-primary mt-3" %>
|
||||||
|
<% end %>
|
46
app/views/notifications/_table.html.erb
Normal file
46
app/views/notifications/_table.html.erb
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
|
<div class="mb-4 table-responsive">
|
||||||
|
<table class="table notifications-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">
|
||||||
|
<%= Notification.human_attribute_name("label") %>
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
<%= Notification.human_attribute_name("recipient") %>
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
<%= Notification.human_attribute_name("interval") %>
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
<%= Notification.human_attribute_name("checks_count") %>
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="text-right"><%= t(".th.edit") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% notifications.each do |notification| %>
|
||||||
|
<tr class="notification-row">
|
||||||
|
<td>
|
||||||
|
<strong><%= notification.label %></strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= notification.recipient %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= t(".interval_in_days", count: notification.interval) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= notification.checks_count %>
|
||||||
|
</td>
|
||||||
|
<td class="action text-right">
|
||||||
|
<%= link_to edit_notification_path(notification), "data-turbolinks" => false do %>
|
||||||
|
<%== Octicons::Octicon.new("pencil").to_svg %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
27
app/views/notifications/edit.html.erb
Normal file
27
app/views/notifications/edit.html.erb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-12 col-lg-10">
|
||||||
|
<h1><%= t(".title") %></h1>
|
||||||
|
|
||||||
|
<%= render "form", notification: @notification %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-5 justify-content-center">
|
||||||
|
<div class="col-12 col-lg-10">
|
||||||
|
<h4><%= t(".checks", count: @notification.checks_count) %></h4>
|
||||||
|
<% if @notification.checks_count.positive? %>
|
||||||
|
<%= render "checks/table", checks: @notification.checks, skip_sort: true, skip_pagination: true %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-5 mb-3 justify-content-center">
|
||||||
|
<div class="col-12 col-lg-10">
|
||||||
|
<%= button_to(t("helpers.submit.notification.delete"), notification_path(@notification), class: "btn btn-danger", method: :delete,
|
||||||
|
data: { confirm: t(".destroy_confirmation", count: @notification.checks_count) }) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
22
app/views/notifications/index.html.erb
Normal file
22
app/views/notifications/index.html.erb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-12 col-lg-10 col-xl-9">
|
||||||
|
<% if @notifications.empty? %>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<%= t(".no_notification_yet_html", new_path: new_notification_path) %>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="row justify-content-md-end">
|
||||||
|
<%= link_to("Ajouter une notification", new_notification_path, class: "btn btn-primary") %>
|
||||||
|
</div>
|
||||||
|
<h1 class="mb-3 mb-sm-5"><%= t(".title") %></h1>
|
||||||
|
<%= render "table", notifications: @notifications %>
|
||||||
|
<% end %>
|
||||||
|
<div class="bd-callout bd-callout-info">
|
||||||
|
<p><%= t(".explanation") %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
11
app/views/notifications/new.html.erb
Normal file
11
app/views/notifications/new.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-12 col-lg-10">
|
||||||
|
<h1><%= t(".title") %></h1>
|
||||||
|
|
||||||
|
<%= render "form", notification: @notification %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -24,6 +24,9 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<%= link_to(t(".GitHub"), "https://github.com/Evolix/chexpire", class: "nav-link") %>
|
<%= link_to(t(".GitHub"), "https://github.com/Evolix/chexpire", class: "nav-link") %>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<%= link_to(t(".my_notifications"), notifications_path, class: "nav-link") %>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,28 @@ en:
|
||||||
notifications:
|
notifications:
|
||||||
recipient: john@example.com
|
recipient: john@example.com
|
||||||
|
|
||||||
|
helpers:
|
||||||
|
submit:
|
||||||
|
check:
|
||||||
|
create: "Create"
|
||||||
|
update: "Update"
|
||||||
|
notification:
|
||||||
|
create: "Create"
|
||||||
|
update: "Update"
|
||||||
|
delete: "Delete"
|
||||||
|
|
||||||
flashes:
|
flashes:
|
||||||
user_not_authorized: "You are not authorized to access to this resource."
|
user_not_authorized: "You are not authorized to access to this resource."
|
||||||
|
checks:
|
||||||
|
create: The check has been saved.
|
||||||
|
updated: The check has been updated.
|
||||||
|
invalid: Please check the form.
|
||||||
|
destroyed: The check has been destroyed.
|
||||||
|
notifications:
|
||||||
|
created: The notification has been created.
|
||||||
|
updated: The notification has been updated."
|
||||||
|
destroyed: The notification has been destroyed.
|
||||||
|
invalid: Please check the form.
|
||||||
|
|
||||||
notifications_mailer:
|
notifications_mailer:
|
||||||
domain_expires_soon:
|
domain_expires_soon:
|
||||||
|
@ -68,6 +88,7 @@ en:
|
||||||
my_checks: "My checks"
|
my_checks: "My checks"
|
||||||
new_domain_check: "New domain check"
|
new_domain_check: "New domain check"
|
||||||
new_ssl_check: "New SSL check"
|
new_ssl_check: "New SSL check"
|
||||||
|
my_notifications: "My notifications"
|
||||||
sign_up: "Sign up"
|
sign_up: "Sign up"
|
||||||
sign_in: "Log in"
|
sign_in: "Log in"
|
||||||
sign_out: "Log out"
|
sign_out: "Log out"
|
||||||
|
@ -143,3 +164,36 @@ en:
|
||||||
zero: "Last check successful: today"
|
zero: "Last check successful: today"
|
||||||
one: "Last check successful: yesterday"
|
one: "Last check successful: yesterday"
|
||||||
other: "Last check successful %{count} days ago"
|
other: "Last check successful %{count} days ago"
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
index:
|
||||||
|
title: "List of your notifications"
|
||||||
|
no_notification_yet_html: |
|
||||||
|
You have not set up a notification yet.
|
||||||
|
<a href="%{new_path}">Create your first notification</a>.
|
||||||
|
explanation: |
|
||||||
|
For each of your checks,
|
||||||
|
you can associate one or more notifications that you will receive
|
||||||
|
by email at the interval of your choice before the expiration date.
|
||||||
|
table:
|
||||||
|
th:
|
||||||
|
edit: Edit
|
||||||
|
interval_in_days:
|
||||||
|
one: 1 day
|
||||||
|
other: "%{count} days"
|
||||||
|
edit:
|
||||||
|
title: "Edit the notification"
|
||||||
|
checks:
|
||||||
|
zero: No check associated check.
|
||||||
|
one: Check associated
|
||||||
|
other: Checks associated
|
||||||
|
destroy_confirmation:
|
||||||
|
zero: "Are you sure ?"
|
||||||
|
one: |
|
||||||
|
Are you sure ?
|
||||||
|
You won't receive this notification for the associated check.
|
||||||
|
other: |
|
||||||
|
Are you sure ?
|
||||||
|
You won't receive this notification for the associated checks.
|
||||||
|
form:
|
||||||
|
label_hint: This label allows you to identify this notification and associate it with a check.
|
||||||
|
|
|
@ -13,8 +13,10 @@ fr:
|
||||||
domain_updated_at: "Date de modification"
|
domain_updated_at: "Date de modification"
|
||||||
domain_expires_at: "Date d'expiration"
|
domain_expires_at: "Date d'expiration"
|
||||||
notification:
|
notification:
|
||||||
|
label: Étiquette
|
||||||
interval: Délai
|
interval: Délai
|
||||||
recipient: Destinataire
|
recipient: Destinataire
|
||||||
|
checks_count: Vérifications
|
||||||
user:
|
user:
|
||||||
tos_accepted: "Conditions d'utilisation"
|
tos_accepted: "Conditions d'utilisation"
|
||||||
notifications_enabled: "Notifications activées"
|
notifications_enabled: "Notifications activées"
|
||||||
|
@ -27,6 +29,10 @@ fr:
|
||||||
check:
|
check:
|
||||||
create: "Créer"
|
create: "Créer"
|
||||||
update: "Valider"
|
update: "Valider"
|
||||||
|
notification:
|
||||||
|
create: "Créer"
|
||||||
|
update: "Modifier"
|
||||||
|
delete: "Supprimer la notification"
|
||||||
page_entries_info:
|
page_entries_info:
|
||||||
one_page:
|
one_page:
|
||||||
display_entries:
|
display_entries:
|
||||||
|
@ -71,6 +77,16 @@ fr:
|
||||||
|
|
||||||
flashes:
|
flashes:
|
||||||
user_not_authorized: "Vous n'êtes pas autorisé•e à accéder à cette ressouce."
|
user_not_authorized: "Vous n'êtes pas autorisé•e à accéder à cette ressouce."
|
||||||
|
checks:
|
||||||
|
create: La vérification est enregistrée.
|
||||||
|
updated: La vérification est mise à jour.
|
||||||
|
invalid: Veuillez vérifier le formulaire.
|
||||||
|
destroyed: La vérification est supprimée.
|
||||||
|
notifications:
|
||||||
|
created: La notification est créée.
|
||||||
|
updated: "La notification est mise à jour."
|
||||||
|
destroyed: La notification est supprimée.
|
||||||
|
invalid: Veuillez vérifier le formulaire.
|
||||||
|
|
||||||
notifications_mailer:
|
notifications_mailer:
|
||||||
domain_expires_soon:
|
domain_expires_soon:
|
||||||
|
@ -101,6 +117,7 @@ fr:
|
||||||
my_checks: "Mes vérifications"
|
my_checks: "Mes vérifications"
|
||||||
new_domain_check: "Nouveau nom de domaine"
|
new_domain_check: "Nouveau nom de domaine"
|
||||||
new_ssl_check: "Nouveau certificat SSL"
|
new_ssl_check: "Nouveau certificat SSL"
|
||||||
|
my_notifications: "Mes notifications"
|
||||||
sign_up: "Enregistrement"
|
sign_up: "Enregistrement"
|
||||||
sign_in: "Connexion"
|
sign_in: "Connexion"
|
||||||
sign_out: "Déconnexion"
|
sign_out: "Déconnexion"
|
||||||
|
@ -138,10 +155,6 @@ fr:
|
||||||
ssl:
|
ssl:
|
||||||
title: Nouvelle vérification d'un certificat SSL
|
title: Nouvelle vérification d'un certificat SSL
|
||||||
|
|
||||||
create:
|
|
||||||
saved: La vérification est enregistrée.
|
|
||||||
invalid: Veuillez vérifier le formulaire.
|
|
||||||
|
|
||||||
filters:
|
filters:
|
||||||
kind_domain: Domaine
|
kind_domain: Domaine
|
||||||
kind_ssl: SSL
|
kind_ssl: SSL
|
||||||
|
@ -176,3 +189,38 @@ fr:
|
||||||
zero: "Dernière vérification réussie : aujourd'hui"
|
zero: "Dernière vérification réussie : aujourd'hui"
|
||||||
one: "Dernière vérification réussie : hier"
|
one: "Dernière vérification réussie : hier"
|
||||||
other: "Dernière vérification réussie il y a %{count} jours"
|
other: "Dernière vérification réussie il y a %{count} jours"
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
index:
|
||||||
|
title: "Liste de vos notifications"
|
||||||
|
no_notification_yet_html: |
|
||||||
|
Vous n'avez pas encore créé de notification.
|
||||||
|
<a href="%{new_domain_path}">Créez votre première notification</a>.
|
||||||
|
explanation: |
|
||||||
|
Pour chacune de vos vérifications,
|
||||||
|
vous pouvez associer une ou plusieurs notifications que vous recevrez
|
||||||
|
par email un certain nombre de jours avant la date d'expiration.
|
||||||
|
table:
|
||||||
|
th:
|
||||||
|
edit: Modifier
|
||||||
|
interval_in_days:
|
||||||
|
one: 1 jour
|
||||||
|
other: "%{count} jours"
|
||||||
|
new:
|
||||||
|
title: Nouvelle notification
|
||||||
|
edit:
|
||||||
|
title: "Modification d'une notification"
|
||||||
|
checks:
|
||||||
|
zero: Aucune vérification associée.
|
||||||
|
one: Vérification associée
|
||||||
|
other: Vérifications associées
|
||||||
|
destroy_confirmation:
|
||||||
|
zero: "Confirmez-vous la suppression de cette notification ?"
|
||||||
|
one: |
|
||||||
|
Confirmez-vous la suppression ?
|
||||||
|
Vous ne recevrez plus la notification associée à cette vérification.
|
||||||
|
other: |
|
||||||
|
Confirmez-vous la suppression ?
|
||||||
|
Vous ne recevrez plus les notifications associées à ces vérifications.
|
||||||
|
form:
|
||||||
|
label_hint: Ce nom vous permet d'identifier cette notification pour l'associer à une vérification.
|
||||||
|
|
|
@ -7,12 +7,11 @@ Rails.application.routes.draw do
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
|
|
||||||
resources :checks, except: [:show] do
|
resources :checks, except: [:show] do
|
||||||
resources :notifications, only: [:destroy]
|
resources :check_notifications, only: [:destroy]
|
||||||
collection do
|
|
||||||
post :supports, format: :json
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :notifications, except: [:show]
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
root to: "pages#home"
|
root to: "pages#home"
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ end
|
||||||
# == Route Map
|
# == Route Map
|
||||||
#
|
#
|
||||||
# Prefix Verb URI Pattern Controller#Action
|
# Prefix Verb URI Pattern Controller#Action
|
||||||
# check_notification DELETE /checks/:check_id/notifications/:id(.:format) notifications#destroy
|
# check_check_notification DELETE /checks/:check_id/check_notifications/:id(.:format) check_notifications#destroy
|
||||||
# supports_checks POST /checks/supports(.:format) checks#supports
|
# supports_checks POST /checks/supports(.:format) checks#supports
|
||||||
# checks GET /checks(.:format) checks#index
|
# checks GET /checks(.:format) checks#index
|
||||||
# POST /checks(.:format) checks#create
|
# POST /checks(.:format) checks#create
|
||||||
|
@ -31,6 +30,13 @@ end
|
||||||
# check PATCH /checks/:id(.:format) checks#update
|
# check PATCH /checks/:id(.:format) checks#update
|
||||||
# PUT /checks/:id(.:format) checks#update
|
# PUT /checks/:id(.:format) checks#update
|
||||||
# DELETE /checks/:id(.:format) checks#destroy
|
# DELETE /checks/:id(.:format) checks#destroy
|
||||||
|
# notifications GET /notifications(.:format) notifications#index
|
||||||
|
# POST /notifications(.:format) notifications#create
|
||||||
|
# new_notification GET /notifications/new(.:format) notifications#new
|
||||||
|
# edit_notification GET /notifications/:id/edit(.:format) notifications#edit
|
||||||
|
# notification PATCH /notifications/:id(.:format) notifications#update
|
||||||
|
# PUT /notifications/:id(.:format) notifications#update
|
||||||
|
# DELETE /notifications/:id(.:format) notifications#destroy
|
||||||
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
|
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
|
||||||
# user_session POST /users/sign_in(.:format) devise/sessions#create
|
# user_session POST /users/sign_in(.:format) devise/sessions#create
|
||||||
# destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
|
# destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
|
||||||
|
@ -56,7 +62,7 @@ end
|
||||||
# rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
|
# rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
|
||||||
# update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
|
# update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
|
||||||
# rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
|
# rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
|
||||||
#
|
#
|
||||||
# Routes for LetterOpenerWeb::Engine:
|
# Routes for LetterOpenerWeb::Engine:
|
||||||
# clear_letters DELETE /clear(.:format) letter_opener_web/letters#clear
|
# clear_letters DELETE /clear(.:format) letter_opener_web/letters#clear
|
||||||
# delete_letter DELETE /:id(.:format) letter_opener_web/letters#destroy
|
# delete_letter DELETE /:id(.:format) letter_opener_web/letters#destroy
|
||||||
|
|
10
test/controllers/check_notifications_controller_test.rb
Normal file
10
test/controllers/check_notifications_controller_test.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||||
|
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||||
|
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class CheckNotificationsControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
|
@ -1,7 +1,4 @@
|
||||||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
require 'test_helper'
|
||||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
|
||||||
|
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class NotificationsControllerTest < ActionDispatch::IntegrationTest
|
class NotificationsControllerTest < ActionDispatch::IntegrationTest
|
||||||
# test "the truth" do
|
# test "the truth" do
|
||||||
|
|
Loading…
Reference in a new issue