class PortalTemplatesController < ApplicationController def index offers = Offer.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) offer_list = offers.collect do |offer| { "member" => (offer.member_profile.name rescue ""), "offer_title" => offer.offer_title, "link_to_show" => OrbitHelper.url_to_show(offer.to_param) } end { "offers" => offer_list, "extras" => { "widget-title" => t("module_name.portal_template"), "th_member" => t('users.name'), "th_offer_title" => t('portal_template.offer_title'), "th_detail" => t('detail') }, "total_pages" => offers.total_pages } end def show params = OrbitHelper.params plugin = Offer.where(:is_hidden=>false).find_by(uid: params[:uid].to_s) fields_to_show = [ "offer_title" ] has_applied = OfferApplication.where(:member_profile_id => OrbitHelper.current_user.member_profile.id, :offer_id => plugin.id).count > 0 if !has_applied && params[:status] == "apply" application = OfferApplication.new application.member_profile_id = OrbitHelper.current_user.member_profile.id application.offer_id = plugin.id application.save has_applied = true end user_roles = OrbitHelper.current_user.member_profile.roles.pluck(:id) ps = PortalSetting.first.applicant_role apply_button = user_roles.include?(ps) if apply_button if has_applied apply_button = "
Applied
" else apply_button = "Apply" end else apply_button = "" end { "plugin_datas"=>plugin.get_plugin_data(fields_to_show), "extras" => { "apply_button" => apply_button } } end end