effective_work_experience 0.0.1 → 0.0.3

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: 9a876f18790cdca6bc9e13228ec0be8b643e4167e1e348cfaf00f09c9376f79f
4
- data.tar.gz: c08a8257f216cb33f27760b729526b76d854a6d4f7d71ec32c21af581f78c358
3
+ metadata.gz: 5b1b17b8acb26be41f882c4aba1bd5546986dc12bed911b4ee7fba690d1dee4b
4
+ data.tar.gz: a40e92b082bc6217ee0c3fc11452b7c3aa36afa35b95571b3a140eccbedd1bbf
5
5
  SHA512:
6
- metadata.gz: 7c4aa51ef471a77a677dfb382e4a4c190336903557b827d3b9839c93f075ad2c856b8d281692f0efbe8d6291d5c99fd797d77cf840dd8e71048ebb0104fbd597
7
- data.tar.gz: '0788634767708d121ce06edadf1cfefd9c5150b4cfed0ae5e0e354143a3f4446b0891a0115ccf3b45c98911c426223ca0cda33af45d782c60b738e85f1128723'
6
+ metadata.gz: 4741e55d2afddd0d6e7478ee8adcd5fdcf8f3307e669fb4a84ff522efbd5657b583f22ccc295953dc41076c82b44619738b647df6a38e10b5b9bec6029fdd691
7
+ data.tar.gz: b283fcdc327b1353f89bc43ae92012271dd21a9307cf6a7c11801fccfc54a71df5bce0eee3a00c04c0747a55f61d6e5f6acbc6c575d5dac746696c02475c41f5
data/README.md CHANGED
@@ -65,33 +65,78 @@ and configure it:
65
65
  config.work_experience_summary_class_name = 'Bcsla::WorkExperienceSummary'
66
66
  ```
67
67
 
68
+ ## Categories
69
+
70
+ Nothing works until there are categories and subcategories to record hours against — a new record
71
+ has one row per subcategory, so with none it is an empty form. Every application defines its own,
72
+ either from the admin screens or from its own seeds. See `db/seeds.rb` for an example set.
73
+
74
+ `minimum_hours` is optional on both. The work experience report shows a target and a percent
75
+ complete for each category and subcategory that has one, and just the hours to date for those that
76
+ don't.
77
+
68
78
  ## User
69
79
 
70
- Add the following to your User model:
80
+ An intern's mentor is another user, so this gem needs one column on your users table. The install
81
+ migration does not add it. Write your own:
82
+
83
+ ```ruby
84
+ class AddWorkExperienceMentorToUsers < ActiveRecord::Migration[8.0]
85
+ def change
86
+ add_column :users, :work_experience_mentor_id, :integer
87
+ end
88
+ end
89
+ ```
90
+
91
+ Then add the following to your User model:
71
92
 
72
93
  ```ruby
73
94
  effective_work_experience_user
74
95
  ```
75
96
 
76
- This requires a `work_experience_mentor_id` column on your users table, and adds:
97
+ which adds the `belongs_to :work_experience_mentor` for that column, plus:
77
98
 
78
- - `work_experience_mentor` — the user who reviews my work experience summaries
79
99
  - `work_experience_mentees` — the interns I am a mentor for
80
100
  - `work_experience_outside_mentor` — my mentor when they don't have an account. A `has_one`.
81
101
  - `work_experience_records`, `work_experience_entries`, `work_experience_projects`, `work_experience_summaries`, `mentee_work_experience_summaries`
82
102
  - the `work_experience_hours`, `work_experience_hours_by_year` and `work_experience_total_hours_to_date` calculations
103
+ - `work_experience_intern?`, `work_experience_mentor?` and `work_experience_outside_mentor?`, used by the views and permissions below
83
104
 
84
105
  An intern with an outside mentor has no `work_experience_mentor`, so their summaries are reviewed automatically on submit.
85
106
 
86
107
  The summary's `user`, `mentor` and `supervisor` are polymorphic. A summary assigns its mentor from the user's `work_experience_mentor`, and its supervisor from the user's `supervisor` when your User model defines one.
87
108
 
109
+ ### Who is an intern
110
+
111
+ `work_experience_intern?` is true once a user has any records or summaries. To have someone see the
112
+ intern dashboard before they've recorded anything, define `intern?` on your User model and it will
113
+ be used too:
114
+
115
+ ```ruby
116
+ def intern?
117
+ membership.present? && membership.category.intern?
118
+ end
119
+ ```
120
+
121
+ ### Admin user form
122
+
88
123
  Render the mentor fields from your own admin user form:
89
124
 
90
125
  ```haml
