mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-22 11:52:21 +01:00
(feat) child compte validation notification
This commit is contained in:
parent
d95ef8beb7
commit
ba26f2f653
@ -47,7 +47,7 @@ class API::ChildrenController < API::APIController
|
||||
authorize @child
|
||||
|
||||
cparams = params.require(:child).permit(:validated_at)
|
||||
if @child.update(validated_at: cparams[:validated_at].present? ? Time.current : nil)
|
||||
if ChildService.validate(@child, cparams[:validated_at].present?)
|
||||
render :show, status: :ok, location: child_path(@child)
|
||||
else
|
||||
render json: @child.errors, status: :unprocessable_entity
|
||||
|
@ -15,4 +15,20 @@ class ChildService
|
||||
def self.update(child, child_params)
|
||||
child.update(child_params)
|
||||
end
|
||||
|
||||
def self.validate(child, is_valid)
|
||||
is_updated = child.update(validated_at: is_valid ? Time.current : nil)
|
||||
if is_updated
|
||||
if is_valid
|
||||
NotificationCenter.call type: 'notify_user_child_is_validated',
|
||||
receiver: child.user,
|
||||
attached_object: child
|
||||
else
|
||||
NotificationCenter.call type: 'notify_user_child_is_invalidated',
|
||||
receiver: child.user,
|
||||
attached_object: child
|
||||
end
|
||||
end
|
||||
is_updated
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,2 @@
|
||||
json.title notification.notification_type
|
||||
json.description t('.child_invalidated')
|
@ -0,0 +1,2 @@
|
||||
json.title notification.notification_type
|
||||
json.description t('.child_validated')
|
@ -0,0 +1,5 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.child_invalidated') %>
|
||||
</p>
|
@ -0,0 +1,5 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.child_validated') %>
|
||||
</p>
|
@ -447,6 +447,10 @@ en:
|
||||
account_validated: "Your account is valid."
|
||||
notify_user_is_invalidated:
|
||||
account_invalidated: "Your account is invalid."
|
||||
notify_user_child_is_validated:
|
||||
child_validated: "Your account child is valid."
|
||||
notify_user_child_is_invalidated:
|
||||
child_invalidated: "Your account child is invalid."
|
||||
notify_user_supporting_document_refusal:
|
||||
refusal: "Your supporting documents were refused"
|
||||
notify_admin_user_supporting_document_refusal:
|
||||
|
@ -447,6 +447,10 @@ fr:
|
||||
account_validated: "Votre compte est valide."
|
||||
notify_user_is_invalidated:
|
||||
account_invalidated: "Votre compte est invalide."
|
||||
notify_user_child_is_validated:
|
||||
child_validated: "Votre compte enfant est valide."
|
||||
notify_user_child_is_invalidated:
|
||||
child_invalidated: "Votre compte enfant est invalide."
|
||||
notify_user_supporting_document_refusal:
|
||||
refusal: "Vos pièces justificatives ont été refusées"
|
||||
notify_admin_user_supporting_document_refusal:
|
||||
|
@ -401,6 +401,14 @@ en:
|
||||
subject: "Account invalidated"
|
||||
body:
|
||||
account_invalidated: "Your account was invalidated. You won't be able to book anymore, until your account is validated again."
|
||||
notify_user_child_is_validated:
|
||||
subject: "Child account validated"
|
||||
body:
|
||||
child_validated: "Your child account was validated. Now, you have access to event booking features."
|
||||
notify_user_child_is_invalidated:
|
||||
subject: "Child account invalidated"
|
||||
body:
|
||||
account_invalidated: "Your child account was invalidated. You won't be able to book event, until your child account is validated again."
|
||||
notify_user_supporting_document_refusal:
|
||||
subject: "Your supporting documents were refused"
|
||||
body:
|
||||
|
@ -401,6 +401,14 @@ fr:
|
||||
subject: "Compte invalidé"
|
||||
body:
|
||||
account_invalidated: "Votre compte a été invalidé. Vous ne pourrez plus réserver, jusqu'à ce que votre compte soit à nouveau validé."
|
||||
notify_user_child_is_validated:
|
||||
subject: "Compte enfant validé"
|
||||
body:
|
||||
account_validated: "Votre compte enfant a été validé. Vous avez maintenant accès aux fonctionnalités de réservation de l'événement."
|
||||
notify_user_child_is_invalidated:
|
||||
subject: "Compte enfant invalidé"
|
||||
body:
|
||||
account_invalidated: "Votre compte enfant a été invalidé. Vous ne pourrez plus réserver l'événement, jusqu'à ce que votre compte enfant soit à nouveau validé."
|
||||
notify_user_supporting_document_refusal:
|
||||
subject: "Vos pièces justificatives ont été refusées"
|
||||
body:
|
||||
|
@ -55,3 +55,19 @@ unless NotificationType.find_by(name: 'notify_admin_child_created')
|
||||
is_configurable: true
|
||||
)
|
||||
end
|
||||
|
||||
unless NotificationType.find_by(name: 'notify_user_child_is_validated')
|
||||
NotificationType.create!(
|
||||
name: 'notify_user_child_is_validated',
|
||||
category: 'users_accounts',
|
||||
is_configurable: false
|
||||
)
|
||||
end
|
||||
|
||||
unless NotificationType.find_by(name: 'notify_user_child_is_invalidated')
|
||||
NotificationType.create!(
|
||||
name: 'notify_user_child_is_invalidated',
|
||||
category: 'users_accounts',
|
||||
is_configurable: false
|
||||
)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user