Skip to content

Commit

Permalink
Merge pull request #49 from reidab/with_mentoring_i18n
Browse files Browse the repository at this point in the history
Merge mentoring features with i18n work
  • Loading branch information
reidab committed Nov 5, 2011
2 parents 5ac57b1 + 0c40923 commit f8a437a
Show file tree
Hide file tree
Showing 34 changed files with 185 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ vagrant/cookbooks/vagrant/recipes/local.rb
tags
app/stylesheets/custom.sass
app/views/layouts/_custom_css_includes.html.haml
.rvmrc
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ GEM
faraday (0.6.1)
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
rack (>= 1.1.0, < 2)
rack (< 2, >= 1.1.0)
faraday_middleware (0.6.5)
faraday (~> 0.6.0)
ffi (1.0.9)
Expand All @@ -115,8 +115,8 @@ GEM
activesupport (>= 2.3.7)
i18n (~> 0.4)
foursquare2 (1.1.2)
faraday (>= 0.6, < 0.8)
faraday_middleware (>= 0.6, < 0.8)
faraday (< 0.8, >= 0.6)
faraday_middleware (< 0.8, >= 0.6)
hashie (~> 1.0)
fssm (0.2.7)
haml (3.1.3)
Expand All @@ -143,8 +143,8 @@ GEM
rbx-require-relative (> 0.0.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
macaddr (1.4.0)
systemu (~> 2.2.0)
macaddr (1.5.0)
systemu (>= 2.4.0)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -210,7 +210,7 @@ GEM
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
mime-types
polyglot (0.3.2)
polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.3)
rack (1.3.5)
rack-cache (1.0.3)
Expand Down Expand Up @@ -251,7 +251,7 @@ GEM
responders (0.6.4)
rest-client (1.6.7)
mime-types (>= 1.16)
riddle (1.4.0)
riddle (1.5.0)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
Expand Down Expand Up @@ -300,15 +300,15 @@ GEM
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
tilt (!= 1.3.0, ~> 1.1)
steak (2.0.0)
capybara (>= 1.0.0)
rspec-rails (>= 2.5.0)
systemu (2.2.0)
thinking-sphinx (2.0.9)
systemu (2.4.0)
thinking-sphinx (2.0.10)
activerecord (>= 3.0.3)
builder (>= 2.1.2)
riddle (>= 1.3.3)
riddle (>= 1.5.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class ApplicationController < ActionController::Base

protected

def mentoring_enabled?
SETTINGS['mentoring']
end
helper_method :mentoring_enabled?

def random_sort_clause
seed = session["#{controller_name}_random_sort_seed"] ||= rand(2147483647)
direction = %w(asc desc).include?(params[:order]) ? params[:order].upcase : ''
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def claim
protected

def collection
@people ||= filter_sort_and_paginate(end_of_association_chain, true)
people = end_of_association_chain
people = people.mentors if mentoring_enabled? && params[:mentors]
people = people.mentees if mentoring_enabled? && params[:mentees]

@people ||= filter_sort_and_paginate(people, true)
end

def require_owner_or_admin!
Expand Down
13 changes: 13 additions & 0 deletions app/helpers/people_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
module PeopleHelper
def people_list_title(list, tag)
title_key = 'title'
if mentoring_enabled?
title_key = 'mentor_title' if params[:mentors]
title_key = 'mentee_title' if params[:mentees]
end

semantic_pluralize(
list.respond_to?(:total_entries) ? list.total_entries : list.size,
t("people.index.#{title_key}.one", :tag => tag).strip.titleize,
t("people.index.#{title_key}.other", :tag => tag).strip
)
end
end
3 changes: 3 additions & 0 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Person < ActiveRecord::Base

scope :claimed, where('user_id IS NOT null')
scope :unclaimed, where('user_id IS null')
scope :mentors, where('interested_mentor IS true')
scope :mentees, where('interested_mentee IS true')


private

Expand Down
3 changes: 3 additions & 0 deletions app/stylesheets/desktop.sass
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ body
#authentications
+grid(6,16)
+omega
#view_options
.show
padding-left: 20px

div#creepy-baby-sloth
margin: 2em auto 0 auto
Expand Down
2 changes: 1 addition & 1 deletion app/views/companies/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- context ||= :general
%ul{:class => 'resource_list companies'}
%ul.resource_list.companies
= render :partial => 'companies/list_item', :collection => list, :locals => {:context => context}
= render :partial => 'shared/list_pagination', :object => list
6 changes: 3 additions & 3 deletions app/views/companies/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%h3
=link_to list_item.name, company_path(list_item)
- if list_item.twitter.present?
%span{:class => 'twitter_link'}
%span.twitter_link
= t('people.list.on_twitter', :link => twitter_link(list_item.twitter)).html_safe
-#%p{:class=>'location'}= person['location']
%p{:class=>'description'}= truncate(strip_links(list_item.description), :length => 350)
-#%p.location= person['location']
%p.description= truncate(strip_links(list_item.description), :length => 350)
2 changes: 1 addition & 1 deletion app/views/companies/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- content_for(:section_header) do
.section_header{:class => 'companies'}
.section_header.companies
%h1= semantic_pluralize(@companies.respond_to?(:total_entries) ? @companies.total_entries : @companies.size, t('company.index.title.one',{:tag => @tag}).strip.titleize, t('company.index.title.other',{:tag => @tag}).strip.titleize)
= link_to t('company.button.add'), new_company_path, :class => 'new'
#view_options
Expand Down
2 changes: 1 addition & 1 deletion app/views/groups/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- context ||= :general
%ul{:class => 'resource_list groups'}
%ul.resource_list.groups
= render :partial => 'groups/list_item', :collection => list, :locals => {:context => context}
= render :partial => 'shared/list_pagination', :object => list
6 changes: 3 additions & 3 deletions app/views/groups/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%h3
=link_to list_item.name, group_path(list_item)
- if list_item.twitter.present?
%span{:class => 'twitter_link'}
%span.twitter_link
= t('people.list.on_twitter', :link => twitter_link(list_item.twitter)).html_safe
-#%p{:class=>'location'}= person['location']
%p{:class=>'description'}= truncate(strip_links(list_item.description), :length => 350)
-#%p.location= person['location']
%p.description= truncate(strip_links(list_item.description), :length => 350)
2 changes: 1 addition & 1 deletion app/views/groups/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- content_for(:section_header) do
.section_header{:class => 'groups'}
.section_header.groups
%h1= semantic_pluralize(@groups.respond_to?(:total_entries) ? @groups.total_entries : @groups.size, t('group.index.title.one',{:tag => @tag}).strip.titleize, t('group.index.title.other',{:tag => @tag}).strip.titleize)
= link_to t('group.button.add'), new_group_path, :class => 'new'
#view_options
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
%h1
%a{:href => root_path}
="#{SETTINGS['organization']['logotype']}".html_safe
%img{:class => 'home_marker', :src => '/images/home_12x12.png',
:height => 12, :width => 12}
%img.home_marker{:src => '/images/home_12x12.png', :height => 12, :width => 12}
#account_box{:class => current_user.try(:admin?) ? 'admin' : nil}
- if current_user.present?
- if current_user.avatar_url
Expand Down
6 changes: 6 additions & 0 deletions app/views/people/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
= f.input :bio
= f.input :tag_list, :as => :text, :input_html => {:class => 'tags'}
= f.input :technology_list, :as => :text, :input_html => {:class => 'tags'}
- if mentoring_enabled?
= f.inputs :name => t('people.field.mentoring.title') do
= f.input :interested_mentor
= f.input :mentor_topics
= f.input :interested_mentee
= f.input :mentee_topics
= import_image_from_url_tags_for f, @person, :photo
= f.input :reviewed, :input_html => {:value => true}, :as => :hidden
- if current_user.admin?
Expand Down
2 changes: 1 addition & 1 deletion app/views/people/_grid.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- context ||= :general
%ul{:class => 'resource_grid people'}
%ul.resource_grid.people
= render :partial => 'people/grid_item', :collection => grid, :locals => {:context => context}
= render :partial => 'shared/list_pagination', :object => grid
2 changes: 1 addition & 1 deletion app/views/people/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- context ||= :general
%ul{:class => 'resource_list people'}
%ul.resource_list.people
= render :partial => 'people/list_item', :collection => list, :locals => {:context => context}
= render :partial => 'shared/list_pagination', :object => list
8 changes: 6 additions & 2 deletions app/views/people/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
%h3
=link_to list_item.name, person_path(list_item)
- if list_item.twitter.present?
%span{:class => 'twitter_link'}
%span.twitter_link
= t('people.list.on_twitter', :link => twitter_link(list_item.twitter)).html_safe
%p{:class=>'bio'}= strip_links(list_item.bio)
%p.bio= strip_links(list_item.bio)
- if params[:mentors]
%p.bio= list_item.mentor_topics
- elsif params[:mentees]
%p.bio= list_item.mentee_topics
- if context == :claim
.actions
= link_to t('people.button.claim'), claim_person_path(list_item), :class => 'claim'
12 changes: 10 additions & 2 deletions app/views/people/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- content_for(:section_header) do
.section_header{:class => 'people'}
%h1= semantic_pluralize(@people.respond_to?(:total_entries) ? @people.total_entries : @people.size, t('people.index.title.one', :tag => @tag).strip.titleize, t('people.index.title.other', :tag => @tag).strip.titleize)
.section_header.people
%h1= people_list_title(@people, @tag)
= link_to t('people.button.add'), new_person_path, :class => 'new', :id => 'new_person'
#view_options
%span.sorting
Expand All @@ -15,6 +15,14 @@
= link_to_unless_current t('list.view_as.list'), people_path(:page => params[:page], :column => params[:column], :order => params[:order])
= "|"
= link_to_unless_current t('list.view_as.grid'), grid_people_path(:page => params[:page], :column => params[:column], :order => params[:order])
%span.show
%strong= t('list.mentor_filter.title') + ':'
= link_to_unless_current t('list.mentor_filter.all'), people_path(:page => params[:page], :column => params[:column], :order => params[:order])
= "|"
= link_to_unless_current t('list.mentor_filter.mentors'), mentors_people_path(:page => params[:page], :column => params[:column], :order => params[:order])
= "|"
= link_to_unless_current t('list.mentor_filter.mentees'), mentees_people_path(:page => params[:page], :column => params[:column], :order => params[:order])


- if @view == :grid
= render :partial => 'grid', :object => @people
Expand Down
6 changes: 3 additions & 3 deletions app/views/people/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


- if @found_people.present?
%ul{:id => 'people_search_results', :class => 'resource_list people'}
%ul#people_search_results.resource_list.people
- @found_people.each do |person|
%li{:class => [person.new_record? ? person.imported_from_provider : 'existing']}
- if (photo_url = person.photo_import_url || person.photo.url).present?
Expand All @@ -37,8 +37,8 @@
- if person.imported_from_provider == 'twitter' && person.imported_from_screen_name.present?
%strong
= t('people.list.on_twitter', :link => twitter_link(person.imported_from_screen_name)).html_safe
%p{:class=>'location'}= person.location
%p{:class=>'bio'}= person.bio
%p.location= person.location
%p.bio= person.bio
- if !person.new_record?
.existing_user_label
= t('people.new.name_knows_known', :name => SETTINGS['organization']['name'], :known => person.name)
Expand Down
12 changes: 12 additions & 0 deletions app/views/people/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
%h2= t('field.project_list.title')
= render :partial => 'projects/list', :object => @person.projects

- if mentoring_enabled?

- if @person.interested_mentor
.section.mentor
%h2= t('people.field.mentor_topics.title')
%p= @person.mentor_topics

- if @person.interested_mentee
.section.mentee
%h2= t('people.field.mentee_topics.title')
%p= @person.mentee_topics

.record_actions
- if current_user && (current_user.admin? || current_user.person == @person)
= link_to t('button.edit'), edit_person_path(@person), :class => 'edit'
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- context ||= :general
%ul{:class => 'resource_list projects'}
%ul.resource_list.projects
= render :partial => 'projects/list_item', :collection => list, :locals => {:context => context}
= render :partial => 'shared/list_pagination', :object => list
6 changes: 3 additions & 3 deletions app/views/projects/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%h3
=link_to list_item.name, project_path(list_item)
- if list_item.twitter.present?
%span{:class => 'twitter_link'}
%span.twitter_link
= t('people.list.on_twitter', :link => twitter_link(list_item.twitter)).html_safe
-#%p{:class=>'location'}= person['location']
%p{:class=>'description'}= truncate(strip_links(list_item.description), :length => 350)
-#%p.location= person['location']
%p.description= truncate(strip_links(list_item.description), :length => 350)
2 changes: 1 addition & 1 deletion app/views/projects/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- content_for(:section_header) do
.section_header{:class => 'projects'}
.section_header.projects
%h1= semantic_pluralize(@projects.respond_to?(:total_entries) ? @projects.total_entries : @projects.size, t('project.index.title.one', :tag => @tag).strip.titleize.html_safe, t('project.index.title.other', :tag => @tag).strip.titleize.html_safe)
= link_to t('project.button.add'), new_project_path, :class => 'new'
#view_options
Expand Down
2 changes: 1 addition & 1 deletion app/views/resource_links/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
%li.resource_link
%h3
=link_to "#{list_item.category}: #{list_item.name}", normalize_url(list_item.url)
%p{:class=>'description'}= truncate(strip_links(list_item.description), :length => 350)
%p.description= truncate(strip_links(list_item.description), :length => 350)

4 changes: 2 additions & 2 deletions app/views/resource_links/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- content_for(:section_header) do
.section_header{:class => 'resources'}
.section_header.resources
%h1= semantic_pluralize(ResourceLink.count, t('resource_links.index.title.one', :tag => @tag).strip.titleize, t('resource_links.index.title.other', :tag => @tag).strip.titleize)
= link_to t('resource_links.button.add'), url_for(:action => :new), :class => 'new'

- @resource_links.keys.sort.each do |category|
%h2 #{category}
%ul{:class => 'resources'}
%ul.resources
- @resource_links[category].sort_by(&:name).each do |resource|
%li{:id => resource.id}
%a{:href => normalize_url(resource.url)}
Expand Down
2 changes: 1 addition & 1 deletion app/views/site/_display_errors_for.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- if record.errors.any?
%ul{:class => 'record_errors errors'}
%ul.record_errors.errors
- for error in record.errors.full_messages
%li
= error
2 changes: 1 addition & 1 deletion app/views/users/home.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- content_for(:section_header) do
.section_header{:class => 'events'}
.section_header.events
%h1= t('user.home.title')

#user_home
Expand Down
Loading

0 comments on commit f8a437a

Please sign in to comment.