Fixes #24 - MySQL returns Mysql::Time object on dynamic column, this is incompatible with ruby's Time object - instead check is made via class name (again not the best method of reflection, however in the case of a MySQL missing environment it'd break due to module/class not being found)
Updated two scopes to no longer be read-only (default stance is to make joins read only), however this breaks intended purpose
This commit is contained in:
parent
6018638843
commit
70bfdb2a9b
@ -6,6 +6,9 @@ Changelog for Redmine DMSF
|
||||
* New: Settings introduced to enable read-only or read-write stance to be taken with webdav
|
||||
* Fix: Issue #27 - incorrect call to display column information from database (redmine 1.x fragment).
|
||||
* Fix: Issue #28 - incompatible SQL in db migration script for postgresql
|
||||
* Fix: Issue #23 - Incorrect call to to_s for displaying time in certain views
|
||||
* Fix: Issue #24 - Incorrect times shown on revision history / documents
|
||||
* Fix: Issue #25 - Character in init.rb stops execution
|
||||
|
||||
1.4.4p2: *2012-07-08*
|
||||
-------------------
|
||||
|
||||
@ -63,5 +63,17 @@ module DmsfHelper
|
||||
def plugin_asset_path(plugin, asset_type, source)
|
||||
return "/plugin_assets/#{plugin}/#{asset_type}/#{source}"
|
||||
end
|
||||
|
||||
def self.to_time(obj)
|
||||
#Right, enough of bugs, let's try a better approach here.
|
||||
return if !obj
|
||||
return obj.to_time(ActiveRecord::Base.default_timezone) if obj.is_a?(String)
|
||||
|
||||
# Why can't Mysql::Time conform to time object? - without a utc? method it breaks redmine's
|
||||
# rendering method, so we convert it to string, and back into time - not the most efficient
|
||||
# of methods - however seems functional. Not sure if MySQL
|
||||
return obj.to_s.to_time(ActiveRecord::Base.default_timezone) if obj.class.name == "Mysql::Time"
|
||||
return obj
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -39,7 +39,8 @@ class DmsfFile < ActiveRecord::Base
|
||||
:conditions => {:entity_type => 0},
|
||||
:dependent => :destroy
|
||||
belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id"
|
||||
scope :visible, lambda {|*args| where(DmsfFile.visible_condition(args.shift || User.current, *args))}
|
||||
|
||||
scope :visible, lambda {|*args| where(DmsfFile.visible_condition(args.shift || User.current, *args)).readonly(false)}
|
||||
|
||||
validates_presence_of :name
|
||||
validates_format_of :name, :with => DmsfFolder.invalid_characters,
|
||||
|
||||
@ -27,7 +27,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
has_many :access, :class_name => "DmsfFileRevisionAccess", :foreign_key => "dmsf_file_revision_id", :dependent => :destroy
|
||||
|
||||
#Returns a list of revisions that are not deleted here, or deleted at parent level either
|
||||
scope :visible, lambda {|*args| joins(:file).where(DmsfFile.visible_condition(args.shift || User.current, *args)).where("#{self.table_name}.deleted = :false", :false => false ) }
|
||||
scope :visible, lambda {|*args| joins(:file).where(DmsfFile.visible_condition(args.shift || User.current, *args)).where("#{self.table_name}.deleted = :false", :false => false ).readonly(false) }
|
||||
|
||||
acts_as_customizable
|
||||
|
||||
@ -63,6 +63,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def delete(delete_all = false)
|
||||
reload
|
||||
if self.file.locked_for_user?
|
||||
errors[:base] << l(:error_file_is_locked)
|
||||
return false
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<tr>
|
||||
<td><%=link_to_user(access.user)%></td>
|
||||
<td><%=access["count"]%></td>
|
||||
<td><%=format_time(access.first_at.to_time(ActiveRecord::Base.default_timezone))%></td>
|
||||
<td><%=format_time(access.last_at.to_time(ActiveRecord::Base.default_timezone))%></td>
|
||||
<td><%=format_time(DmsfHelper::to_time(access.first_at))%></td>
|
||||
<td><%=format_time(DmsfHelper::to_time(access.last_at))%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user