@@ -21,16 +21,15 @@ def apply
21
21
end
22
22
23
23
def new
24
- team_id = params . permit ( :team_id ) [ :team_id ]
25
- @job = Opportunity . new ( team_document_id : team_id )
24
+ team_id = params [ :team_id ]
25
+ @job = Opportunity . new ( team_id : team_id )
26
26
end
27
27
28
28
def edit
29
-
30
29
end
31
30
32
31
def create
33
- opportunity_create_params = params . require ( :opportunity ) . permit ( :name , :team_document_id , :opportunity_type , :description , :tags , :location , :link , :salary , :apply )
32
+ opportunity_create_params = params . require ( :opportunity ) . permit ( :name , :team_id , :opportunity_type , :description , :tags , :location , :link , :salary , :apply )
34
33
@job = Opportunity . new ( opportunity_create_params )
35
34
respond_to do |format |
36
35
if @job . save
@@ -43,7 +42,7 @@ def create
43
42
end
44
43
45
44
def update
46
- opportunity_update_params = params . require ( :opportunity ) . permit ( :id , :name , :team_document_id , :opportunity_type , :description , :tags , :location , :link , :salary , :apply )
45
+ opportunity_update_params = params . require ( :opportunity ) . permit ( :id , :name , :team_id , :opportunity_type , :description , :tags , :location , :link , :salary , :apply )
47
46
respond_to do |format |
48
47
if @job . update_attributes ( opportunity_update_params )
49
48
format . html { redirect_to teamname_path ( @team . slug ) , notice : "#{ @job . name } updated" }
@@ -73,22 +72,30 @@ def visit
73
72
74
73
def index
75
74
current_user . seen ( :jobs ) if signed_in?
76
- store_location! if ! signed_in?
75
+ store_location! unless signed_in?
77
76
chosen_location = ( params [ :location ] || closest_to_user ( current_user ) ) . try ( :titleize )
78
- chosen_location = nil if chosen_location == "Worldwide"
79
- @page = params [ :page ] . try ( :to_i ) || 1
80
- tag = params [ :skill ] . gsub ( /\- / , ' ' ) . downcase unless params [ :skill ] . nil?
81
- @jobs = get_jobs_for ( chosen_location , tag , @page )
82
- @jobs_left = @jobs . count
83
- @jobs = @jobs . limit ( 20 )
84
- chosen_location = "Worldwide" if chosen_location . nil?
85
- @locations = Rails . cache . fetch ( "job_locations_#{ params [ :location ] } _#{ params [ :skill ] } " , expires_in : 1 . hour ) { Opportunity . by_tag ( tag ) . map ( &:locations ) . flatten . reject { |loc | loc == "Worldwide" } . push ( "Worldwide" ) . uniq . compact }
77
+ chosen_location = nil if chosen_location == 'Worldwide'
78
+
79
+ @page = params [ :page ] . try ( :to_i ) || 1
80
+ tag = params [ :skill ] . gsub ( /\- / , ' ' ) . downcase unless params [ :skill ] . nil?
81
+
82
+
83
+ @jobs = get_jobs_for ( chosen_location , tag , @page )
84
+ @jobs_left = @jobs . count
85
+ @jobs = @jobs . limit ( 20 )
86
+
87
+
88
+
89
+ chosen_location = 'Worldwide' if chosen_location . nil?
90
+ @locations = Rails . cache . fetch ( "job_locations_#{ params [ :location ] } _#{ params [ :skill ] } " , expires_in : 1 . hour ) do
91
+ Opportunity . by_tag ( tag ) . map ( &:locations ) . flatten . reject { |loc | loc == "Worldwide" } . push ( "Worldwide" ) . uniq . compact
92
+ end
86
93
@locations . delete ( chosen_location ) unless @locations . frozen?
87
94
params [ :location ] = chosen_location
88
- @lat , @lng = geocode_location ( chosen_location )
95
+ @lat , @lng = geocode_location ( chosen_location )
89
96
90
97
respond_to do |format |
91
- format . html { render layout : " jobs" }
98
+ format . html { render layout : ' jobs' }
92
99
format . json { render json : @jobs . map ( &:to_public_hash ) . to_json }
93
100
format . js
94
101
end
@@ -97,10 +104,11 @@ def index
97
104
98
105
def map
99
106
@job_locations = all_job_locations
100
- @job_skills = all_job_skills
107
+ @job_skills = all_job_skills
101
108
end
102
109
103
110
private
111
+
104
112
def validate_permissions
105
113
redirect_to :back unless team_admin?
106
114
end
@@ -160,6 +168,8 @@ def get_jobs_for(chosen_location, tag, page)
160
168
scope = Opportunity
161
169
scope = scope . by_city ( chosen_location ) unless chosen_location . nil?
162
170
scope = scope . by_tag ( tag ) unless tag . nil?
171
+ # TODO: Verify that there are no unmigrated teams
172
+ scope = scope . where ( 'team_id is not null' )
163
173
scope . offset ( ( page -1 ) * 20 )
164
174
end
165
175
end
0 commit comments