<commit_before>class UsersController < ApplicationController

  before_filter :require_valid_user

  def show
    @user = User.find(params[:id])
    @application = @user.get_most_recent_application
    if @application
      @completed_forms = @application.get_completed_forms
      if @application.completed
        @status = "Complete"
      else
        @status = "Incomplete"
      end
      @year = @application.year
      @type = @application.application_type.app_type
      @forms_to_build = @application.application_type.forms
    end
  end

  def submit_application
    user = User.find(params[:id])
    application = user.get_most_recent_application
    if application
      if not application.completed #and application.all_forms_completed? 
        application.completed = true
        application.save
        flash[:notice] = "Application successfully submitted."
      # else
      #   flash[:alert] = "One of the forms is not yet submitted."
      end
    else
      flash[:alert] = "Error. Application not found. Please contact SFVS for help."
    end
    redirect_to user_path(user)
  end

	def submit_payment
		user = User.find(params[:id])
		application = user.get_most_recent_application
		if application.hasPaid?
			#flash[:payment_notice] = "You have already paid for this application."
			flash[:alert] = "You have already paid for this application."
			redirect_to user_path(user)
		else<commit_msg>checked to make sure app is completed before paying<commit_after>class UsersController < ApplicationController

  before_filter :require_valid_user

  def show
    @user = User.find(params[:id])
    @application = @user.get_most_recent_application
    if @application
      @completed_forms = @application.get_completed_forms
      if @application.completed
        @status = "Complete"
      else
        @status = "Incomplete"
      end
      @year = @application.year
      @type = @application.application_type.app_type
      @forms_to_build = @application.application_type.forms
    end
  end

  def submit_application
    user = User.find(params[:id])
    application = user.get_most_recent_application
    if application
      if not application.completed #and application.all_forms_completed? 
        application.completed = true
        application.save
        flash[:notice] = "Application successfully submitted."
      # else
      #   flash[:alert] = "One of the forms is not yet submitted."
      end
    else
      flash[:alert] = "Error. Application not found. Please contact SFVS for help."
    end
    redirect_to user_path(user)
  end

	def submit_payment
		user = User.find(params[:id])
		application = user.get_most_recent_application
		if not application.complete
			flash[:alert] = "You must first complete and submit the application."
			redirect_to user_path(user)
		end
		if application.hasPaid?
			#flash[:payment_notice] = "You have already paid for this application."
			flash[:alert] = "You have already paid for this application."
			redirect_to user_path(user)
		else
{'fraction_non_alphanumeric': 0.08068783068783068, 'fraction_numerical': 0.0, 'mean_word_length': 3.2665726375176303, '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': '6594539', 'n_tokens_mistral': 873, 'n_tokens_neox': 818, 'n_words': 230}