add get_bulletins_json function
This commit is contained in:
		
							parent
							
								
									e6a9555dd8
								
							
						
					
					
						commit
						800279ea69
					
				| 
						 | 
					@ -4,11 +4,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_filter :clean_values, :only => [:create, :update]
 | 
					  before_filter :clean_values, :only => [:create, :update]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  before_filter :for_admin_only,:only => [:]
 | 
					  #  before_filter :for_admin_only,:only => [:]
 | 
				
			||||||
#  before_filter :for_app_manager,:only => [:index,:show,] 
 | 
					  #  before_filter :for_app_manager,:only => [:index,:show,] 
 | 
				
			||||||
  before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
 | 
					  before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
 | 
				
			||||||
  before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
 | 
					  before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
 | 
				
			||||||
  before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
 | 
					  before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
 | 
					  before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
 | 
				
			||||||
    controller.get_categorys('BulletinCategory')
 | 
					    controller.get_categorys('BulletinCategory')
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,28 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
    render '/shared/preview/preview.html.erb',:layout=>false
 | 
					    render '/shared/preview/preview.html.erb',:layout=>false
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def get_bulletins_json
 | 
				
			||||||
 | 
					    @bulletins = Bulletin.all
 | 
				
			||||||
 | 
					    @data = Hash.new
 | 
				
			||||||
 | 
					    @data[I18n.t("category")] = Hash.new
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @bulletins.each do |b|
 | 
				
			||||||
 | 
					      deadline = b.deadline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if not deadline.nil?
 | 
				
			||||||
 | 
					        deadline = display_date_time(deadline)
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        deadline = I18n.t("no_deadline")
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      @data[I18n.t("category")][b.bulletin_category.title] = { title: b.title,
 | 
				
			||||||
 | 
					                                           postdate: display_date_time(b.postdate),
 | 
				
			||||||
 | 
					                                           deadline: deadline,
 | 
				
			||||||
 | 
					                                           tag: b.sorted_tags.to_a,
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    render :json => @data.to_json
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    # @bulletins = Bulletin.all
 | 
					    # @bulletins = Bulletin.all
 | 
				
			||||||
    # @bulletins = Bulletin.desc("postdate desc")
 | 
					    # @bulletins = Bulletin.desc("postdate desc")
 | 
				
			||||||
| 
						 | 
					@ -52,10 +74,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @bulletin_link = BulletinLink.new
 | 
					    @bulletin_link = BulletinLink.new
 | 
				
			||||||
    @link_url = panel_announcement_back_end_bulletins_path
 | 
					    @link_url = panel_announcement_back_end_bulletins_path
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
    @bulletin_file = BulletinFile.new
 | 
					    @bulletin_file = BulletinFile.new
 | 
				
			||||||
    @file_url = panel_announcement_back_end_bulletins_path
 | 
					    @file_url = panel_announcement_back_end_bulletins_path
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
      format.html # index.html.erb
 | 
					      format.html # index.html.erb
 | 
				
			||||||
      format.js { }
 | 
					      format.js { }
 | 
				
			||||||
| 
						 | 
					@ -84,13 +106,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
      @bulletin = session[:in_validate_object]
 | 
					      @bulletin = session[:in_validate_object]
 | 
				
			||||||
      session[:in_validate_object] = {}
 | 
					      session[:in_validate_object] = {}
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    @link_url = panel_announcement_back_end_bulletins_path
 | 
					    @link_url = panel_announcement_back_end_bulletins_path
 | 
				
			||||||
    get_tags
 | 
					    get_tags
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
        format.html # new.html.erb
 | 
					      format.html # new.html.erb
 | 
				
			||||||
        format.xml  { render :xml => @bulletin }
 | 
					      format.xml  { render :xml => @bulletin }
 | 
				
			||||||
  	end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # GET /bulletins/1/edit
 | 
					  # GET /bulletins/1/edit
 | 
				
			||||||
| 
						 | 
					@ -100,85 +122,82 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
      redirect_to :action => :index
 | 
					      redirect_to :action => :index
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      # @summary_variable = @bulletin.summary_variable
 | 
					      # @summary_variable = @bulletin.summary_variable
 | 
				
			||||||
  	
 | 
					
 | 
				
			||||||
    	@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
 | 
					      @link_url = panel_announcement_back_end_bulletin_path(@bulletin)
 | 
				
			||||||
    	
 | 
					
 | 
				
			||||||
    	get_tags
 | 
					      get_tags
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # POST /bulletins
 | 
					  # POST /bulletins
 | 
				
			||||||
  # POST /bulletins.xml
 | 
					  # POST /bulletins.xml
 | 
				
			||||||
  def create
 | 
					  def create
 | 
				
			||||||
	get_tags
 | 
					    get_tags
 | 
				
			||||||
	if params[:bulletin_link]
 | 
					    if params[:bulletin_link]
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
		@bulletin_link = BulletinLink.new(params[:bulletin_link])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		respond_to do |format|
 | 
					      @bulletin_link = BulletinLink.new(params[:bulletin_link])
 | 
				
			||||||
		  if @bulletin_link.save
 | 
					 | 
				
			||||||
			format.js { render 'create_bulletin_link' }
 | 
					 | 
				
			||||||
		  end
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	elsif params[:bulletin_file]
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
		@bulletin_file = BulletinFile.new(params[:bulletin_file])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
		  if @bulletin_file.save
 | 
					        if @bulletin_link.save
 | 
				
			||||||
        format.js { render 'create_bulletin_file' }
 | 
					          format.js { render 'create_bulletin_link' }
 | 
				
			||||||
		  end
 | 
					        end
 | 
				
			||||||
		end
 | 
					      end
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	else  
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
		@bulletin = Bulletin.new(params[:bulletin])
 | 
					 | 
				
			||||||
            @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		@bulletin.create_user_id = current_user.id
 | 
					 | 
				
			||||||
		@bulletin.update_user_id = current_user.id
 | 
					 | 
				
			||||||
            if(is_manager? || is_admin?)
 | 
					 | 
				
			||||||
                    @bulletin.is_checked = true
 | 
					 | 
				
			||||||
                    @bulletin.is_rejected = false
 | 
					 | 
				
			||||||
                    @bulletin.de_pending
 | 
					 | 
				
			||||||
            end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		respond_to do |format|
 | 
					    elsif params[:bulletin_file]
 | 
				
			||||||
		  if @bulletin.save
 | 
					
 | 
				
			||||||
                  
 | 
					      @bulletin_file = BulletinFile.new(params[:bulletin_file])
 | 
				
			||||||
			format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
 | 
					
 | 
				
			||||||
			format.xml  { render :xml => @bulletin, :status => :created, :location => @bulletin }
 | 
					      respond_to do |format|
 | 
				
			||||||
			# format.js
 | 
					        if @bulletin_file.save
 | 
				
			||||||
                  format.js { 
 | 
					          format.js { render 'create_bulletin_file' }
 | 
				
			||||||
                    @info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
 | 
					        end
 | 
				
			||||||
                    flash[:notice] = t('bulletin.create_bulletin_success')
 | 
					      end
 | 
				
			||||||
                    render "/shared/preview/after_create.js.erb"
 | 
					
 | 
				
			||||||
                  }
 | 
					    else
 | 
				
			||||||
		  else
 | 
					
 | 
				
			||||||
			format.html { render :action => "new" }
 | 
					      @bulletin = Bulletin.new(params[:bulletin])
 | 
				
			||||||
			format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity }
 | 
					      @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
 | 
				
			||||||
                  format.js { 
 | 
					
 | 
				
			||||||
                    @info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
 | 
					      @bulletin.create_user_id = current_user.id
 | 
				
			||||||
                    session[:in_validate_object] = @bulletin
 | 
					      @bulletin.update_user_id = current_user.id
 | 
				
			||||||
                    render "/shared/preview/after_create.js.erb"
 | 
					      if(is_manager? || is_admin?)
 | 
				
			||||||
                  }
 | 
					        @bulletin.is_checked = true
 | 
				
			||||||
		  end
 | 
					        @bulletin.is_rejected = false
 | 
				
			||||||
		end
 | 
					        @bulletin.de_pending
 | 
				
			||||||
		
 | 
					      end
 | 
				
			||||||
	end
 | 
					
 | 
				
			||||||
	
 | 
					      respond_to do |format|
 | 
				
			||||||
 | 
					        if @bulletin.save
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
 | 
				
			||||||
 | 
					          format.xml  { render :xml => @bulletin, :status => :created, :location => @bulletin }
 | 
				
			||||||
 | 
					          # format.js
 | 
				
			||||||
 | 
					          format.js { 
 | 
				
			||||||
 | 
					            @info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
 | 
				
			||||||
 | 
					            flash[:notice] = t('bulletin.create_bulletin_success')
 | 
				
			||||||
 | 
					            render "/shared/preview/after_create.js.erb"
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          format.html { render :action => "new" }
 | 
				
			||||||
 | 
					          format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity }
 | 
				
			||||||
 | 
					          format.js { 
 | 
				
			||||||
 | 
					            @info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
 | 
				
			||||||
 | 
					            session[:in_validate_object] = @bulletin
 | 
				
			||||||
 | 
					            render "/shared/preview/after_create.js.erb"
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def link_quick_add    
 | 
					  def link_quick_add
 | 
				
			||||||
    @bulletin_link = BulletinLink.new
 | 
					    @bulletin_link = BulletinLink.new
 | 
				
			||||||
    @link_url = panel_announcement_back_end_bulletins_path
 | 
					    @link_url = panel_announcement_back_end_bulletins_path
 | 
				
			||||||
    @bulletin_link.bulletin_id = params[:bulletin_id]
 | 
					    @bulletin_link.bulletin_id = params[:bulletin_id]
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
      format.js
 | 
					      format.js
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def link_quick_edit
 | 
					  def link_quick_edit
 | 
				
			||||||
| 
						 | 
					@ -189,14 +208,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def file_quick_add    
 | 
					  def file_quick_add
 | 
				
			||||||
    @bulletin_file = BulletinFile.new
 | 
					    @bulletin_file = BulletinFile.new
 | 
				
			||||||
    @file_url = panel_announcement_back_end_bulletins_path
 | 
					    @file_url = panel_announcement_back_end_bulletins_path
 | 
				
			||||||
    @bulletin_file.bulletin_id = params[:bulletin_id]
 | 
					    @bulletin_file.bulletin_id = params[:bulletin_id]
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
      format.js
 | 
					      format.js
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def file_quick_edit
 | 
					  def file_quick_edit
 | 
				
			||||||
| 
						 | 
					@ -211,75 +229,71 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
  # PUT /bulletins/1.xml
 | 
					  # PUT /bulletins/1.xml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def update
 | 
					  def update
 | 
				
			||||||
    	if params[:bulletin_link]
 | 
					    if params[:bulletin_link]
 | 
				
			||||||
  	
 | 
					 | 
				
			||||||
  		@bulletin_link = BulletinLink.find(params[:id])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  		@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
 | 
					      @bulletin_link = BulletinLink.find(params[:id])
 | 
				
			||||||
 | 
					      @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  		respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
            
 | 
					        if @bulletin_link.update_attributes(params[:bulletin_link])
 | 
				
			||||||
  		  if @bulletin_link.update_attributes(params[:bulletin_link])
 | 
					          # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
				
			||||||
  			# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
					          format.js { render 'update_bulletin_link' }
 | 
				
			||||||
  			format.js { render 'update_bulletin_link' }
 | 
					        end
 | 
				
			||||||
  		  end
 | 
					      end
 | 
				
			||||||
  		end
 | 
					 | 
				
			||||||
  	
 | 
					 | 
				
			||||||
  	elsif params[:bulletin_file]
 | 
					 | 
				
			||||||
  	
 | 
					 | 
				
			||||||
  		@bulletin_file = BulletinFile.find(params[:id])
 | 
					 | 
				
			||||||
  		
 | 
					 | 
				
			||||||
  		@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  		respond_to do |format|
 | 
					    elsif params[:bulletin_file]
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
  		  if @bulletin_file.update_attributes(params[:bulletin_file])
 | 
					      @bulletin_file = BulletinFile.find(params[:id])
 | 
				
			||||||
  			# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
					      @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
 | 
				
			||||||
  			format.js { render 'update_bulletin_file' }
 | 
					      respond_to do |format|
 | 
				
			||||||
  		  end
 | 
					
 | 
				
			||||||
  		end
 | 
					        if @bulletin_file.update_attributes(params[:bulletin_file])
 | 
				
			||||||
  	
 | 
					          # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
				
			||||||
  	else
 | 
					          format.js { render 'update_bulletin_file' }
 | 
				
			||||||
    
 | 
					        end
 | 
				
			||||||
  		@bulletin = Bulletin.find(params[:id])
 | 
					      end
 | 
				
			||||||
  		
 | 
					
 | 
				
			||||||
  		# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
 | 
					    else
 | 
				
			||||||
  		# if params[:bulletin][:image_del] == '1' 
 | 
					
 | 
				
			||||||
  			# @bulletin.remove_image!
 | 
					      @bulletin = Bulletin.find(params[:id])
 | 
				
			||||||
  			# @bulletin.image_del = nil
 | 
					
 | 
				
			||||||
  			# params[:bulletin][:image_del] = nil
 | 
					      # @bulletin.image.clear if params[:bulletin][:image_del] == '1'
 | 
				
			||||||
  		# end
 | 
					      # if params[:bulletin][:image_del] == '1' 
 | 
				
			||||||
 | 
					      # @bulletin.remove_image!
 | 
				
			||||||
 | 
					      # @bulletin.image_del = nil
 | 
				
			||||||
 | 
					      # params[:bulletin][:image_del] = nil
 | 
				
			||||||
 | 
					      # end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            delete_out_invalid_date_from_params
 | 
					      delete_out_invalid_date_from_params
 | 
				
			||||||
  		respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
  		  if @bulletin.update_attributes(params[:bulletin])
 | 
					        if @bulletin.update_attributes(params[:bulletin])
 | 
				
			||||||
                 if(is_manager? || is_admin?)
 | 
					          if(is_manager? || is_admin?)
 | 
				
			||||||
                  @bulletin.is_checked = true
 | 
					            @bulletin.is_checked = true
 | 
				
			||||||
                  @bulletin.is_rejected = false
 | 
					            @bulletin.is_rejected = false
 | 
				
			||||||
                  @bulletin.de_pending!
 | 
					            @bulletin.de_pending!
 | 
				
			||||||
                 end
 | 
					          end
 | 
				
			||||||
                # if (params[:bulletin][:is_checked] == "false")
 | 
					          # if (params[:bulletin][:is_checked] == "false")
 | 
				
			||||||
                #   @bulletin.is_rejected = true
 | 
					          #   @bulletin.is_rejected = true
 | 
				
			||||||
                #   @bulletin.save!
 | 
					          #   @bulletin.save!
 | 
				
			||||||
                # end
 | 
					          # end
 | 
				
			||||||
                   # if (@bulletin.deadline < @bulletin.postdate rescue nil)
 | 
					          # if (@bulletin.deadline < @bulletin.postdate rescue nil)
 | 
				
			||||||
                   #    @bulletin.deadline = nil
 | 
					          #    @bulletin.deadline = nil
 | 
				
			||||||
                   #    @bulletin.update_user_id = current_user.id
 | 
					          #    @bulletin.update_user_id = current_user.id
 | 
				
			||||||
                   #    @bulletin.save!
 | 
					          #    @bulletin.save!
 | 
				
			||||||
                   #  end
 | 
					          #  end
 | 
				
			||||||
  			# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
 | 
					          # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
 | 
				
			||||||
  			format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
 | 
					          format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
 | 
				
			||||||
  			format.js  { render 'toggle_enable' }
 | 
					          format.js  { render 'toggle_enable' }
 | 
				
			||||||
  			format.xml  { head :ok }
 | 
					          format.xml  { head :ok }
 | 
				
			||||||
  		  else
 | 
					        else
 | 
				
			||||||
                  get_tags
 | 
					          get_tags
 | 
				
			||||||
  			format.html { render :action => "edit" }
 | 
					          format.html { render :action => "edit" }
 | 
				
			||||||
  			format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity }
 | 
					          format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity }
 | 
				
			||||||
  		  end
 | 
					        end
 | 
				
			||||||
  		end
 | 
					      end
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -291,7 +305,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
    @bulletin.destroy
 | 
					    @bulletin.destroy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
     
 | 
					
 | 
				
			||||||
      format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
					      format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
				
			||||||
      # format.xml  { head :ok }
 | 
					      # format.xml  { head :ok }
 | 
				
			||||||
      format.js
 | 
					      format.js
 | 
				
			||||||
