diff --git a/app/controllers/member_counselors_controller.rb b/app/controllers/member_counselors_controller.rb index ada6ba3..1a888a1 100644 --- a/app/controllers/member_counselors_controller.rb +++ b/app/controllers/member_counselors_controller.rb @@ -3,6 +3,67 @@ class MemberCounselorsController < CUserController before_filter :is_user_authorized?, :only => ["show"] def index + idx = 0 + cities = HpsCity.all.collect do |city| + total = 0 + idx = idx + 1 + schools = city.hps_schools.collect do |school| + count = HpsMember.where(:hps_school_id => school.id.to_s).count + total = count + total + { + "name" => school.name, + "url_to_show" => OrbitHelper.url_to_show(school.to_param) + "?method=proposals", + "count" => count + } + end + { + "name" => city.name, + "total" => total, + "id" => "tab#{idx}", + "schools" => schools + } + end + { + "cities" => cities, + "extras" => {} + } + end + + def proposals + params = OrbitHelper.params + school = HpsSchool.where(:uid => params[:uid]).first + members = HpsMember.where(:hps_school_id => school.id.to_s) + page = Page.where(:page_id => params[:page_id]).first + files = [] + members.each do |member| + member.hps_files.each do |file| + files << { + "title" => file.title, + "download_count" => file.download_count, + "url" => "/cuser/download?file_id=#{file.id.to_s}" + } + end + end + { + "files" => files, + "data" => { + "back-url" => "/" + I18n.locale.to_s + page.url + } + } + end + + def download + file_id = params[:file_id] + file = HpsFile.find(file_id) rescue nil + if !file.nil? + file.download_count = file.download_count + 1 + file.save + redirect_to file.file.url and return + end + render :nothing => true + end + + def login if !current_counselor_user.nil? redirect_to member_dash_path(current_counselor_user.account) end diff --git a/app/models/hps_school.rb b/app/models/hps_school.rb index ec4fe60..16c5118 100644 --- a/app/models/hps_school.rb +++ b/app/models/hps_school.rb @@ -1,9 +1,10 @@ class HpsSchool include Mongoid::Document include Mongoid::Timestamps + include Slug field :old_id - field :name + field :name, as: :slug_title field :address field :telephone field :land diff --git a/app/views/member_counselors/_form.html.erb b/app/views/member_counselors/_form.html.erb index 1b8c7f8..ebb763b 100644 --- a/app/views/member_counselors/_form.html.erb +++ b/app/views/member_counselors/_form.html.erb @@ -31,9 +31,9 @@ <% if @hpsfile.new_record? %> <% case current_counselor_user.user_type %> <% when 0 %> - -