mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-01 21:52:19 +01:00
(feat) new child notification
This commit is contained in:
parent
42946effe0
commit
d95ef8beb7
@ -20,7 +20,7 @@ class API::ChildrenController < API::APIController
|
|||||||
def create
|
def create
|
||||||
@child = Child.new(child_params)
|
@child = Child.new(child_params)
|
||||||
authorize @child
|
authorize @child
|
||||||
if @child.save
|
if ChildService.create(@child)
|
||||||
render status: :created
|
render status: :created
|
||||||
else
|
else
|
||||||
render json: @child.errors.full_messages, status: :unprocessable_entity
|
render json: @child.errors.full_messages, status: :unprocessable_entity
|
||||||
|
18
app/services/child_service.rb
Normal file
18
app/services/child_service.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# ChildService
|
||||||
|
class ChildService
|
||||||
|
def self.create(child)
|
||||||
|
if child.save
|
||||||
|
NotificationCenter.call type: 'notify_admin_child_created',
|
||||||
|
receiver: User.admins_and_managers,
|
||||||
|
attached_object: child
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.update(child, child_params)
|
||||||
|
child.update(child_params)
|
||||||
|
end
|
||||||
|
end
|
@ -6,7 +6,7 @@ json.supporting_document_files_attributes child.supporting_document_files do |f|
|
|||||||
json.supportable_id f.supportable_id
|
json.supportable_id f.supportable_id
|
||||||
json.supportable_type f.supportable_type
|
json.supportable_type f.supportable_type
|
||||||
json.supporting_document_type_id f.supporting_document_type_id
|
json.supporting_document_type_id f.supporting_document_type_id
|
||||||
json.attachment f.attachment.file.filename
|
json.attachment f.attachment.file&.filename
|
||||||
json.attachment_name f.attachment_identifier
|
json.attachment_name f.attachment_identifier
|
||||||
json.attachment_url "/api/supporting_document_files/#{f.id}/download"
|
json.attachment_url f.attachment_identifier ? "/api/supporting_document_files/#{f.id}/download" : nil
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
json.title notification.notification_type
|
||||||
|
json.description t('.a_new_child_has_been_created_NAME_html',
|
||||||
|
NAME: notification.attached_object&.full_name || t('api.notifications.deleted_user'))
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= t('.body.new_child_created') %>
|
||||||
|
"<%= @attached_object&.full_name || t('api.notifications.deleted_user') %> <<%= @attached_object.email%>>"
|
||||||
|
</p>
|
@ -284,6 +284,7 @@ en:
|
|||||||
app_management: "Concerning app management notifications"
|
app_management: "Concerning app management notifications"
|
||||||
notification_form:
|
notification_form:
|
||||||
notify_admin_when_user_is_created: "A user account has been created"
|
notify_admin_when_user_is_created: "A user account has been created"
|
||||||
|
notify_admin_child_created: "A child has been created"
|
||||||
notify_admin_when_user_is_imported: "A user account has been imported"
|
notify_admin_when_user_is_imported: "A user account has been imported"
|
||||||
notify_admin_profile_complete: "An imported account has completed its profile"
|
notify_admin_profile_complete: "An imported account has completed its profile"
|
||||||
notify_admin_user_merged: "An imported account has been merged with an existing account"
|
notify_admin_user_merged: "An imported account has been merged with an existing account"
|
||||||
|
@ -284,6 +284,7 @@ fr:
|
|||||||
app_management: "Au sujet de la gestion de l'application"
|
app_management: "Au sujet de la gestion de l'application"
|
||||||
notification_form:
|
notification_form:
|
||||||
notify_admin_when_user_is_created: "Un compte utilisateur a été créé"
|
notify_admin_when_user_is_created: "Un compte utilisateur a été créé"
|
||||||
|
notify_admin_child_created: "Un compte enfant a été créé"
|
||||||
notify_admin_when_user_is_imported: "Un compte utilisateur a été importé"
|
notify_admin_when_user_is_imported: "Un compte utilisateur a été importé"
|
||||||
notify_admin_profile_complete: "Un compte importé a complété ses informations"
|
notify_admin_profile_complete: "Un compte importé a complété ses informations"
|
||||||
notify_admin_user_merged: "Un compte importé a été fusionné avec un compte existant"
|
notify_admin_user_merged: "Un compte importé a été fusionné avec un compte existant"
|
||||||
|
@ -314,6 +314,8 @@ en:
|
|||||||
project_NAME_has_been_published_html: "Project <a href='/#!/projects/%{ID}'><strong><em>%{NAME}<em></strong></a> has been published."
|
project_NAME_has_been_published_html: "Project <a href='/#!/projects/%{ID}'><strong><em>%{NAME}<em></strong></a> has been published."
|
||||||
notify_admin_when_user_is_created:
|
notify_admin_when_user_is_created:
|
||||||
a_new_user_account_has_been_created_NAME_EMAIL_html: "A new user account has been created: <strong><em>%{NAME} <%{EMAIL}></strong></em>."
|
a_new_user_account_has_been_created_NAME_EMAIL_html: "A new user account has been created: <strong><em>%{NAME} <%{EMAIL}></strong></em>."
|
||||||
|
notify_admin_child_created:
|
||||||
|
a_new_child_has_been_created_NAME_html: "A new child has been created: <strong><em>%{NAME}</em></strong>."
|
||||||
notify_admin_when_user_is_imported:
|
notify_admin_when_user_is_imported:
|
||||||
a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "A new user account has been imported from: <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "A new user account has been imported from: <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
||||||
notify_member_create_reservation:
|
notify_member_create_reservation:
|
||||||
|
@ -314,6 +314,8 @@ fr:
|
|||||||
project_NAME_has_been_published_html: "Le projet <a href='/#!/projects/%{ID}'><strong><em>%{NAME}<em></strong></a> vient d'être publié."
|
project_NAME_has_been_published_html: "Le projet <a href='/#!/projects/%{ID}'><strong><em>%{NAME}<em></strong></a> vient d'être publié."
|
||||||
notify_admin_when_user_is_created:
|
notify_admin_when_user_is_created:
|
||||||
a_new_user_account_has_been_created_NAME_EMAIL_html: "Un nouveau compte utilisateur vient d'être créé : <strong><em>%{NAME} <%{EMAIL}></strong></em>."
|
a_new_user_account_has_been_created_NAME_EMAIL_html: "Un nouveau compte utilisateur vient d'être créé : <strong><em>%{NAME} <%{EMAIL}></strong></em>."
|
||||||
|
notify_admin_child_created:
|
||||||
|
a_new_child_has_been_created_NAME_html: "Un nouveau enfant vient d'être créé : <strong><em>%{NAME}</em></strong>."
|
||||||
notify_admin_when_user_is_imported:
|
notify_admin_when_user_is_imported:
|
||||||
a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
||||||
notify_member_create_reservation:
|
notify_member_create_reservation:
|
||||||
|
@ -104,6 +104,10 @@ en:
|
|||||||
new_account_created: "A new user account has been created on the website:"
|
new_account_created: "A new user account has been created on the website:"
|
||||||
user_of_group_html: "The user has registered in the group <strong>%{GROUP}</strong>"
|
user_of_group_html: "The user has registered in the group <strong>%{GROUP}</strong>"
|
||||||
account_for_organization: "This account manage an organization:"
|
account_for_organization: "This account manage an organization:"
|
||||||
|
notify_admin_child_created:
|
||||||
|
subject: "A user's child has been created"
|
||||||
|
body:
|
||||||
|
new_child_created: "A new user's child has been created on the website"
|
||||||
notify_admin_subscribed_plan:
|
notify_admin_subscribed_plan:
|
||||||
subject: "A subscription has been purchased"
|
subject: "A subscription has been purchased"
|
||||||
body:
|
body:
|
||||||
|
@ -104,6 +104,10 @@ fr:
|
|||||||
new_account_created: "Un nouveau compte utilisateur vient d'être créé sur la plateforme :"
|
new_account_created: "Un nouveau compte utilisateur vient d'être créé sur la plateforme :"
|
||||||
user_of_group_html: "L'utilisateur s'est inscrit dans le groupe <strong>%{GROUP}</strong>"
|
user_of_group_html: "L'utilisateur s'est inscrit dans le groupe <strong>%{GROUP}</strong>"
|
||||||
account_for_organization: "Ce compte gère une structure :"
|
account_for_organization: "Ce compte gère une structure :"
|
||||||
|
notify_admin_child_created:
|
||||||
|
subject: "Un enfant a été créé"
|
||||||
|
body:
|
||||||
|
new_child_created: "Un nouveau enfant vient d'être créé sur la plateforme"
|
||||||
notify_admin_subscribed_plan:
|
notify_admin_subscribed_plan:
|
||||||
subject: "Un abonnement a été souscrit"
|
subject: "Un abonnement a été souscrit"
|
||||||
body:
|
body:
|
||||||
|
@ -47,3 +47,11 @@ unless NotificationType.find_by(name: 'notify_user_child_supporting_document_ref
|
|||||||
is_configurable: false
|
is_configurable: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless NotificationType.find_by(name: 'notify_admin_child_created')
|
||||||
|
NotificationType.create!(
|
||||||
|
name: 'notify_admin_child_created',
|
||||||
|
category: 'users_accounts',
|
||||||
|
is_configurable: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user