| 
						 | 
					@ -299,21 +313,21 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # def top_edit
 | 
					  # def top_edit
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	# Bulletin.where(id: params[:id]).update_all( is_top: true )
 | 
					  # Bulletin.where(id: params[:id]).update_all( is_top: true )
 | 
				
			||||||
    # respond_to do |format|
 | 
					  # respond_to do |format|
 | 
				
			||||||
      # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
					  # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
 | 
				
			||||||
      # format.xml  { head :ok }
 | 
					  # format.xml  { head :ok }
 | 
				
			||||||
    # end
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
  # end
 | 
					  # end
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
 | 
					  # end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def load_quick_edit
 | 
					  def load_quick_edit
 | 
				
			||||||
    @bulletin = Bulletin.find(params[:id])
 | 
					    @bulletin = Bulletin.find(params[:id])
 | 
				
			||||||
    @type = params[:type]
 | 
					    @type = params[:type]
 | 
				
			||||||
    @bulletin_categories = BulletinCategory.all
 | 
					    @bulletin_categories = BulletinCategory.all
 | 
				
			||||||
     #TODO 需要做 manager ,admin 才可以 all.  其他 available就好
 | 
					    #TODO 需要做 manager ,admin 才可以 all.  其他 available就好
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    get_tags
 | 
					    get_tags
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					@ -325,9 +339,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
    redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
 | 
					    redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  protected
 | 
					  protected
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  def delete_out_invalid_date_from_params
 | 
					  def delete_out_invalid_date_from_params
 | 
				
			||||||
    if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?)) 
 | 
					    if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?)) 
 | 
				
			||||||
      params[:bulletin].delete("deadline(1i)")
 | 
					      params[:bulletin].delete("deadline(1i)")
 | 
				
			||||||
