Skip to content

Commit f1ba778

Browse files
committed
Man, got the app running for the most part but I'm thinking of renaming this branch RAT_KING
1 parent ae1ee05 commit f1ba778

12 files changed

+103
-66
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ group :development, :test do
162162
gem 'jazz_hands', github: 'nixme/jazz_hands', branch: 'bring-your-own-debugger'
163163
gem 'launchy'
164164
gem 'pry-byebug'
165-
gem 'pry-rescue'
166-
gem 'pry-stack_explorer'
165+
#gem 'pry-rescue'
166+
#gem 'pry-stack_explorer'
167167
gem 'quiet_assets'
168168
gem 'rspec-rails'
169169
gem 'syntax'

Gemfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ GEM
341341
httpauth (0.2.1)
342342
i18n (0.6.11)
343343
inflecto (0.0.2)
344-
interception (0.5)
345344
ipaddress (0.8.0)
346345
jbuilder (2.1.3)
347346
activesupport (>= 3.0.0, < 5)
@@ -489,9 +488,6 @@ GEM
489488
pry-remote (0.1.8)
490489
pry (~> 0.9)
491490
slop (~> 3.0)
492-
pry-rescue (1.4.1)
493-
interception (>= 0.5)
494-
pry
495491
pry-stack_explorer (0.4.9.1)
496492
binding_of_caller (>= 0.7)
497493
pry (>= 0.9.11)
@@ -809,8 +805,6 @@ DEPENDENCIES
809805
pg
810806
postgres_ext
811807
pry-byebug
812-
pry-rescue
813-
pry-stack_explorer
814808
pubnub (= 0.1.9)
815809
puma
816810
querystring

app/controllers/teams_controller.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,26 @@ def followed
3939
end
4040

4141
def show
42+
4243
show_params = params.permit(:job_id, :refresh, :callback, :id, :slug)
4344

4445
respond_to do |format|
4546
format.html do
4647
@team = team_from_params(slug: show_params[:slug], id: show_params[:id])
48+
4749
return render_404 if @team.nil?
50+
4851
@team_protips = @team.trending_protips(4)
4952
@query = "team:#{@team.slug}"
5053
viewing_user.track_team_view!(@team) if viewing_user
5154
@team.viewed_by(viewing_user || session_id) unless is_admin?
5255
@job = show_params[:job_id].nil? ? @team.jobs.sample : Opportunity.with_public_id(show_params[:job_id])
56+
5357
@other_jobs = @team.jobs.reject { |job| job.id == @job.id } unless @job.nil?
58+
5459
return render(:premium) if show_premium_page?
5560
end
61+
5662
format.json do
5763
options = { :expires_in => 5.minutes }
5864
options[:force] = true if !show_params[:refresh].blank?
@@ -92,7 +98,7 @@ def create
9298
end
9399

94100
#def team_to_regex(team)
95-
#team.name.gsub(/ \-\./, '.*')
101+
#team.name.gsub(/ \-\./, '.*')
96102
#end
97103

98104
def edit
@@ -259,11 +265,12 @@ def deny_join
259265

260266
protected
261267

262-
263268
def team_from_params(opts)
264-
return Team.where(slug: opts[:slug].downcase).first if opts[:slug].present?
265-
266-
Team.find(opts[:id])
269+
if opts[:slug].present?
270+
Team.where(slug: opts[:slug].downcase).first
271+
else
272+
Team.find(opts[:id])
273+
end
267274
end
268275

269276
def replace_section(section_name)

app/models/opportunity.rb

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ class Opportunity < ActiveRecord::Base
3535
#remove default scope
3636
default_scope valid
3737

38-
attr_accessor :title
39-
4038
HUMANIZED_ATTRIBUTES = { name: 'Title' }
4139

42-
#def team
43-
#@team ||= Team.find(team_document_id.to_s)
44-
#end
45-
46-
belongs_to :team
40+
belongs_to :team, class_name: 'Team', touch: true
4741

4842
def self.human_attribute_name(attr,options={})
4943
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
@@ -57,29 +51,27 @@ def self.parse_salary(salary_string)
5751
0
5852
else
5953
salary = number.to_i
60-
if thousands.downcase == 'k' or salary < 1000
54+
if thousands.downcase == 'k' || salary < 1000
6155
salary * 1000
6256
else
6357
salary
6458
end
6559
end
60+
end
6661

