<commit_before>class CoursesController < ApplicationController

  #before_action :require_login,only:[:show, :start]
#  before_action :require_course_exists,except:[:list,:create_enroll]
#  before_action :require_take_part_in,only:[:show]

  def info
    # TODO: should show only live courses
    @course_name = course.name

    if !["ios","nodejs"].include?(@course_name)
      render_404("No such course: #{@course_name}")
      return
    end
  end

  def show
    @enrollment = course.enrollments.find_by(user: current_user)
    if !@enrollment.activated
      flash[:error] = "您尚未激活该课程"
      redirect_to :root
      return
    end
    @send_day = Date.today.day
    #render '_show'
  end

  def pay
    @course = Course.find params[:id]
  end

  def invite
    @course = Course.find params[:id]
    @user = User.take
  end

  # 待定  should use before_action to controller login or not
  def start
    user = current_user
    course = Course.find params[:id]

=begin
    unless user
      store_location payment_course_url(course)
      return redirect_to login_path
    end
=end

    if user.courses.include? course.id
      redirect_to course_path(course)
    else
      update_record
      redirect_to course_path(course)
    end
  end


  def send_course_preview
    #TODO
  end

  def get_user_status
    result = {}
    result["has_logged_in"] = login?
    if login?
      result["has_enrolled"] = Course.find_by_id(params[:course_id]).include_user?(current_user)<commit_msg>remove unused actions from courses controller<commit_after>class CoursesController < ApplicationController

  #before_action :require_login,only:[:show, :start]
#  before_action :require_course_exists,except:[:list,:create_enroll]
#  before_action :require_take_part_in,only:[:show]

  def info
    # TODO: should show only live courses
    @course_name = course.name

    if !["ios","nodejs"].include?(@course_name)
      render_404("No such course: #{@course_name}")
      return
    end
  end

  def show
    @enrollment = course.enrollments.find_by(user: current_user)
    if !@enrollment.activated
      flash[:error] = "您尚未激活该课程"
      redirect_to :root
      return
    end
    @send_day = Date.today.day
    #render '_show'
  end

  def get_user_status
    result = {}
    result["has_logged_in"] = login?
    if login?
      result["has_enrolled"] = Course.find_by_id(params[:course_id]).include_user?(current_user)
{'fraction_non_alphanumeric': 0.10170195101701951, 'fraction_numerical': 0.0024906600249066002, 'mean_word_length': 3.530075187969925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4723090', 'n_tokens_mistral': 806, 'n_tokens_neox': 803, 'n_words': 171}