mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-23 12:52:20 +01:00
(feat) child's supporting document file created/updated notification
This commit is contained in:
parent
19df3d47c0
commit
4989e16e6f
@ -7,13 +7,38 @@ class ChildService
|
|||||||
NotificationCenter.call type: 'notify_admin_child_created',
|
NotificationCenter.call type: 'notify_admin_child_created',
|
||||||
receiver: User.admins_and_managers,
|
receiver: User.admins_and_managers,
|
||||||
attached_object: child
|
attached_object: child
|
||||||
|
all_files_are_upload = true
|
||||||
|
SupportingDocumentType.where(document_type: 'Child').each do |sdt|
|
||||||
|
file = sdt.supporting_document_files.find_by(supportable: child)
|
||||||
|
all_files_are_upload = false if file.nil? || file.attachment_identifier.nil?
|
||||||
|
end
|
||||||
|
if all_files_are_upload
|
||||||
|
NotificationCenter.call type: 'notify_admin_user_child_supporting_document_files_created',
|
||||||
|
receiver: User.admins_and_managers,
|
||||||
|
attached_object: child
|
||||||
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update(child, child_params)
|
def self.update(child, child_params)
|
||||||
child.update(child_params)
|
if child.update(child_params)
|
||||||
|
all_files_are_upload = true
|
||||||
|
SupportingDocumentType.where(document_type: 'Child').each do |sdt|
|
||||||
|
file = sdt.supporting_document_files.find_by(supportable: child)
|
||||||
|
all_files_are_upload = false if file.nil? || file.attachment_identifier.nil?
|
||||||
|
end
|
||||||
|
if all_files_are_upload
|
||||||
|
NotificationCenter.call type: 'notify_admin_user_child_supporting_document_files_updated',
|
||||||
|
receiver: User.admins_and_managers,
|
||||||
|
attached_object: child
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.validate(child, is_valid)
|
def self.validate(child, is_valid)
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
json.title notification.notification_type
|
||||||
|
json.description t('.supporting_document_files_uploaded',
|
||||||
|
NAME: notification.attached_object&.full_name || t('api.notifications.deleted_user'))
|
@ -0,0 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
json.title notification.notification_type
|
||||||
|
json.description t('.supporting_document_files_uploaded',
|
||||||
|
NAME: notification.attached_object&.full_name || t('api.notifications.deleted_user'))
|
@ -0,0 +1,18 @@
|
|||||||
|
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= t('.body.supporting_document_files_uploaded_below',
|
||||||
|
NAME: @attached_object&.full_name || t('api.notifications.deleted_user')) %>
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<% if @attached_object %>
|
||||||
|
<% SupportingDocumentType.where(document_type: 'Child').each do |type| %>
|
||||||
|
<li><%= type.name %></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% if Setting.get('child_validation_required') %>
|
||||||
|
<p>
|
||||||
|
<%= t('.body.validate_child') %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
@ -0,0 +1,19 @@
|
|||||||
|
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= t('.body.child_update_supporting_document_file',
|
||||||
|
NAME: @attached_object&.full_name || t('api.notifications.deleted_user')) %>
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<% if @attached_object %>
|
||||||
|
<% SupportingDocumentType.where(document_type: 'Child').each do |type| %>
|
||||||
|
<li><%= type.name %></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
<% if Setting.get('child_validation_required') %>
|
||||||
|
<p>
|
||||||
|
<%= t('.body.validate_child') %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
@ -295,6 +295,8 @@ en:
|
|||||||
notify_admin_user_child_supporting_document_refusal: "A supporting document of child has been rejected"
|
notify_admin_user_child_supporting_document_refusal: "A supporting document of child has been rejected"
|
||||||
notify_admin_user_supporting_document_files_created: "A user has uploaded a supporting document"
|
notify_admin_user_supporting_document_files_created: "A user has uploaded a supporting document"
|
||||||
notify_admin_user_supporting_document_files_updated: "A user has updated a supporting document"
|
notify_admin_user_supporting_document_files_updated: "A user has updated a supporting document"
|
||||||
|
notify_admin_user_child_supporting_document_files_created: "A child has uploaded a supporting document"
|
||||||
|
notify_admin_user_child_supporting_document_files_updated: "A child has updated a supporting document"
|
||||||
notify_admin_member_create_reservation: "A member books a reservation"
|
notify_admin_member_create_reservation: "A member books a reservation"
|
||||||
notify_admin_slot_is_modified: "A reservation slot has been modified"
|
notify_admin_slot_is_modified: "A reservation slot has been modified"
|
||||||
notify_admin_slot_is_canceled: "A reservation has been cancelled"
|
notify_admin_slot_is_canceled: "A reservation has been cancelled"
|
||||||
|
@ -295,6 +295,8 @@ fr:
|
|||||||
notify_admin_user_child_supporting_document_refusal: "Un justificatif de l'enfant a été refusé"
|
notify_admin_user_child_supporting_document_refusal: "Un justificatif de l'enfant a été refusé"
|
||||||
notify_admin_user_supporting_document_files_created: "Un utilisateur a téléversé un justificatif"
|
notify_admin_user_supporting_document_files_created: "Un utilisateur a téléversé un justificatif"
|
||||||
notify_admin_user_supporting_document_files_updated: "Un utilisateur a mis à jour un justificatif"
|
notify_admin_user_supporting_document_files_updated: "Un utilisateur a mis à jour un justificatif"
|
||||||
|
notify_admin_user_child_supporting_document_files_created: "Un enfant a téléversé un justificatif"
|
||||||
|
notify_admin_user_child_supporting_document_files_updated: "Un enfant a mis à jour un justificatif"
|
||||||
notify_admin_member_create_reservation: "Un membre fait une réservation"
|
notify_admin_member_create_reservation: "Un membre fait une réservation"
|
||||||
notify_admin_slot_is_modified: "Un créneau de réservation a été modifié"
|
notify_admin_slot_is_modified: "Un créneau de réservation a été modifié"
|
||||||
notify_admin_slot_is_canceled: "Une réservation a été annulée"
|
notify_admin_slot_is_canceled: "Une réservation a été annulée"
|
||||||
|
@ -443,6 +443,10 @@ en:
|
|||||||
supporting_document_files_uploaded: "Supporting document uploaded by member <strong><em>%{NAME}</strong></em>."
|
supporting_document_files_uploaded: "Supporting document uploaded by member <strong><em>%{NAME}</strong></em>."
|
||||||
notify_admin_user_supporting_document_files_updated:
|
notify_admin_user_supporting_document_files_updated:
|
||||||
supporting_document_files_uploaded: "Supporting document changed by member <strong><em>%{NAME}</strong></em>."
|
supporting_document_files_uploaded: "Supporting document changed by member <strong><em>%{NAME}</strong></em>."
|
||||||
|
notify_admin_user_child_supporting_document_files_created:
|
||||||
|
supporting_document_files_uploaded: "Child's <strong><em>%{NAME}</strong></em> supporting document uploaded."
|
||||||
|
notify_admin_user_child_supporting_document_files_updated:
|
||||||
|
supporting_document_files_uploaded: "Supporting document changed by child <strong><em>%{NAME}</strong></em>."
|
||||||
notify_user_is_validated:
|
notify_user_is_validated:
|
||||||
account_validated: "Your account is valid."
|
account_validated: "Your account is valid."
|
||||||
notify_user_is_invalidated:
|
notify_user_is_invalidated:
|
||||||
|
@ -443,6 +443,10 @@ fr:
|
|||||||
supporting_document_files_uploaded: "Le membre <strong><em>%{NAME}</strong></em> a téléversé un nouveau justificatif."
|
supporting_document_files_uploaded: "Le membre <strong><em>%{NAME}</strong></em> a téléversé un nouveau justificatif."
|
||||||
notify_admin_user_supporting_document_files_updated:
|
notify_admin_user_supporting_document_files_updated:
|
||||||
supporting_document_files_uploaded: "Le membre <strong><em>%{NAME}</strong></em> a modifié un justificatif."
|
supporting_document_files_uploaded: "Le membre <strong><em>%{NAME}</strong></em> a modifié un justificatif."
|
||||||
|
notify_admin_user_child_supporting_document_files_created:
|
||||||
|
supporting_document_files_uploaded: "L'enfant <strong><em>%{NAME}</strong></em> a téléversé un nouveau justificatif."
|
||||||
|
notify_admin_user_child_supporting_document_files_updated:
|
||||||
|
supporting_document_files_uploaded: "L'enfant <strong><em>%{NAME}</strong></em> a modifié un justificatif."
|
||||||
notify_user_is_validated:
|
notify_user_is_validated:
|
||||||
account_validated: "Votre compte est valide."
|
account_validated: "Votre compte est valide."
|
||||||
notify_user_is_invalidated:
|
notify_user_is_invalidated:
|
||||||
|
@ -393,6 +393,16 @@ en:
|
|||||||
body:
|
body:
|
||||||
user_update_supporting_document_file: "Member %{NAME} has modified the supporting documents below:"
|
user_update_supporting_document_file: "Member %{NAME} has modified the supporting documents below:"
|
||||||
validate_user: "Please validate this account"
|
validate_user: "Please validate this account"
|
||||||
|
notify_admin_user_child_supporting_document_files_created:
|
||||||
|
subject: "Supporting documents of child uploaded by a member"
|
||||||
|
body:
|
||||||
|
supporting_document_files_uploaded_below: "Child %{NAME} has uploaded the following supporting documents:"
|
||||||
|
validate_child: "Please validate this child account"
|
||||||
|
notify_admin_user_child_supporting_document_files_updated:
|
||||||
|
subject: "Child's supporting documents have changed"
|
||||||
|
body:
|
||||||
|
child_update_supporting_document_file: "Child %{NAME} has modified the supporting documents below:"
|
||||||
|
validate_child: "Please validate this child account"
|
||||||
notify_user_is_validated:
|
notify_user_is_validated:
|
||||||
subject: "Account validated"
|
subject: "Account validated"
|
||||||
body:
|
body:
|
||||||
|
@ -393,6 +393,16 @@ fr:
|
|||||||
body:
|
body:
|
||||||
user_update_supporting_document_file: "Le membre %{NAME} a modifié le justificatif ci-dessous :"
|
user_update_supporting_document_file: "Le membre %{NAME} a modifié le justificatif ci-dessous :"
|
||||||
validate_user: "Veuillez valider son compte"
|
validate_user: "Veuillez valider son compte"
|
||||||
|
notify_admin_user_child_supporting_document_files_created:
|
||||||
|
subject: "Justificatif de l'enfant téléversé par un membre"
|
||||||
|
body:
|
||||||
|
supporting_document_files_uploaded_below: "L'enfant %{NAME} a téléversé le justificatif suivant :"
|
||||||
|
validate_child: "Veuillez valider son compte enfant"
|
||||||
|
notify_admin_user_child_supporting_document_files_updated:
|
||||||
|
subject: "Le justificatif d'un enfant a changé"
|
||||||
|
body:
|
||||||
|
child_update_supporting_document_file: "L'enfant %{NAME} a modifié le justificatif ci-dessous :"
|
||||||
|
validate_child: "Veuillez valider son compte enfant"
|
||||||
notify_user_is_validated:
|
notify_user_is_validated:
|
||||||
subject: "Compte validé"
|
subject: "Compte validé"
|
||||||
body:
|
body:
|
||||||
|
@ -71,3 +71,19 @@ unless NotificationType.find_by(name: 'notify_user_child_is_invalidated')
|
|||||||
is_configurable: false
|
is_configurable: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless NotificationType.find_by(name: 'notify_admin_user_child_supporting_document_files_updated')
|
||||||
|
NotificationType.create!(
|
||||||
|
name: 'notify_admin_user_child_supporting_document_files_updated',
|
||||||
|
category: 'supporting_documents',
|
||||||
|
is_configurable: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
unless NotificationType.find_by(name: 'notify_admin_user_child_supporting_document_files_created')
|
||||||
|
NotificationType.create!(
|
||||||
|
name: 'notify_admin_user_child_supporting_document_files_created',
|
||||||
|
category: 'supporting_documents',
|
||||||
|
is_configurable: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user