Permalink
Browse files

Several updates for rails 3.1 and update the locale files with the on…

…es used in mconf-web (formatted using 'translate-rails3').
  • Loading branch information...
1 parent 2ed39d1 commit c0f8ef10ffb17843aa4eaca5fa0bdd54b504482f @daronco daronco committed Jan 9, 2012
View
View
View
@@ -1,14 +1,9 @@
-#config.gem "mislav-will_paginate", :lib => 'will_paginate',
-# :version => '>= 2.3.2',
-# :source => 'http://gems.github.com/'
-
+require 'will_paginate/array'
require_dependency 'permalink_fu'
-# TODO this may affect several places bellow
directory = File.expand_path(File.dirname(__FILE__))
# Make Station app/ paths reloadable
-# TODO: test it
ActiveSupport::Dependencies.autoload_once_paths.delete(File.expand_path(File.dirname(__FILE__))+'/app')
# Core Extensions
@@ -32,7 +27,7 @@
# Mime Types
# Redefine Mime::ATOM to include "application/atom+xml;type=entry"
-Mime::Type.register "application/atom+xml", :atom, [ "application/atom+xml;type=entry" ]
+# Mime::Type.register "application/atom+xml", :atom, [ "application/atom+xml;type=entry" ]
Mime::Type.register "application/atomsvc+xml", :atomsvc
Mime::Type.register "application/atomcat+xml", :atomcat
Mime::Type.register "application/xrds+xml", :xrds
@@ -2,12 +2,12 @@ module ActiveRecord #:nodoc:
module Agent
# Reset password support
module PasswordReset
- # Activate agent recovery password mechanism.
+ # Activate agent recovery password mechanism.
# Generates password reset code
def lost_password
@lost_password = true
self.make_reset_password_code
- save(false)
+ save(:validate => false)
end
# User did reset the password
@@ -18,7 +18,7 @@ def reset_password
# Active agent if pending, since she has verified her email
! active? ?
activate :
- save(false)
+ save(:validate => false)
end
# Did the agent recently reset the passowrd?
@@ -78,7 +78,8 @@ def acts_as_content(options = {})
if options[:reflection] != :container
alias_attribute :container, options[:reflection]
attr_protected options[:reflection]
- attr_protected reflections[options[:reflection]].primary_key_name
+ attr_protected reflections[options[:reflection]].respond_to?(:foreign_key) ?
+ reflections[options[:reflection]].foreign_key : reflections[options[:reflection]].primary_key_name
if reflections[options[:reflection]].options[:polymorphic]
attr_protected reflections[options[:reflection]].options[:foreign_type]
end
@@ -116,7 +117,9 @@ def container_conditions(container)
"(#{ c })"
else
if container.class.acts_as?(:container)
- c = "#{ table_name }.#{ container_reflection.primary_key_name } = '#{ container.id }'"
+ primary_key = container_reflection.respond_to?(:foreign_key) ?
+ container_reflection.foreign_key : container_reflection.primary_key_name
+ c = "#{ table_name }.#{ primary_key } = '#{ container.id }'"
if container_reflection.options[:polymorphic]
c << " AND #{ table_name }.#{ container_reflection.options[:foreign_type] } = '#{ container.class.base_class }'"
end
@@ -2,8 +2,23 @@ module ActiveRecord #:nodoc:
module Content
# Fake ActiveRecord::Base subclass for building queries in Containers
class Inquirer < ActiveRecord::Base
- @colums = Array.new
- @columns_hash = { "type" => :fake }
+ def self.columns
+ @columns ||= [];
+ end
+
+ def self.columns_hash
+ @columns_hash = { "type" => :fake }
+ end
+
+ def self.column(name, sql_type=nil, default=nil, null=true)
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default,
+ sql_type.to_s, null)
+ end
+
+ # Override the save method to prevent exceptions.
+ def save(validate = true)
+ validate ? valid? : true
+ end
set_table_name "all_contents"
@@ -25,7 +40,7 @@ def paginate(options = {}, container_options = {})
all_options = options.dup
all_options[:limit] = limit
- all_options[:offset] = offset
+ all_options[:offset] = offset
WillPaginate::Collection.create(page, limit) do |pager|
contents = all(all_options, container_options.dup)
@@ -87,10 +102,10 @@ def query(options = {}, container_options = {})
return "SELECT * FROM ( SELECT #{ columns_sql }) AS empty WHERE `#{ columns.first }` IS NOT NULL"
end
-
+
#Temporal fix for contents with type column
container_options[:columns].delete('type')
-
+
containers.any? ?
containers.map{ |c| container_query(c, container_options.dup) }.join(" UNION ") :
container_query(nil, container_options)
@@ -103,7 +118,7 @@ def query(options = {}, container_options = {})
# contents:: The contents that will be included in the query. If container is present, defaults to container's contents. If it's nil, to all the Contents
def container_query(container, options = {})
options[:contents] ||=
- ( container.present? ?
+ ( container.present? ?
container.class.contents :
ActiveRecord::Content.symbols )
@@ -119,7 +134,7 @@ def container_query(container, options = {})
}.join(", ")
# Should fix this to support AR STI
params[:select] += ", ( SELECT \"#{ content }\" ) AS type"
-
+
content.content_inquirer_query(params, :container => container)
}.join(" UNION ")
end
@@ -121,19 +121,6 @@ def atom_entry(record, options = {}, &block)
end
end
-require 'will_paginate'
-
-module WillPaginate::ViewHelpers::Base #:nodoc:
- def will_paginate_with_translation(collection = nil, options = {})
- options[:previous_label] ||= I18n.t('pagination.previous_label')
- options[:next_label] ||= I18n.t('pagination.next_label')
-
- will_paginate_without_translation(collection, options)
- end
-
- alias_method_chain :will_paginate, :translation
-end
-
# atom-tools like interface for standard Ruby RSS library
begin
require 'rss/1.0'

0 comments on commit c0f8ef1

Please sign in to comment.