class Admin::TutorsController

Public Instance Methods

export_tutors() click to toggle source

Method to export all Tutor in csv file containing its username and email.

# File app/controllers/admin/tutors_controller.rb, line 76
def export_tutors
  @tutors = User.where('type = "Tutor"').order('created_at desc')
  report = CSV.generate() do |csv|
    csv << ['Username', 'Email']
    @tutors.each do |t|
      username = t.name.nil? ? '-' : t.name
      email    = t.email
      csv << [username, email]
    end
  end

  send_data( report,
    :type => 'text/csv; charset=utf-8; header=present',
    :disposition => "attachment; filename=tutors_list.csv" )
end
intimate_profile_completion() click to toggle source

Used to send mail to intimate Tutor to complete profile.

# File app/controllers/admin/tutors_controller.rb, line 6
def intimate_profile_completion
  UserMailer.delay(queue: :mailer).intimation_profile_completion_email(resource, true)
  respond_to do |format|
    format.js {}
  end
end
mark_all_searchable() click to toggle source

Method to set all Tutor as searchable.

# File app/controllers/admin/tutors_controller.rb, line 14
def mark_all_searchable
  respond_to do |format|
    if Tutor.active.not_searchable.update_all(searchable: true)
      Tutor.searchable.each do |tutor|
        Indexer.perform_async(:update,  tutor.class.to_s, tutor.id)
      end
      format.html {redirect_via_turbolinks_to admin_tutors_path, alert: 'All Active tutors are searchable. Please allow two to five minutes to complete the process in the background before they are visible in the Search Page.'}
    else
      format.js {redirect_to collection_path, alert: 'Unable to mark all tutors searchable.'}
    end
  end
end
mark_searchable() click to toggle source

Method to update Tutor as searchable.

# File app/controllers/admin/tutors_controller.rb, line 50
def mark_searchable
  respond_to do |format|
    if !resource.is_registration_completed?
      format.js {redirect_to collection_path, alert: 'Unable to make searchable, User has not completed his profile.'}
    else
      if resource.update_attribute(:searchable, true)
        format.js {render 'referesh_datatable'}
      else
        format.js {redirect_to collection_path, alert: 'Unable to add in search.'}
      end
    end
  end
end
unmark_searchable() click to toggle source

Method to update Tutor as non-searchable.

# File app/controllers/admin/tutors_controller.rb, line 65
def unmark_searchable
  respond_to do |format|
    if resource.update_attribute(:searchable, false)
      format.js {render 'referesh_datatable'}
    else
      format.js {redirect_to collection_path, alert: 'Unable to remove from search.'}
    end
  end
end