Skip to content

Commit 5b0892d

Browse files
committed
Fixed broken link and use the new Team model name.
1 parent e35367a commit 5b0892d

File tree

5 files changed

+30
-132
lines changed

5 files changed

+30
-132
lines changed

app/models/followed_team.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class FollowedTeam < ActiveRecord::Base
2-
belongs_to :team, class_name: 'PgTeam'
2+
belongs_to :team, class_name: 'Team'
33
belongs_to :user
44
end
55

app/models/pg_team.rb

Lines changed: 0 additions & 107 deletions
This file was deleted.

app/models/team.rb

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@
33

44
#Rename to Team when Mongodb is dropped
55
class Team < ActiveRecord::Base
6+
DEFAULT_HEX_BRAND = '#343131'
7+
LEADERBOARD_KEY = 'teams:leaderboard'
8+
FEATURED_TEAMS_CACHE_KEY = 'featured_teams_results'
9+
MAX_TEAM_SCORE = 400
10+
11+
self.table_name = 'teams'
12+
613
include SearchModule
714
include TeamSearch
15+
include LeaderboardRedisRank
16+
include TeamAnalytics
17+
include TeamMigration
18+
19+
mount_uploader :avatar, TeamUploader
20+
821
mapping team: {
922
properties: {
1023
id: { type: 'string', index: 'not_analyzed' },
@@ -27,35 +40,33 @@ class Team < ActiveRecord::Base
2740
}
2841
}
2942

30-
include LeaderboardRedisRank
31-
include TeamAnalytics
32-
include TeamMigration
43+
scope :featured, ->{ where(premium: true, valid_jobs: true, hide_from_featured: false) }
3344

34-
DEFAULT_HEX_BRAND = '#343131'
35-
LEADERBOARD_KEY = 'teams:leaderboard'
36-
FEATURED_TEAMS_CACHE_KEY = 'featured_teams_results'
37-
MAX_TEAM_SCORE = 400
3845

39-
self.table_name = 'teams'
46+
before_validation :create_slug!
47+
48+
validates :slug, uniqueness: true, presence: true
49+
4050

41-
#TODO add inverse_of
42-
has_one :account, class_name: 'Teams::Account', foreign_key: 'team_id', dependent: :delete
51+
has_many :followers, through: :follows, source: :team
4352

44-
has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :delete_all
45-
has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id', dependent: :delete_all
53+
has_many :follows, class_name: 'FollowedTeam', foreign_key: 'team_id', dependent: :destroy
54+
has_many :jobs, class_name: 'Opportunity', foreign_key: 'team_id', dependent: :destroy
55+
has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id', dependent: :delete_all
4656
has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :delete_all
57+
has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :delete_all
58+
has_one :account, class_name: 'Teams::Account', foreign_key: 'team_id', dependent: :delete
4759

4860
def featured_links
4961
links
5062
end
5163

5264
has_many :jobs, class_name: 'Opportunity', foreign_key: 'team_id', dependent: :destroy
5365

54-
#def jobs
55-
#all_jobs.valid
56-
#end
66+
private def create_slug!
67+
self.slug = name.parameterize
68+
end
5769

58-
#Replaced with jobs
5970
def all_jobs
6071
jobs.order('created_at DESC')
6172
end
@@ -186,10 +197,6 @@ def university?
186197
true
187198
end
188199

189-
def locations
190-
(location || '').split(';').collect { |location| location.strip }
191-
end
192-
193200
def locations_message
194201
if premium?
195202
locations.collect(&:name).join(', ')

app/models/teams/location.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ class Teams::Location < ActiveRecord::Base
22
include Geocoder::Model::ActiveRecord
33

44
# Rails 3 is stupid
5-
belongs_to :team, class_name: 'Team',
6-
foreign_key: 'team_id',
7-
touch: true
5+
belongs_to :team, class_name: 'Team', foreign_key: 'team_id', touch: true
86

97
geocoded_by :address do |obj, results|
108
if geo = results.first and obj.address.downcase.include?(geo.city.try(:downcase) || "")

app/uploaders/team_uploader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class TeamUploader < CoderwallUploader
33
process resize_and_pad: [100, 100]
44

55
def store_dir
6-
"/uploads/team/avatar/#{model.mongo_id || model.id}"
6+
"uploads/team/avatar/#{model.mongo_id || model.id}"
77
end
88

99
def default_url

0 commit comments

Comments
 (0)