91
- = render('effective/work_experience/user_fields', f: f)
126
+ = render('admin/work_experience/user_fields', f: f, hint: 'Who can be a mentor')
92
127
  ```
93
128
 
94
129
  This is the `work_experience_mentor` select plus an `f.has_many` builder for the one outside mentor.
130
+ The `work_experience_mentor_id` and `work_experience_outside_mentors_attributes` params are permitted
131
+ by effective_resources for free — there is nothing to add to your `effective_resource do` block.
132
+
133
+ Render an intern's records, projects, summaries and report as a tab on the same form:
134
+
135
+ ```haml
136
+ - if user.work_experience_intern?
137
+ = tab Effective::WorkExperienceRecord, label: 'Work Experience' do
138
+ = render('admin/work_experience/user_work_experience', user: user)
139
+ ```
95
140
 
96
141
  ## Dashboard
97
142
 
@@ -66,7 +66,7 @@ module EffectiveWorkExperienceUser
66
66
  end
67
67
 
68
68
  def work_experience_intern?
69
- return true if try(:intern?)
69
+ return true if try(:intern?) || try(:pre_intern?)
70
70
  work_experience_records.present? || work_experience_summaries.present?
71
71
  end
72
72
 
@@ -23,7 +23,7 @@
23
23
 
24
24
  - f.object.work_experience_subcategories.group_by(&:work_experience_category).each do |work_experience_category, work_experience_subcategories|
25
25
  %tbody
26
- - category_hours = work_experience_subcategories.sum { |work_experience_subcategory| user.work_experience_total_hours_to_date(work_experience_subcategory: work_experience_subcategory, month: ceiling_month) }
26
+ - category_hours = work_experience_subcategories.sum { |work_experience_subcategory| user&.work_experience_total_hours_to_date(work_experience_subcategory: work_experience_subcategory, month: ceiling_month) || 0.0 }
27
27
  %tr{style: "background: #f6f8fa"}
28
28
  %th{colspan: 6}= work_experience_category
29
29
  %th.text-right= (category_hours > 0.0 ? work_experience_hours_to_s(category_hours) : '-')
@@ -45,7 +45,7 @@
45
45
  %td= ef.number_text_field :week_4, label: false
46
46
  %td= ef.number_text_field :week_5, label: false
47
47
  %td.text-right
48
- - hours = user.work_experience_total_hours_to_date(work_experience_subcategory: work_experience_subcategory, month: ceiling_month)
48
+ - hours = user&.work_experience_total_hours_to_date(work_experience_subcategory: work_experience_subcategory, month: ceiling_month) || 0.0
49
49
  = (hours > 0.0 ? work_experience_hours_to_s(hours) : '-')
50
50
  %td.text-right
51
51
  - if work_experience_subcategory.minimum_hours.present?
@@ -27,7 +27,7 @@ en:
27
27
  minimum_hours: 'Minimum Hours'
28
28
  position: 'Position'
29
29
  work_experience_category: 'Category'
30
- body: 'Description'
30
+ body: 'Body'
31
31
 
32
32
  effective/work_experience_record:
33
33
  month: 'Month'
@@ -1,6 +1,6 @@
1
1
  class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
2
2
  def change
3
- create_table :work_experience_categories do |t|
3
+ create_table :work_experience_categories, if_not_exists: true do |t|
4
4
  t.string :title
5
5
  t.integer :minimum_hours
6
6
  t.integer :position
@@ -8,7 +8,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
8
8
  t.timestamps
9
9
  end
10
10
 
11
- create_table :work_experience_subcategories do |t|
11
+ create_table :work_experience_subcategories, if_not_exists: true do |t|
12
12
  t.integer :work_experience_category_id
13
13
 
14
14
  t.string :title
@@ -18,7 +18,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
18
18
  t.timestamps
19
19
  end
20
20
 
21
- create_table :work_experience_outside_mentors do |t|
21
+ create_table :work_experience_outside_mentors, if_not_exists: true do |t|
22
22
  t.integer :user_id
23
23
  t.string :user_type
24
24
 
@@ -31,7 +31,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
31
31
  t.timestamps
32
32
  end
33
33
 
34
- create_table :work_experience_records do |t|
34
+ create_table :work_experience_records, if_not_exists: true do |t|
35
35
  t.integer :user_id
36
36
  t.string :user_type
37
37
 
@@ -50,7 +50,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
50
50
  t.timestamps
51
51
  end
52
52
 
53
- create_table :work_experience_entries do |t|
53
+ create_table :work_experience_entries, if_not_exists: true do |t|
54
54
  t.integer :user_id
55
55
  t.string :user_type
56
56
 
@@ -66,7 +66,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
66
66
  t.timestamps
67
67
  end
68
68
 
69
- create_table :work_experience_projects do |t|
69
+ create_table :work_experience_projects, if_not_exists: true do |t|
70
70
  t.integer :user_id
71
71
  t.string :user_type
72
72
 
@@ -79,7 +79,7 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
79
79
  t.timestamps
80
80
  end
81
81
 
82
- create_table :work_experience_summaries do |t|
82
+ create_table :work_experience_summaries, if_not_exists: true do |t|
83
83
  t.integer :user_id
84
84
  t.string :user_type
85
85
 
@@ -110,11 +110,11 @@ class CreateEffectiveWorkExperience < ActiveRecord::Migration[6.0]
110
110
  t.timestamps
111
111
  end
112
112
 
113
- add_index :work_experience_outside_mentors, [:user_id, :user_type], unique: true
114
- add_index :work_experience_records, [:user_id, :user_type]
115
- add_index :work_experience_entries, [:work_experience_record_id]
116
- add_index :work_experience_projects, [:user_id, :user_type]
117
- add_index :work_experience_summaries, [:user_id, :user_type]
118
- add_index :work_experience_summaries, [:mentor_id, :mentor_type]
113
+ add_index :work_experience_outside_mentors, [:user_id, :user_type], unique: true, if_not_exists: true
114
+ add_index :work_experience_records, [:user_id, :user_type], if_not_exists: true
115
+ add_index :work_experience_entries, [:work_experience_record_id], if_not_exists: true
116
+ add_index :work_experience_projects, [:user_id, :user_type], if_not_exists: true
117
+ add_index :work_experience_summaries, [:user_id, :user_type], if_not_exists: true
118
+ add_index :work_experience_summaries, [:mentor_id, :mentor_type], if_not_exists: true
119
119
  end
120
120
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveWorkExperience
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_work_experience
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect