Permalink
Browse files

More rails3 fixes

  • Loading branch information...
1 parent 22afb13 commit 86f288f24a5c075cbab4b4dd98183bdff1cc771d @jamesu committed Aug 21, 2011
View
@@ -7,6 +7,7 @@ gem 'sass-rails', "~> 3.1.0.rc"
gem 'haml'
gem 'uglifier'
gem 'paperclip'
+gem 'dynamic_form'
#group :test, :development do
# gem 'rspec-rails', '~> 2.3.1'
View
@@ -44,6 +44,7 @@ GEM
builder (3.0.0)
cancan (1.6.5)
cocaine (0.2.0)
+ dynamic_form (1.1.4)
erubis (2.7.0)
execjs (1.2.0)
multi_json (~> 1.0)
@@ -118,6 +119,7 @@ PLATFORMS
DEPENDENCIES
cancan
choices!
+ dynamic_form
haml
paperclip
pg
@@ -25,12 +25,12 @@ def value
end
def value=(val)
- if val.class == Array:
+ if val.class == Array
@rawValue = val.join("\r\n")
else
# Clean input
- res = []
- val.to_s.each_line { |l| res << l.strip }
+ res = []
+ val.to_s.each_line { |l| res << l.strip }
@rawValue = res.uniq.reject{ |el| !el.empty? }.join("\r\n")
end
end
@@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base
include LoginSystem
protect_from_forgery
+ clear_helpers
helper :navigation
before_filter :reload_owner
@@ -81,7 +82,7 @@ def verify_project
def user_track
unless @logged_user.nil?
- store_location if request.method == :get and request.format == :html
+ store_location if request.method_symbol == :get and request.format == :html
@logged_user.update_attribute('last_visit', Time.now.utc)
end
@@ -162,7 +162,7 @@ def permissions
return
end
- case request.method
+ case request.method_symbol
when :put
project_list = params[:project]
project_list ||= []
@@ -188,7 +188,7 @@ def permissions
def logo
return error_status(true, :insufficient_permissions) unless (@company.can_be_edited_by(@logged_user))
- case request.method
+ case request.method_symbol
when :put
company_attribs = params[:company]
@@ -18,8 +18,8 @@
#++
class DashboardController < ApplicationController
-
after_filter :user_track
+ helper :dashboard
def index
when_fragment_expired "user#{@logged_user.id}_dblog", Time.now.utc + (60 * Rails.configuration.minutes_to_activity_log_expire) do
@@ -302,7 +302,7 @@ def attach
return
end
- case request.method
+ case request.method_symbol
when :put
attach_attribs = params[:attach]
@@ -115,7 +115,7 @@ def people
def permissions
return error_status(true, :insufficient_permissions) unless @project.can_be_managed_by(@logged_user)
- case request.method
+ case request.method_symbol
when :get
@project_users = @project.users
@user_projects = @logged_user.projects
@@ -191,7 +191,7 @@ def permissions
def users
return error_status(true, :insufficient_permissions) unless @project.can_be_managed_by(@logged_user)
- case request.method
+ case request.method_symbol
when :delete
user = User.find(params[:user_id])
unless user.owner_of_owner?
@@ -208,7 +208,7 @@ def users
def companies
return error_status(true, :insufficient_permissions) unless @project.can_be_managed_by(@logged_user)
- case request.method
+ case request.method_symbol
when :delete
company = Company.find(params[:company_id])
unless company.is_owner?
@@ -251,7 +251,7 @@ def destroy
def avatar
return error_status(true, :insufficient_permissions) unless (@user.profile_can_be_updated_by(@logged_user))
- case request.method
+ case request.method_symbol
when :put
user_attribs = params[:user]
@@ -311,7 +311,7 @@ def permissions
@projects = @user.company.projects
@permissions = ProjectUser.permission_names()
- case request.method
+ case request.method_symbol
when :put
update_project_permissions(@user, params[:user_project], params[:project_permission], @projects)
#ApplicationLog.new_log(@project, @logged_user, :edit, true)
@@ -30,24 +30,24 @@ def product_signature
def pagination_links(url, ids)
values = ids.collect{ |id| "<a href=\"#{url}page=#{id}\">#{id}</a>" }.join(' | ')
- "<div class=\"advancedPagination\"><span>#{:page.l}: </span><span>(#{values})</span></div>"
+ "<div class=\"advancedPagination\"><span>#{:page.l}: </span><span>(#{values})</span></div>".html_safe
end
def icon_url(filename)
- "/themes/#{Rails.configuration.site_theme}/images/icons/#{filename}.gif"
+ "/images/icons/#{filename}.gif"
end
def checkbox_link(link, checked=false, hint=nil, attrs={})
- icon_url = checked ? "/themes/#{Rails.configuration.site_theme}/images/icons/checked.gif" : "/themes/#{Rails.configuration.site_theme}/images/icons/not-checked.gif"
+ icon_url = checked ? "/images/icons/checked.gif" : "/images/icons/not-checked.gif"
method = attrs[:method] || :post
- link_to "<img src='#{icon_url}' alt='' />", link, attrs.merge({:method => method, :class => 'checkboxLink', :title => ( hint.nil? ? '' : (html_escape hint) )})
+ link_to "<img src='#{icon_url}' alt='' />".html_safe, link, attrs.merge({:method => method, :class => 'checkboxLink', :title => ( hint.nil? ? '' : (html_escape hint) )})
end
def render_icon(filename, alt, attrs={})
attr_values = attrs.keys.collect{ |a| "#{a}='#{attrs[a]}'" }.join(' ')
- "<img src='/themes/#{Rails.configuration.site_theme}/images/icons/#{filename}.gif' alt='#{alt}' #{attr_values}/>"
+ "<img src='/images/icons/#{filename}.gif' alt='#{alt}' #{attr_values}/>".html_safe
end
def action_list(actions)
@@ -76,7 +76,7 @@ def tag_list(object)
tags.collect do |tag|
link_to h(tag), project_tag_path(object.project_id, CGI.escape(tag))
- end.join(', ')
+ end.join(', ').html_safe
end
def format_size(value)
@@ -95,16 +95,16 @@ def format_usertime(time, format, user=@logged_user)
def yesno_toggle(object_name, method, options = {})
radio_button(object_name, method, "true", options.merge({:id => "#{options[:id]}Yes"})) +
- " <label for=\"#{options[:id]}Yes\" class=\"#{options[:class]}\">#{:yesno_yes.l}</label> " +
+ " <label for=\"#{options[:id]}Yes\" class=\"#{options[:class]}\">#{:yesno_yes.l}</label> ".html_safe +
radio_button(object_name, method, "false", options.merge({:id => "#{options[:id]}No"})) +
- " <label for=\"#{options[:id]}No\" class=\"#{options[:class]}\">#{:yesno_no.l}</label>"
+ " <label for=\"#{options[:id]}No\" class=\"#{options[:class]}\">#{:yesno_no.l}</label>".html_safe
end
def yesno_toggle_tag(name, is_yes, options = {})
radio_button_tag(name, "1", is_yes, options.merge({:id => "#{options[:id]}Yes"})) +
- " <label for=\"#{options[:id]}Yes\" class=\"#{options[:class]}\">#{:yesno_yes.l}</label> " +
+ " <label for=\"#{options[:id]}Yes\" class=\"#{options[:class]}\">#{:yesno_yes.l}</label> ".html_safe +
radio_button_tag(name, "0", !is_yes, options.merge({:id => "#{options[:id]}No"})) +
- " <label for=\"#{options[:id]}No\" class=\"#{options[:class]}\">#{:yesno_no.l}</label>"
+ " <label for=\"#{options[:id]}No\" class=\"#{options[:class]}\">#{:yesno_no.l}</label>".html_safe
end
def actions_for_user(user)
@@ -221,7 +221,7 @@ def cal_table(in_rows, tableclass)
end
"<tr>#{columns}</tr>"
end
- "<table class=\"#{tableclass}\"><tbody>#{rows}</tbody></table>"
+ "<table class=\"#{tableclass}\"><tbody>#{rows}</tbody></table>".html_safe
end
# offset: Use date.wday, so use 0 to start the week in sunday
@@ -298,7 +298,7 @@ def calendar_block(content, items, classname, force=false)
''
end
- "<div class=\"#{classname}\">#{content} #{list}</div>"
+ "<div class=\"#{classname}\">#{content} #{list}</div>".html_safe
end
def textilize(text)
@@ -82,7 +82,7 @@ def task_select_grouped_options(task_lists, filter=nil, options = {})
items = {}
task_lists.each do |task_list|
list = filter.nil? ? task_list.project_tasks : task_list.project_tasks.reject(&filter)
- items[task_list.name] = list.collect {|task| [truncate(task.text, 50), task.id.to_s]}
+ items[task_list.name] = list.collect {|task| [truncate(task.text, :length => 50), task.id.to_s]}
end
content_tag(:option, :none.l, :value => 0) + grouped_options_for_select(items, options)
@@ -25,7 +25,7 @@ def current_crumb
case action_name
when 'new', 'create' then :add_task
when 'edit', 'update' then :edit_task
- when 'show' then truncate(@task.text, 25)
+ when 'show' then truncate(@task.text, :length => 25)
else super
end
end
@@ -17,11 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#++
-require 'composite_primary_keys'
-
class AttachedFile < ActiveRecord::Base
- set_primary_keys :rel_object_type, :rel_object_id, :file_id
-
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_id'
belongs_to :project_file, :foreign_key => 'file_id'
View
@@ -26,7 +26,7 @@ class Comment < ActiveRecord::Base
has_many :attached_file, :as => 'rel_object'
has_many :project_file, :through => :attached_file
- before_validation_on_create :process_params
+ before_validation :on => :create, :process_params
after_create :process_create
before_update :process_update_params
before_destroy :process_destroy
View
@@ -16,11 +16,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#++
-require 'composite_primary_keys'
-
class ImValue < ActiveRecord::Base
set_table_name 'user_im_values'
- set_primary_keys :user_id, :im_type_id
belongs_to :user
belongs_to :im_type
@@ -37,7 +37,7 @@ def public(reload=false)
end
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
before_destroy :process_destroy
@@ -41,7 +41,7 @@ def public(reload=false)
has_and_belongs_to_many :subscribers, :class_name => 'User', :join_table => 'message_subscriptions', :foreign_key => 'message_id'
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
before_destroy :process_destroy
@@ -49,7 +49,7 @@ def public(reload=false)
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
before_destroy :process_destroy
@@ -40,7 +40,7 @@ def public(reload=false)
has_many :project_times, :foreign_key => 'task_id', :dependent => :nullify
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
after_update :update_task_list
@@ -30,7 +30,7 @@ class ProjectTaskList < ActiveRecord::Base
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
after_update :update_tags
@@ -35,9 +35,9 @@ class ProjectTime < ActiveRecord::Base
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- named_scope :running, :conditions => 'start_date IS NOT NULL AND done_date IS NULL'
+ scope :running, :conditions => 'start_date IS NOT NULL AND done_date IS NULL'
- before_validation_on_create :process_params
+ before_validation :process_params, :on => :create
after_create :process_create
before_update :process_update_params
before_destroy :process_destroy
@@ -17,11 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#++
-require 'composite_primary_keys'
-
class ProjectUser < ActiveRecord::Base
- set_primary_keys :project_id, :user_id
-
belongs_to :user
belongs_to :project
@@ -12,7 +12,7 @@
<% if not ['Comment', 'ProjectMessage'].include?(application_logs.rel_object_type) %>
<b><%= application_logs.friendly_action %>:</b>
<% end %>
- <%= application_logs.rel_object.nil? ? h(truncate(application_logs.object_name, 50)) : link_to(h(truncate(application_logs.object_name, 50)), application_logs.rel_object.object_url) %>
+ <%= application_logs.rel_object.nil? ? h(truncate(application_logs.object_name, :length => 50)) : link_to(h(truncate(application_logs.object_name, :length => 50)), application_logs.rel_object.object_url) %>
</span>
<% if show_project_column %>
@@ -39,14 +39,14 @@
<% else %>
<td class="logTakenOnBy">
<% if application_logs.is_today? %>
- <%= :action_today_with_time.l_with_args(:time => format_usertime(application_logs.created_on, :action_today_fomat)) %>
+ <%= :action_today_with_time.l_with_args(:time => format_usertime(application_logs.created_on, :action_today_fomat)).html_safe %>
<% elsif application_logs.is_yesterday? %>
<%= :action_yesterday.l %>
<% else %>
<%= format_usertime(application_logs.created_on, :action_past_format) %>
<% end %>
<% if not application_logs.taken_by.nil? %>
- <%= :action_by.l_with_args :user => link_to(h(application_logs.taken_by.display_name), user_path(:id => application_logs.taken_by.id)) %>
+ <%= :action_by.l_with_args(:user => link_to(h(application_logs.taken_by.display_name), user_path(:id => application_logs.taken_by.id))) .html_safe %>
<% end %>
</td>
<% end %>
@@ -2,7 +2,7 @@
<% if user.is_anonymous? %>
<%= :welcome_anonymous.l %> (<%= link_to(:login.l, logout_path) %>),
<% else %>
- <%= :welcome_back.l_with_args(:user => h(user.display_name)) %> (<%= link_to :logout.l, logout_path, :confirm => :are_you_sure_logout.l %>)
+ <%= :welcome_back.l_with_args(:user => h(user.display_name)).html_safe %> (<%= link_to :logout.l, logout_path, :confirm => :are_you_sure_logout.l %>)
<% end %>
<div id="running_times_count" style="display:<%= @running_times.empty? ? 'none' : 'block' %>;">
<span><%= :running_times.l_with_args(:count => @running_times.size) %></span> <%= render_icon 'bullet_drop_down', '', :id => 'running_times', :class => 'PopupMenuWidgetAttachTo', :title => 'Enable javascript' %>
Oops, something went wrong.

0 comments on commit 86f288f

Please sign in to comment.