effective_cpd 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: '007309633bd01dfa4ad2731f7c36f6d576c471c6de1f8ec21f355da5615a2b0d'
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f1a0b42227c58dea846ad8e288bccec8472ce05a747b790ef4a6b83ee8ab0539
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 99d7615012e34a640bd5e3009559a431638880894f819910cbc3d6df770316c6e4329bebb2dfdd28cf44d7c39abf2f63f1682205232f5a8bea5f43c9e7b25c73
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 99e4617ac625fa40c15e60cbe535824be383edf62306ebd3337b01204c5a03d9f3b89c7c441045848f932fcdb1c21c564aa349c3334eddb2c2eee9c73a54631e
         
     | 
| 
         @@ -26,7 +26,7 @@ module EffectiveCpdUser 
     | 
|
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                # Effective scoped
         
     | 
| 
       28 
28 
     | 
    
         
             
                has_many :cpd_targets, -> { order(:cpd_cycle_id) }, inverse_of: :user, class_name: 'Effective::CpdTarget', dependent: :delete_all
         
     | 
| 
       29 
     | 
    
         
            -
                accepts_nested_attributes_for :cpd_targets, reject_if:  
     | 
| 
      
 29 
     | 
    
         
            +
                accepts_nested_attributes_for :cpd_targets, reject_if: :reject_cpd_target_attributes, allow_destroy: true
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                # These two should not be sorted
         
     | 
| 
       32 
32 
     | 
    
         
             
                scope :cpd_audit_auditees, -> { without_role(:cpd_audit_reviewer).without_role(:admin) }
         
     | 
| 
         @@ -43,7 +43,7 @@ module EffectiveCpdUser 
     | 
|
| 
       43 
43 
     | 
    
         
             
                }
         
     | 
| 
       44 
44 
     | 
    
         
             
              end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
              #  
     | 
| 
      
 46 
     | 
    
         
            +
              # The required or targeted number of credits for this user in this cycle
         
     | 
| 
       47 
47 
     | 
    
         
             
              def cpd_target_score(cpd_cycle:)
         
     | 
| 
       48 
48 
     | 
    
         
             
                target = cpd_target(cpd_cycle: cpd_cycle)
         
     | 
| 
       49 
49 
     | 
    
         
             
                return target.score if target&.score.present?
         
     | 
| 
         @@ -51,8 +51,15 @@ module EffectiveCpdUser 
     | 
|
| 
       51 
51 
     | 
    
         
             
                default_cpd_target_score(cpd_cycle: cpd_cycle)
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
              #  
     | 
| 
       55 
     | 
    
         
            -
               
     | 
| 
      
 54 
     | 
    
         
            +
              # Whether the user can submit a statement without the required number of credits
         
     | 
| 
      
 55 
     | 
    
         
            +
              def cpd_target_score_required_to_submit?(cpd_cycle:)
         
     | 
| 
      
 56 
     | 
    
         
            +
                target = cpd_target(cpd_cycle: cpd_cycle)
         
     | 
| 
      
 57 
     | 
    
         
            +
                return target.required_to_submit? unless target&.required_to_submit.nil?
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                default_cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              # Required for this user category without the targets. Used to display defaults on admin form.
         
     | 
| 
       56 
63 
     | 
    
         
             
              def default_cpd_target_score(cpd_cycle:)
         
     | 
| 
       57 
64 
     | 
    
         
             
                if self.class.try(:effective_memberships_user?)
         
     | 
| 
       58 
65 
     | 
    
         
             
                  category = membership_categories_on(cpd_cycle.start_at)&.first if cpd_cycle.start_at.present?
         
     | 
| 
         @@ -63,10 +70,8 @@ module EffectiveCpdUser 
     | 
|
| 
       63 
70 
     | 
    
         
             
                end
         
     | 
| 
       64 
71 
     | 
    
         
             
              end
         
     | 
| 
       65 
72 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
               
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                return target.required_to_submit? unless target&.required_to_submit.nil?
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 73 
     | 
    
         
            +
              # Required for this user category without the targets. Used to display defaults on admin form.
         
     | 
| 
      
 74 
     | 
    
         
            +
              def default_cpd_target_score_required_to_submit?(cpd_cycle:)
         
     | 
| 
       70 
75 
     | 
    
         
             
                cpd_cycle.required_to_submit?
         
     | 
| 
       71 
76 
     | 
    
         
             
              end
         
     | 
| 
       72 
77 
     | 
    
         | 
| 
         @@ -103,10 +108,23 @@ module EffectiveCpdUser 
     | 
|
| 
       103 
108 
     | 
    
         | 
| 
       104 
109 
     | 
    
         
             
              # For the form
         
     | 
| 
       105 
110 
     | 
    
         
             
              def build_cpd_targets
         
     | 
| 
       106 
     | 
    
         
            -
                Effective::CpdCycle.sorted.all. 
     | 
| 
      
 111 
     | 
    
         
            +
                Effective::CpdCycle.sorted.all.map do |cpd_cycle|
         
     | 
| 
       107 
112 
     | 
    
         
             
                  cpd_target(cpd_cycle: cpd_cycle) || cpd_targets.new(cpd_cycle: cpd_cycle)
         
     | 
| 
      
 113 
     | 
    
         
            +
                end.sort_by(&:cpd_cycle_id).reverse
         
     | 
| 
      
 114 
     | 
    
         
            +
              end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
              private
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              def reject_cpd_target_attributes(atts)
         
     | 
| 
      
 119 
     | 
    
         
            +
                # Reject if new record and blank
         
     | 
