Add notification for champs

This commit is contained in:
Xavier J 2016-12-26 11:47:51 +01:00
parent e5768b6798
commit 33c1a12b84
3 changed files with 15 additions and 4 deletions

View file

@ -5,6 +5,8 @@ class Champ < ActiveRecord::Base
delegate :libelle, :type_champ, :order_place, :mandatory, :description, :drop_down_list, to: :type_de_champ
after_save :internal_notification
def mandatory?
mandatory
end
@ -46,4 +48,10 @@ class Champ < ActiveRecord::Base
def self.pays
JSON.parse(Carto::GeoAPI::Driver.pays).inject([]) { |acc, liste| acc.push(liste['nom']) }
end
private
def internal_notification
NotificationService.new('champs', self.dossier.id, self.libelle).notify
end
end

View file

@ -6,7 +6,8 @@ class Notification < ActiveRecord::Base
enum type_notif: {
commentaire: 'commentaire',
cerfa: 'cerfa',
piece_justificative: 'piece_justificative'
piece_justificative: 'piece_justificative',
champs: 'champs'
}
# def broadcast_notification

View file

@ -31,6 +31,8 @@ class NotificationService
"Un nouveau formulaire a été déposé."
when 'piece_justificative'
attribut
when 'champs'
attribut
else
'Notification par défaut'
end