From f72fc5bd9ff81b822f46b9b0385820a42d88c8db Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Sun, 9 Sep 2018 20:08:56 +0800 Subject: [PATCH] added check for disabled user, employees can set resume status to be inactive and active --- app/controllers/recruitments_controller.rb | 23 ++++++++++++++++--- app/models/recruit_profile.rb | 8 +++++++ .../recruitments/account_settings.html.erb | 6 +++++ app/views/recruitments/index.html.erb | 9 +++++++- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/controllers/recruitments_controller.rb b/app/controllers/recruitments_controller.rb index d486166..3b604ae 100644 --- a/app/controllers/recruitments_controller.rb +++ b/app/controllers/recruitments_controller.rb @@ -147,8 +147,15 @@ class RecruitmentsController < PseudoSessionController if !OrbitHelper.current_user.nil? available = OrbitHelper.current_user.is_admin? end + if available || available == "true" + pu = PseudoUser.find(session[:current_pseudo_user_id]) + enabled = RecruitProfile.where(:pseudo_member_id => pu.user_name).first.enabled + else + enabled = false + end { "session" => available, + "enabled" => enabled, "url" => "/" + I18n.locale.to_s + page.url, "type" => OrbitHelper.params[:page_id] } @@ -633,10 +640,20 @@ class RecruitmentsController < PseudoSessionController def update_settings pu = PseudoUser.where(:user_name => @profile.pseudo_member_id).first - if pu.update_password(params[:password],params[:password_confirmation]) - redirect_to mydashboard_path + if params[:password].present? + if pu.update_password(params[:password],params[:password_confirmation]) + profile = @profile.profile + profile.active = params[:active].present? + profile.save + redirect_to mydashboard_path + else + redirect_to account_settings_path(:err => "1") + end else - redirect_to account_settings_path(:err => "1") + profile = @profile.profile + profile.active = params[:active].present? + profile.save + redirect_to mydashboard_path end end diff --git a/app/models/recruit_profile.rb b/app/models/recruit_profile.rb index 42a559d..dfda123 100644 --- a/app/models/recruit_profile.rb +++ b/app/models/recruit_profile.rb @@ -22,6 +22,14 @@ class RecruitProfile has_one :employer_profile, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :employer_profile, :allow_destroy => true + before_create :disable_employer + + + def disable_employer + if self.is_employer? + self.enabled = false + end + end def disable_user pu = PseudoUser.where(:user_name => self.pseudo_member_id).first diff --git a/app/views/recruitments/account_settings.html.erb b/app/views/recruitments/account_settings.html.erb index 7fa8e66..fb70369 100644 --- a/app/views/recruitments/account_settings.html.erb +++ b/app/views/recruitments/account_settings.html.erb @@ -6,6 +6,12 @@
<%= t("recruitment.pass_confirm_pass_do_not_match") %>
<% end %>
+
+ +
+ /> +
+
diff --git a/app/views/recruitments/index.html.erb b/app/views/recruitments/index.html.erb index ce3a823..ee9120e 100644 --- a/app/views/recruitments/index.html.erb +++ b/app/views/recruitments/index.html.erb @@ -1,6 +1,7 @@ <% thissession = action_data("check_session") %> <% if thissession["session"] == "true" || thissession["session"] == true %> - <%= render_view %> + <% if thissession["enabled"] == true %> + <%= render_view %>