Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
Ready for Redmine3.0, Rails4.
Browse files Browse the repository at this point in the history
  • Loading branch information
akiko-pusu committed Jan 2, 2015
1 parent 542844e commit 0b77e7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/controllers/banner_controller.rb
Expand Up @@ -35,7 +35,8 @@ def project_banner_off
def edit
if (params[:settings] != nil)
@banner = Banner.find_or_create(@project.id)
@banner.safe_attributes = params[:settings]
banner_params = params[:settings] || {}
@banner.update_attributes(banner_params)
@banner.save
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects',
Expand Down
5 changes: 3 additions & 2 deletions app/models/banner.rb
Expand Up @@ -9,10 +9,11 @@ class Banner < ActiveRecord::Base
validates_inclusion_of :style, :in=> ['info','warn','alert', 'normal', 'nodata']
# project should be stable.
safe_attributes 'banner_description', 'style', 'start_date', 'end_date', 'enabled', 'use_timer', 'display_part'
attr_accessible :enabled, :style, :display_part, :banner_description

def self.find_or_create(project_id)
banner = Banner.find(:first, :conditions => ['project_id = ?', project_id])
unless banner
banner = Banner.where(['project_id = ?', project_id]).first()
unless banner.present?
banner = Banner.new
banner.project_id = project_id
banner.enabled = false
Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
@@ -1,7 +1,7 @@
Rails.application.routes.draw do
match 'projects/:project_id/banner/:action', :to => 'banner'
match 'projects/:project_id/banner/project_banner_off', :to => 'banner#project_banner_off'
match 'projects/:project_id/banner/:action', :to => 'banner', :via => [:get, :post, :patch]
match 'projects/:project_id/banner/project_banner_off', :to => 'banner#project_banner_off', :via => [:get]
match 'banner/preview', :to => 'banner#preview',:via => [:get, :post]
match 'banner/off', :to => 'banner#off'
match 'banner/off', :to => 'banner#off', :via => [:get, :post]
match 'projects/:project_id/banner/preview', :to => 'banner#preview', :via => [:get, :post]
end

0 comments on commit 0b77e7f

Please sign in to comment.