changed the way to display city and stuff

This commit is contained in:
Harry Bomrah 2017-05-26 15:39:22 +08:00
parent c3f317e282
commit a35db2bd35
2 changed files with 23 additions and 10 deletions

View File

@ -4,10 +4,24 @@ class MemberCounselorsController < CUserController
def index def index
idx = 0 idx = 0
params = OrbitHelper.params
pcity = nil
page = Page.where(:page_id => params[:page_id]).first
cities = HpsCity.all.collect do |city| cities = HpsCity.all.collect do |city|
total = 0 total = city.hps_files.count
pcity = city if idx == 0
idx = idx + 1 idx = idx + 1
schools = city.hps_schools.collect do |school| {
"name" => city.name,
"total" => total,
"url" => "/" + I18n.locale.to_s + page.url + "?city_id=#{city.id.to_s}"
}
end
if params[:city_id].present?
pcity = HpsCity.find(params[:city_id])
end
total = 0
schools = pcity.hps_schools.collect do |school|
members = HpsMember.where(:hps_school_id => school.id.to_s).pluck(:id) members = HpsMember.where(:hps_school_id => school.id.to_s).pluck(:id)
count = HpsFile.where(:hps_member_id.in => members).count count = HpsFile.where(:hps_member_id.in => members).count
total = count + total total = count + total
@ -17,15 +31,9 @@ class MemberCounselorsController < CUserController
"count" => count "count" => count
} }
end end
{
"name" => city.name,
"total" => total,
"id" => "tab#{idx}",
"schools" => schools
}
end
{ {
"cities" => cities, "cities" => cities,
"schools" => schools,
"extras" => {} "extras" => {}
} }
end end
@ -104,6 +112,8 @@ class MemberCounselorsController < CUserController
def file_upload def file_upload
hpsfile = HpsFile.new(hps_file_params) hpsfile = HpsFile.new(hps_file_params)
hpsfile.hps_member = current_counselor_user hpsfile.hps_member = current_counselor_user
city = HpsCity.find(current_counselor_user.hps_city_id)
hpsfile.hps_city = city
hpsfile.save hpsfile.save
redirect_to member_dash_path(current_counselor_user.account) redirect_to member_dash_path(current_counselor_user.account)
end end

View File

@ -49,7 +49,10 @@
</tr> </tr>
<tr> <tr>
<th>&nbsp;</th> <th>&nbsp;</th>
<td><%= f.submit "Submit", :class => "btn btn-primary" %><a href="<%= member_dash_path(current_counselor_user.account) %>" class="btn btn-default">Back</a></td> <td>
<%= f.submit "Submit", :class => "btn btn-primary" %>
<a href="<%= member_dash_path(current_counselor_user.account) %>" class="btn btn-default">Back</a>
</td>
</tr> </tr>
</table> </table>