<commit_before>class MotionsController < GroupBaseController
  load_and_authorize_resource :except => [:create, :show, :index]
  before_filter :authenticate_user!, :except => [:show, :index, :get_and_clear_new_activity]
  before_filter :check_group_read_permissions, :only => :show

  def create
    @motion = current_user.authored_motions.new(params[:motion])
    logger.debug("PARAMS: #{params[:motion]}")
    logger.debug("MOTION (before save): #{@motion.attributes.inspect}")
    @group = GroupDecorator.new(@motion.group)
    authorize! :create, @motion
    if @motion.save
      flash[:success] = "Proposal successfully created."
      logger.debug("MOTION (after save): #{@motion.attributes.inspect}")
      redirect_to discussion_path(@motion.discussion)
    else
      flash[:warning] = "Proposal could not be created"
      redirect_to :back
    end
  end

  def index
    # NOTE (Jon): This currently only returns closed motions, which
    # means it should probably be renamed to something like "closed_motions"
    if params[:group_id].present?
      @group = Group.find(params[:group_id])
      if cannot? :show, @group
        head 401
      else
        @closed_motions = @group.motions_closed.page(params[:page]).per(7)
        render :layout => false if request.xhr?
      end<commit_msg>Try to fix motion close date issue.<commit_after>class MotionsController < GroupBaseController
  load_and_authorize_resource :except => [:create, :show, :index]
  before_filter :authenticate_user!, :except => [:show, :index, :get_and_clear_new_activity]
  before_filter :check_group_read_permissions, :only => :show

  def create
    @motion = current_user.authored_motions.new(params[:motion])
    logger.debug("PARAMS: #{params[:motion]}")
    logger.debug("MOTION (before save): #{@motion.attributes.inspect}")
    @motion.close_date = (params[:motion][:close_date]).to_datetime
    logger.debug("MOTION (before save, after hack): #{@motion.attributes.inspect}")
    @group = GroupDecorator.new(@motion.group)
    authorize! :create, @motion
    if @motion.save
      flash[:success] = "Proposal successfully created."
      logger.debug("MOTION (after save): #{@motion.attributes.inspect}")
      redirect_to discussion_path(@motion.discussion)
    else
      flash[:warning] = "Proposal could not be created"
      redirect_to :back
    end
  end

  def index
    # NOTE (Jon): This currently only returns closed motions, which
    # means it should probably be renamed to something like "closed_motions"
    if params[:group_id].present?
      @group = Group.find(params[:group_id])
      if cannot? :show, @group
        head 401
      else
        @closed_motions = @group.motions_closed.page(params[:page]).per(7)
        render :layout => false if request.xhr?
      end
{'fraction_non_alphanumeric': 0.12203876525484565, 'fraction_numerical': 0.002871500358937545, 'mean_word_length': 3.9946236559139785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6067549', 'n_tokens_mistral': 869, 'n_tokens_neox': 832, 'n_words': 207}