62+
def self.based_on(tags)
63+
query_string = "tags:#{tags.join(' OR ')}"
64+
failover_scope = Opportunity.joins('inner join taggings on taggings.taggable_id = opportunities.id').joins('inner join tags on taggings.tag_id = tags.id').where("taggings.taggable_type = 'Opportunity' AND taggings.context = 'tags'").where('lower(tags.name) in (?)', tags.map(&:downcase)).group('opportunities.id').order('count(opportunities.id) desc')
65+
Opportunity::Search.new(Opportunity, Opportunity::Search::Query.new(query_string), nil, nil, nil, failover: failover_scope).execute
66+
end
6767

68+
def self.with_public_id(public_id)
69+
where(public_id: public_id).first
70+
end
6871

69-
def based_on(tags)
70-
query_string = "tags:#{tags.join(' OR ')}"
71-
failover_scope = Opportunity.joins('inner join taggings on taggings.taggable_id = opportunities.id').joins('inner join tags on taggings.tag_id = tags.id').where("taggings.taggable_type = 'Opportunity' AND taggings.context = 'tags'").where('lower(tags.name) in (?)', tags.map(&:downcase)).group('opportunities.id').order('count(opportunities.id) desc')
72-
Opportunity::Search.new(Opportunity, Opportunity::Search::Query.new(query_string), nil, nil, nil, failover: failover_scope).execute
73-
end
74-
75-
def with_public_id(public_id)
76-
where(public_id: public_id).first
77-
end
78-
79-
def random
80-
uncached do
81-
order('RANDOM()')
82-
end
72+
def self.random
73+
uncached do
74+
order('RANDOM()')
8375
end
8476
end
8577

@@ -123,22 +115,22 @@ def destroy(force = false)
123115
if force
124116
super
125117
else
126-
self.deleted = true
127-
self.deleted_at = Time.now.utc
118+
deleted = true
119+
deleted_at = Time.now.utc
128120
save
129121
end
130122
end
131123

132124
def set_expiration
133-
self.expires_at = team.has_monthly_subscription? ? 1.year.from_now : 1.month.from_now
125+
expires_at = team.has_monthly_subscription? ? 1.year.from_now : 1.month.from_now
134126
end
135127

136128
def title
137129
name
138130
end
139131

140132
def title=(new_title)
141-
self.name = new_title
133+
name = new_title
142134
end
143135

144136
def accepts_applications?
@@ -210,12 +202,11 @@ def alive?
210202
end
211203

212204
def to_html
213-
CFM::Markdown.render self.description
205+
CFM::Markdown.render(self.description)
214206
end
215207

