diff --git a/app/models/user.rb b/app/models/user.rb index ddaabeb42..10cbb8b85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -103,6 +103,8 @@ class User < ApplicationRecord after_save :subscribe_to_mailchimp_newsletter after_save :conditionally_resave_articles after_create :estimate_default_language! + before_update :mentor_status_update + before_update :mentee_status_update before_validation :set_username before_validation :downcase_email before_validation :check_for_username_change @@ -497,4 +499,16 @@ class User < ApplicationRecord follower_relationships.destroy_all follows.destroy_all end + + def mentor_status_update + if mentor_description_changed? || offering_mentorship_changed? + self.mentor_form_updated_at = Time.now + end + end + + def mentee_status_update + if mentee_description_changed? || seeking_mentorship_changed? + self.mentee_form_updated_at = Time.now + end + end end diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 8fbffecda..ecf011284 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -72,7 +72,9 @@ class UserPolicy < ApplicationPolicy looking_for_work_publicly medium_url mentee_description + mentee_form_updated_at mentor_description + mentor_form_updated_at mostly_work_with name offering_mentorship diff --git a/app/views/users/_mentorship.html.erb b/app/views/users/_mentorship.html.erb index b5a33510b..2f01d53dd 100644 --- a/app/views/users/_mentorship.html.erb +++ b/app/views/users/_mentorship.html.erb @@ -2,23 +2,27 @@
If you're interested in participating as a mentor, mentee, or both, please indicate below and we will be in contact via email.
<%= form_for(@user) do |f| %> -<% if @user.mentor_form_updated_at? %>Last Updated: <%= @user.mentor_form_updated_at.strftime("%b %d, %Y") %><% end %>
Please share the top 3 technologies/concepts you'd be comfortable working on with your mentee, how much experience you currently have (0-10, 10 being super duper expert), and anything else you'd like us to know.
+ <%= f.text_area :mentor_description, placeholder: "For example:\n\n1. Vim - 6, I love teaching people how to use vim because I really believe it increases productivity.\n\nI don't think I'd be comfortable teaching a total beginner. ", maxlength: 500 %><% if @user.mentee_form_updated_at? %>Last Updated: + <%= @user.mentor_form_updated_at.strftime("%b %d, %Y") %><% end %>
Please share the top 3 technologies/concepts you'd like to work on with your mentor, how much experience you currently have (0-10, 0 being no experience at all), and why you're interested in learning more. Please also share your general technical background and career goals.
+ <%= f.text_area :mentee_description, placeholder: "For example:\n\n1. React - 1, I walked through the tutorial on the React website, but I'm feeling lost. I see React listed in lots of job descriptions so I'd like to learn how to utilize the framework.\n\nI graduated from a coding bootcamp 3 months ago and my goal is to land my first developer role. I learned jQuery in the program.", maxlength: 500 %>