Notification: add gestionnaire.procedures_with_email_notifications scope
This commit is contained in:
parent
7077153e7e
commit
1644fd9059
4 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,8 @@ class AssignTo < ApplicationRecord
|
|||
belongs_to :gestionnaire
|
||||
has_one :procedure_presentation, dependent: :destroy
|
||||
|
||||
scope :with_email_notifications, -> { where(email_notifications_enabled: true) }
|
||||
|
||||
def procedure_presentation_or_default_and_errors
|
||||
errors = reset_procedure_presentation_if_invalid
|
||||
[procedure_presentation || build_procedure_presentation, errors]
|
||||
|
|
|
@ -11,6 +11,10 @@ class Gestionnaire < ApplicationRecord
|
|||
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, through: :assign_to
|
||||
|
||||
has_many :assign_to_with_email_notifications, -> { with_email_notifications }, class_name: 'AssignTo'
|
||||
has_many :procedures_with_email_notifications, through: :assign_to_with_email_notifications, source: :procedure
|
||||
|
||||
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
|
||||
has_many :follows
|
||||
has_many :followed_dossiers, through: :follows, source: :dossier
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddEmailNotificationsColumnToAssignTo < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :assign_tos, :email_notifications_enabled, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_03_11_140926) do
|
||||
ActiveRecord::Schema.define(version: 2019_03_18_154812) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -99,6 +99,7 @@ ActiveRecord::Schema.define(version: 2019_03_11_140926) do
|
|||
t.integer "procedure_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "email_notifications_enabled", default: false, null: false
|
||||
t.index ["gestionnaire_id", "procedure_id"], name: "index_assign_tos_on_gestionnaire_id_and_procedure_id", unique: true
|
||||
t.index ["gestionnaire_id"], name: "index_assign_tos_on_gestionnaire_id"
|
||||
t.index ["procedure_id"], name: "index_assign_tos_on_procedure_id"
|
||||
|
|
Loading…
Reference in a new issue