216208
def to_indexed_json
217209
to_public_hash.deep_merge(
218-
219210
public_id: public_id,
220211
name: name,
221212
description: description,
@@ -260,6 +251,7 @@ def assign_random_id
260251
end
261252

262253
protected
254+
263255
def set_location_city
264256
add_opportunity_locations_to_team
265257
locations = team.cities.compact.select { |city| location.include?(city) }

app/models/team.rb

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,22 @@ class Team < ActiveRecord::Base
4444
has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :delete_all
4545
has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id', dependent: :delete_all
4646
has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :delete_all
47+
48+
def featured_links
49+
links
50+
end
51+
4752
has_many :jobs, class_name: 'Opportunity', foreign_key: 'team_id', dependent: :destroy
4853

54+
#def jobs
55+
#all_jobs.valid
56+
#end
57+
58+
#Replaced with jobs
59+
def all_jobs
60+
jobs.order('created_at DESC')
61+
end
62+
4963
has_many :follows, class_name: 'FollowedTeam', foreign_key: 'team_id', dependent: :destroy
5064
has_many :followers, through: :follows, source: :team
5165

@@ -173,7 +187,7 @@ def locations
173187

174188
def locations_message
175189
if premium?
176-
team_locations.collect(&:name).join(', ')
190+
locations.collect(&:name).join(', ')
177191
else
178192
locations.join(', ')
179193
end
@@ -196,6 +210,11 @@ def on_team?(user)
196210
has_member?(user)
197211
end
198212

213+
def has_member?(user)
214+
team_members.include?(user)
215+
end
216+
217+
199218
def branding_hex_color
200219
branding || DEFAULT_HEX_BRAND
201220
end
@@ -330,7 +349,7 @@ def has_interview_steps?
330349
end
331350

332351
def has_locations?
333-
!team_locations.blank?
352+
!locations.blank?
334353
end
335354

336355
def has_featured_links?
@@ -616,23 +635,23 @@ def self.most_active_countries
616635
end
617636

618637
def primary_address
619-
team_locations.first.try(:address) || primary_address_name
638+
locations.first.try(:address) || primary_address_name
620639
end
621640

622641
def primary_address_name
623-
team_locations.first.try(:name)
642+
locations.first.try(:name)
624643
end
625644

626645
def primary_address_description
627-
team_locations.first.try(:description)
646+
locations.first.try(:description)
628647
end
629648

630649
def primary_points_of_interest
631-
team_locations.first.try(:points_of_interest).to_a
650+
locations.first.try(:points_of_interest).to_a
632651
end
633652

634653
def cities
635-
team_locations.map(&:city).reject { |city| city.blank? }
654+
locations.map(&:city).reject { |city| city.blank? }
636655
end
637656

638657
def generate_event
@@ -662,18 +681,10 @@ def active_job_titles
662681
active_jobs.collect(&:title).uniq
663682
end
664683

665-
def jobs
666-
all_jobs.valid
667-
end
668-
669-
#Replaced with jobs
670-
def all_jobs
671-
jobs.order('created_at DESC')
672-
end
673684

674685

675686

676-
SECTION_FIELDS = %w(about headline big_quote our_challenge benefit_description_1 organization_way office_photos stack_list reason_name_1 interview_steps team_locations blog_feed)
687+
SECTION_FIELDS = %w(about headline big_quote our_challenge benefit_description_1 organization_way office_photos stack_list reason_name_1 interview_steps locations blog_feed)
677688

678689

679690
def visitors_interested_in_jobs

app/models/teams/member.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Move team_banner to uhhh... the Team. Maybe that would make sense.
2+
13
class Teams::Member < ActiveRecord::Base
24
belongs_to :team, class_name: 'Team',
35
foreign_key: 'team_id',
@@ -20,6 +22,18 @@ def display_name
2022
name || username
2123
end
2224

25+
%i(
26+
banner
27+
city
28+
username
29+
avatar
30+
name
31+
about
32+
team_responsibilities
33+
).each do |user_method|
34+
delegate user_method, to: :user
35+
end
36+
2337
[:badges, :title, :endorsements].each do |m|
2438
define_method(m) { user.try(m) }
2539
end

app/models/user.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "net_validators"
1+
require 'net_validators'
22

33
class User < ActiveRecord::Base
44
include ActionController::Caching::Fragments
@@ -19,8 +19,9 @@ class User < ActiveRecord::Base
1919
attr_protected :admin, :id, :github_id, :twitter_id, :linkedin_id, :api_key
2020

2121
mount_uploader :avatar, AvatarUploader
22-
mount_uploader :banner, BannerUploader
2322
mount_uploader :resume, ResumeUploader
23+
24+
mount_uploader :banner, BannerUploader
2425
process_in_background :banner, ResizeTiltShiftBannerJob
2526

2627
RESERVED = %w{

app/views/users/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
%span.team-avatar=image_tag(@user.team.avatar_url, :width => 22, :height => 22)
149149
%div{:itemprop => :affiliation}=truncate("#{@user.team.name}", :length => 28)
150150
-if viewing_self?
151-
=link_to 'Leave team', team_team_member_path(@user.team, @user), :method => :delete, :confirm => "Are you sure you want to leave team #{@user.team.name}", :class => "leave-team track", 'data-action' => 'leave team', 'data-from' => 'profile page'
151+
= link_to 'Leave team', team_members_path([@user.team, @user]), :method => :delete, :confirm => "Are you sure you want to leave team #{@user.team.name}", :class => "leave-team track", 'data-action' => 'leave team', 'data-from' => 'profile page'
152152

153153
-elsif viewing_self?
154154
%li.team-self
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddScoreCacheToTeamsMembers < ActiveRecord::Migration
2+
def change
3+
add_column :teams_members, :score_cache, :float
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddTeamBannerToTeamsMember < ActiveRecord::Migration
2+
def change
3+
add_column :teams_members, :team_banner, :string
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddTeamAvatarToTeamsMember < ActiveRecord::Migration
2+
def change
3+
add_column :teams_members, :team_avatar, :string
4+
end
5+
end

db/schema.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20140918031936) do
14+
ActiveRecord::Schema.define(:version => 20140919042707) do
1515

1616
add_extension "citext"
1717
add_extension "hstore"
@@ -462,11 +462,14 @@
462462
end
463463

464464
create_table "teams_members", :force => true do |t|
465-
t.integer "team_id", :null => false
466-
t.integer "user_id", :null => false
467-
t.datetime "created_at", :null => false
468-
t.datetime "updated_at", :null => false
469-
t.string "state", :default => "pending"
465+
t.integer "team_id", :null => false
466+
t.integer "user_id", :null => false
467+
t.datetime "created_at", :null => false
468+
t.datetime "updated_at", :null => false
469+
t.string "state", :default => "pending"
470+
t.float "score_cache"
471+
t.string "team_banner"
472+
t.string "team_avatar"
470473
end
471474

472475
create_table "tokens", :force => true do |t|

0 commit comments

Comments
 (0)