| 
      
 120 
     | 
    
         
            +
                return true if (atts['id'].blank? && atts['score'].blank? && atts['required_to_submit'].blank?)
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                # Delete when ID present and score and required to submit blank
         
     | 
| 
      
 123 
     | 
    
         
            +
                if (atts['id'].present? && atts['score'].blank? && atts['required_to_submit'].blank?)
         
     | 
| 
      
 124 
     | 
    
         
            +
                  atts.merge!({:_destroy => 1})
         
     | 
| 
       108 
125 
     | 
    
         
             
                end
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                false
         
     | 
| 
       110 
128 
     | 
    
         
             
              end
         
     | 
| 
       111 
129 
     | 
    
         | 
| 
       112 
130 
     | 
    
         
             
            end
         
     | 
| 
         @@ -20,7 +20,7 @@ module Effective 
     | 
|
| 
       20 
20 
     | 
    
         
             
                scope :deep, -> { includes(:user, :cpd_cycle) }
         
     | 
| 
       21 
21 
     | 
    
         
             
                scope :sorted, -> { order(:cpd_cycle_id) }
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
                validates :score, numericality: { greater_than_or_equal_to: 0 }
         
     | 
| 
      
 23 
     | 
    
         
            +
                validates :score, presence: true, numericality: { greater_than_or_equal_to: 0 }
         
     | 
| 
       24 
24 
     | 
    
         
             
                validates :required_to_submit, inclusion: { in: [true, false], message: "can't be blank" }
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                validates :cpd_cycle_id, uniqueness: { scope: [:user_id, :user_type], message: 'target already exists' }
         
     | 
| 
         @@ -1,12 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            = effective_form_with model: [:admin, user] do |f|
         
     | 
| 
       2 
2 
     | 
    
         
             
              = f.hidden_field :id
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              %p 
     | 
| 
      
 4 
     | 
    
         
            +
              %p
         
     | 
| 
      
 5 
     | 
    
         
            +
                #{cpd_targets_label} set the requirements checked when submitting a #{cpd_statement_label}
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
              %table.table
         
     | 
| 
       7 
8 
     | 
    
         
             
                %thead
         
     | 
| 
       8 
9 
     | 
    
         
             
                  %th= cpd_cycle_label
         
     | 
| 
       9 
     | 
    
         
            -
                  %th  
     | 
| 
      
 10 
     | 
    
         
            +
                  %th Default Requirements
         
     | 
| 
      
 11 
     | 
    
         
            +
                  %th Requirements for #{f.object}
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
       11 
13 
     | 
    
         
             
                %tbody
         
     | 
| 
       12 
14 
     | 
    
         
             
                  = f.fields_for :cpd_targets, f.object.build_cpd_targets do |ctf|
         
     | 
| 
         @@ -17,18 +19,27 @@ 
     | 
|
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
                    - collection = Effective::CpdTarget::REQUIRED_TO_SUBMIT
         
     | 
| 
       19 
21 
     | 
    
         
             
                    - cpd_cycle = ctf.object.cpd_cycle
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       20 
23 
     | 
    
         
             
                    - target = f.object.cpd_target_score(cpd_cycle: cpd_cycle)
         
     | 
| 
       21 
     | 
    
         
            -
                    - target_placeholder = f.object.default_cpd_target_score(cpd_cycle: cpd_cycle) || '-'
         
     | 
| 
       22 
24 
     | 
    
         
             
                    - required_to_submit = f.object.cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    - default_target = f.object.default_cpd_target_score(cpd_cycle: cpd_cycle) || 0
         
     | 
| 
      
 27 
     | 
    
         
            +
                    - default_required_to_submit = f.object.default_cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
                    %tr
         
     | 
| 
       26 
30 
     | 
    
         
             
                      %td= link_to(cpd_cycle, effective_cpd.edit_admin_cpd_cycle_path(cpd_cycle), target: '_blank')
         
     | 
| 
      
 31 
     | 
    
         
            +
                      %td
         
     | 
| 
      
 32 
     | 
    
         
            +
                        %p
         
     | 
| 
      
 33 
     | 
    
         
            +
                          = pluralize(default_target, cpd_credit_label.downcase)
         
     | 
| 
      
 34 
     | 
    
         
            +
                          = default_required_to_submit ? 'required' : 'targeted'
         
     | 
| 
      
 35 
     | 
    
         
            +
                          and
         
     | 
| 
      
 36 
     | 
    
         
            +
                          = collection.find { |value| value.last == default_required_to_submit }.first.downcase
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       27 
38 
     | 
    
         
             
                      %td
         
     | 
| 
       28 
39 
     | 
    
         
             
                        .row
         
     | 
| 
       29 
40 
     | 
    
         
             
                          .col
         
     | 
| 
       30 
     | 
    
         
            -
                            = ctf.number_field :score,  
     | 
| 
      
 41 
     | 
    
         
            +
                            = ctf.number_field :score, required: false, label: false
         
     | 
| 
       31 
42 
     | 
    
         
             
                          .col
         
     | 
| 
       32 
     | 
    
         
            -
                            = ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT,  
     | 
| 
      
 43 
     | 
    
         
            +
                            = ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT, required: false, label: false
         
     | 
| 
       33 
44 
     | 
    
         | 
| 
       34 
45 
     | 
    
         
             
              = f.save "Save #{cpd_targets_label}", 'data-confirm': "Really Save #{cpd_targets_label} for #{user}?"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: effective_cpd
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.5.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Code and Effect
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-03-31 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     |