Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
319 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
class MentoringController < ApplicationController | ||
before_filter :authenticate_user!, :only => [:profile_edit, :matches] | ||
|
||
def test | ||
end | ||
|
||
def search | ||
# if @mentor_tags.present? | ||
# @people = Person.tagged_with(@mentor_tags, :on => :mentor_topic_tags, :any => true) | ||
# elsif @mentor_tags.present? | ||
# @people = Person.tagged_with(@mentee_tags, :on => :mentee_topic_tags, :any => true) | ||
# end | ||
|
||
# render :text => params.inspect + "\n\n" + @people.inspect | ||
end | ||
|
||
def profile | ||
session[:mentoring_profile] = load_mentoring_params | ||
redirect_to mentoring_profile_welcome_path | ||
end | ||
|
||
def profile_welcome | ||
@mentoring = get_mentoring_data | ||
@matched_user = User.find_by_email(@mentoring[:contact][:email]) | ||
unless current_user.present? | ||
@signin_data = SignInData.new(:email => @mentoring[:contact][:email], :provider => 'auto') | ||
session[:user_return_to] = mentoring_profile_edit_path | ||
end | ||
end | ||
|
||
def profile_edit | ||
@mentoring = get_mentoring_data | ||
@name = current_user.name || [@mentoring[:firstname], @mentoring[:lastname]].join(' ') | ||
@person = current_user.person || current_user.authentications.first.to_person || Person.new | ||
|
||
@person.name ||= @name | ||
@person.interested_mentor = @mentoring[:mentor_areas].present? | ||
@person.interested_mentee = @mentoring[:mentee_areas].present? | ||
|
||
@person.mentor_topic_models += @mentoring[:mentor_areas].map{|area| MentorshipTopic.find_or_create_by_slug(area) } | ||
@person.mentee_topic_models += @mentoring[:mentee_areas].map{|area| MentorshipTopic.find_or_create_by_slug(area) } | ||
end | ||
|
||
def matches | ||
if current_person | ||
if params[:kind] == 'mentors' | ||
mentor_rankings = Hash.new(0) | ||
current_person.mentee_topic_models.each do |topic| | ||
topic.mentors.each do |mentor| | ||
mentor_rankings[mentor] += 1 | ||
end | ||
end | ||
@potential_mentors = mentor_rankings.keys.sort_by{|mentor| mentor_rankings[mentor]}.reverse | ||
elsif params[:kind] == 'mentees' | ||
mentee_rankings = Hash.new(0) | ||
current_person.mentor_topic_models.each do |topic| | ||
topic.mentees.each do |mentee| | ||
mentee_rankings[mentee] += 1 | ||
end | ||
end | ||
@potential_mentees = mentee_rankings.keys.sort_by{|mentee| mentee_rankings[mentee]}.reverse | ||
else | ||
raise ActiveRecord::RecordNotFound | ||
end | ||
end | ||
end | ||
|
||
# Sign the user out, but preserve their mentoring session data | ||
def sign_out_preserve_mentoring | ||
if current_user.present? | ||
mentoring = get_mentoring_data | ||
sign_out current_user | ||
session[:mentoring_profile] = mentoring | ||
end | ||
redirect_to mentoring_profile_welcome_path | ||
end | ||
|
||
private | ||
|
||
def get_mentoring_data | ||
session[:mentoring_profile].presence || load_mentoring_params | ||
end | ||
|
||
def load_mentoring_params | ||
{}.tap do |mentoring| | ||
mentoring[:mentor_areas] = params[:mentor_area_details].present? ? params[:mentor_area_details].split(',') : [] | ||
mentoring[:mentee_areas] = params[:mentee_area_details].present? ? params[:mentee_area_details].split(',') : [] | ||
mentoring[:contact] = params.extract!(:firstname, :lastname, :companyname, :email, :phone) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class MentorshipTopic < ActiveRecord::Base | ||
has_many :person_mentor_topics | ||
has_many :person_mentee_topics | ||
has_many :mentors, :through => :person_mentor_topics, :source => :person | ||
has_many :mentees, :through => :person_mentee_topics, :source => :person | ||
|
||
def humanize | ||
name || slug | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class PersonMenteeTopic < ActiveRecord::Base | ||
belongs_to :person | ||
belongs_to :mentorship_topic | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class PersonMentorTopic < ActiveRecord::Base | ||
belongs_to :person | ||
belongs_to :mentorship_topic | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#mentoring_matches | ||
- if params[:kind] == 'mentors' | ||
.mentors | ||
%h2 Potential Mentors | ||
%p | ||
You're looking for mentorship in the following topics: | ||
= current_person.mentor_topic_models.map{|t| t.humanize }.join(', ') | ||
- if @potential_mentors.present? | ||
%p Here are some mentors that match | ||
= render :partial => 'people/list', :object => @potential_mentors | ||
- else | ||
%p We couldn't find any mentors that matched. Check back later, as new mentors may join. | ||
- elsif params[:kind] == 'mentees' | ||
.mentees | ||
%h2 Potential Mentees | ||
%p | ||
You're looking to mentor people in the following topics: | ||
= current_person.mentor_topic_models.map{|t| t.humanize }.join(', ') | ||
- if @potential_mentees.present? | ||
%p Here are some interested mentees that match | ||
= render :partial => 'people/list', :object => @potential_mentees | ||
- else | ||
%p We couldn't find any mentees that matched. Check back later, as new mentees may join. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#welcome | ||
%h1= t('user.welcome.hi', :name => @name.split(' ').first) | ||
#mentoring_profile_edit | ||
#add_yourself | ||
- if @person.new_record? | ||
%h2= t('user.welcome.add_yourself', :organization => SETTINGS['organization']['name']) | ||
%p= t('user.welcome.provider', :provider => provider_name(current_user.authentications.first.provider)) | ||
- else | ||
%h2= t('user.welcome.review_details') | ||
%p= t('user.welcome.already_in_directory') | ||
|
||
-# TODO: re-combine this with people/_form | ||
- context ||= @person.new_record? ? :add_self : :review | ||
= semantic_form_for(@person, :html => {:multipart => true}) do |f| | ||
= display_errors_for @person | ||
.person_info | ||
= f.inputs :name => "Personal Information" do | ||
= f.input :name | ||
= render 'site/custom_slug_field', :form => f | ||
- unless @person.new_record? | ||
= f.semantic_fields_for :user do |u| | ||
= u.input :email | ||
= f.input :location | ||
= f.input :url | ||
= f.input :bio | ||
= f.input :tag_list, :as => :text, :input_html => {:class => 'tags'} | ||
= f.input :technology_list, :as => :text, :input_html => {:class => 'tags'} | ||
= import_image_from_url_tags_for f, @person, :photo | ||
- if mentoring_enabled? | ||
.mentorship_info | ||
= f.inputs :name => t('people.field.mentoring.title') do | ||
= f.input :interested_mentor | ||
= f.input :mentor_topic_models, :label_method => :humanize, :label => "I am interested in mentoring these topics", :hint => "Choosing from these structured topics will increase your chance of finding mentees." | ||
= f.input :mentor_topics, :label => "Other topics I'd like to mentor", :as => :string | ||
= f.input :interested_mentee | ||
= f.input :mentee_topic_models, :label_method => :humanize, :label => "I am interested in being mentored in these topics", :hint => "Choosing from these structured topics will increase your chance of finding mentees." | ||
= f.input :mentee_topics, :label => "Other topics I'd like mentorship in", :as => :string | ||
= f.input :reviewed, :input_html => {:value => true}, :as => :hidden | ||
- if current_user.admin? | ||
= f.input :user, :include_blank => "-- #{t('field.user.blankoption')} --", :label_method => :label_for_admin | ||
= hidden_field_tag :form_context, context | ||
%hr | ||
= f.buttons do | ||
= f.commit_button "Save and Continue" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#profile_welcome | ||
%h1 Let's finish setting up your mentoring profile. | ||
.intro | ||
%h2 Welcome to ePDX! | ||
%p | ||
ePDX is the community-edited guide to Portland's awesome tech community and where your mentoring profile will live. | ||
You can sign in anytime to search for mentorship connections and edit your profile. | ||
%p | ||
While you're here, be sure to check out the rest of the site for a look at the many people, companies, and groups that make up the world of Portland tech. | ||
|
||
.user_welcome | ||
- if current_user | ||
%p You're currently signed in to ePDX as: | ||
.signed_in_user | ||
- if current_user.avatar_url | ||
%img.avatar{:src => normalize_url(current_user.avatar_url), :align => 'left'} | ||
.name | ||
%strong= current_user.name | ||
%p | ||
If this isn't you, you can | ||
= link_to t('sign_out'), mentoring_sign_out_path | ||
- elsif @matched_user.present? | ||
.matched-user | ||
%h3 Welcome back! | ||
%p Based on your email address, it looks like you've already got an ePDX account. | ||
.sign_in_form | ||
= semantic_form_for(SignInData.new(:email => @matched_user.email, :provider => 'auto'), :url => user_sessions_path) do |f| | ||
= f.input :email, :as => :hidden | ||
= f.input :provider, :as => :hidden | ||
= f.commit_button t('button.sign_in') + " to continue" | ||
- else | ||
= render :partial => 'authentications/login_form', :locals => {:button_text => "Continue"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
= form_tag mentoring_search_path, :method => :post do | ||
= hidden_field_tag :firstname, "Reid" | ||
= hidden_field_tag :lastname, "Beels" | ||
= hidden_field_tag :companyname, "Pixeldye" | ||
= hidden_field_tag :email, "mail@reidbeels.com" | ||
= hidden_field_tag :phone, "" | ||
|
||
= hidden_field_tag :mentor_type, "" | ||
= hidden_field_tag :mentor_areas, "startup,strategy,raisingmoney,productdev" | ||
= hidden_field_tag :mentor_area_details, "startup_protection,startup_team,strategy_market,strategy_validation,strategy_size,funding_model,funding_decision,funding_amount,productdev_requirements,productdev_roadmap" | ||
= hidden_field_tag :mentee_area_other, "OTHER MARKETING,OTHER SALES,OTHER OPS,OTHER EXIT" | ||
|
||
= hidden_field_tag :mentee_type, "" | ||
= hidden_field_tag :mentee_area_details, "marketing_plan,marketing_budget,marketing_target-market,sales_sales-plan,sales_sales-budget,sales_comp-levels,operations_requirements,operations_office-space,exit_strategy,exit_valuation" | ||
= hidden_field_tag :mentee_areas, "marketing,sales,bizoperations,exitstrategy" | ||
= hidden_field_tag :mentor_area_other, "OTHER STARTUP,OTHER STRATEGY,OTHER FUNDRAISING,OTHER PRODUCT" | ||
|
||
= submit_tag "POST search request" | ||
|
||
= form_tag mentoring_profile_path, :method => :post do | ||
= hidden_field_tag :firstname, "Reid" | ||
= hidden_field_tag :lastname, "Beels" | ||
= hidden_field_tag :companyname, "Pixeldye" | ||
= hidden_field_tag :email, "mail3@reidbeels.com" | ||
= hidden_field_tag :phone, "" | ||
|
||
= hidden_field_tag :mentor_type, "" | ||
= hidden_field_tag :mentor_areas, "startup,strategy,raisingmoney,productdev" | ||
= hidden_field_tag :mentor_area_details, "startup_protection,startup_team,strategy_market,strategy_validation,strategy_size,funding_model,funding_decision,funding_amount,productdev_requirements,productdev_roadmap" | ||
= hidden_field_tag :mentee_area_other, "OTHER MARKETING,OTHER SALES,OTHER OPS,OTHER EXIT" | ||
|
||
= hidden_field_tag :mentee_type, "" | ||
= hidden_field_tag :mentee_area_details, "marketing_plan,marketing_budget,marketing_target-market,sales_sales-plan,sales_sales-budget,sales_comp-levels,operations_requirements,operations_office-space,exit_strategy,exit_valuation" | ||
= hidden_field_tag :mentee_areas, "marketing,sales,bizoperations,exitstrategy" | ||
= hidden_field_tag :mentor_area_other, "OTHER STARTUP,OTHER STRATEGY,OTHER FUNDRAISING,OTHER PRODUCT" | ||
|
||
= submit_tag "POST profile request" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CreateMentorshipTopics < ActiveRecord::Migration | ||
def change | ||
create_table :mentorship_topics do |t| | ||
t.string :name | ||
t.string :slug | ||
t.timestamps | ||
end | ||
|
||
create_table :person_mentor_topics do |t| | ||
t.belongs_to :person | ||
t.belongs_to :mentorship_topic | ||
end | ||
|
||
create_table :person_mentee_topics do |t| | ||
t.belongs_to :person | ||
t.belongs_to :mentorship_topic | ||
end | ||
end | ||
end |
Oops, something went wrong.