| 
						 | 
					@ -361,10 +375,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
  #       redirect_to :action => :index
 | 
					  #       redirect_to :action => :index
 | 
				
			||||||
  #   end
 | 
					  #   end
 | 
				
			||||||
  # end
 | 
					  # end
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  def get_tags
 | 
					  def get_tags
 | 
				
			||||||
  	module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
 | 
					    module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
 | 
				
			||||||
  	@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
 | 
					    @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def clean_values
 | 
					  def clean_values
 | 
				
			||||||
| 
						 | 
					@ -377,5 +391,4 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
 | 
				
			||||||
      end rescue nil
 | 
					      end rescue nil
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@ Rails.application.routes.draw do
 | 
				
			||||||
        match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
 | 
					        match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
 | 
				
			||||||
        match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
 | 
					        match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
 | 
				
			||||||
        match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
 | 
					        match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
 | 
				
			||||||
 | 
					        #match 'get_bulletins_json' => "bulletins#get_bulletins_json" ,:as => :bulletins_json_list,:via => :get
 | 
				
			||||||
        resources :bulletins do
 | 
					        resources :bulletins do
 | 
				
			||||||
          match "approve/:bulletin_id"  => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
 | 
					          match "approve/:bulletin_id"  => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
 | 
				
			||||||
          match "approve/:bulletin_id"  => "approvals#approve",:as => :approve,:via => :post
 | 
					          match "approve/:bulletin_id"  => "approvals#approve",:as => :approve,:via => :post
 | 
				
			||||||
| 
						 | 
					@ -18,21 +19,22 @@ Rails.application.routes.draw do
 | 
				
			||||||
            post "preview"
 | 
					            post "preview"
 | 
				
			||||||
            put "preview"
 | 
					            put "preview"
 | 
				
			||||||
            get 'delete'
 | 
					            get 'delete'
 | 
				
			||||||
 | 
					            get 'get_bulletins_json'
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
          match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
 | 
					          match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
 | 
				
			||||||
          match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
 | 
					          match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
        resources :bulletin_categorys 
 | 
					        resources :bulletin_categorys 
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		resources :bulletin_links, :controller => 'bulletin_links' do
 | 
					        resources :bulletin_links, :controller => 'bulletin_links' do
 | 
				
			||||||
          match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit
 | 
					          match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		resources :bulletin_files, :controller => 'bulletin_files' do
 | 
					        resources :bulletin_files, :controller => 'bulletin_files' do
 | 
				
			||||||
          match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit
 | 
					          match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
        resources :tags
 | 
					        resources :tags
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      namespace :front_end do
 | 
					      namespace :front_end do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in New Issue