allow filter lessons by posa card type

This commit is contained in:
Seth Call 2018-01-16 19:59:22 -06:00
parent 98620efdde
commit 8c27f82cf4
3 changed files with 38 additions and 6 deletions

View File

@ -21,8 +21,8 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
#filter :teacher_user_email_cont, label: 'Student Name', as: :string
filter :student_full_name_or_user_email_cont, label: 'Student Name Or Email', as: :string
filter :by_search_teacher_in, label: 'Teacher Name Or Email', as: :string
filter :by_lesson_package_type_in, label: 'Package Type', as: :select, collection: -> { LessonPackageType.all.map {|t| [t.admin_name, t.id]}}
controller do
active_admin_config.includes.push :teacher, :music_session
@ -139,7 +139,7 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
row "Billed" do |lesson_session|
span do
if lesson_session.is_test_drive?
return 'N/A (because is Test Drive)'
'N/A (because is Test Drive)'
else
lesson_session.billed
end
@ -171,6 +171,18 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
end
end
end
row "Chat Messages" do |lesson_session|
div do
table_for ChatMessage.unscoped.where(lesson_session:lesson_session).order(:created_at) do
column :created_at
column do |chat_msg| chat_msg.purpose ? chat_msg.purpose : 'Chat Msg' end
column 'Sender' do |chat_msg| link_to(chat_msg.user.name, chat_msg.user.admin_url) end
column :target_user do |chat_msg| chat_msg.target_user ? link_to(chat_msg.target_user.name, chat_msg.target_user.admin_url) : '' end
column :message
column :id
end
end
end
end
end

View File

@ -13,15 +13,20 @@ class JamRuby::LessonSession
ransacker :by_search_teacher,
formatter: proc { |teacher_name|
puts "TEACHER NAME #{teacher_name}"
ilikey = "%#{teacher_name}%"
results = LessonSession.joins(:teacher).where('(users.email ilike ?) OR (LOWER(concat_ws(\' \', "users"."first_name", "users"."last_name")) ilike ?)', ilikey, ilikey).map(&:id)
#results = LessonSession.search(teacher_full_name_or_user_email_cont: teacher_name).result.map(&:id)
results = results.present? ? results : nil
}, splat_params: true do |parent|
puts "PARENT #{parent}"
parent.table[:id]
#Teacher.arel_table[:id]
end
ransacker :by_lesson_package_type,
formatter: proc { |lesson_package_type_id|
results = LessonSession.joins(:lesson_booking => [:posa_card]).where('posa_cards.lesson_package_type_id = ? ', lesson_package_type_id).map(&:id)
results = results.present? ? results : nil
}, splat_params: true do |parent|
parent.table[:id]
end
end

View File

@ -159,5 +159,20 @@ module JamRuby
def to_s
sale_display
end
def admin_name
admin = name
if is_amazon?
admin = admin + " (Amazon "
if id == AMAZON_TEST_DRIVE_FREE_2_ID
admin = admin + "Free)"
else
admin = admin + "Paid)"
end
end
admin
end
end
end