Skip to content

Commit

Permalink
Moved 'icon' from Role to Role property.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 16, 2011
1 parent ecaa70b commit dfeeaaf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class Role < ActiveRecord::Base
# We use property to store index information, default values and such
include Property

property do |p|
p.string 'icon'
end
safe_property :icon

class << self
def export
{'Node' => VirtualClass['Node'].export}
Expand Down Expand Up @@ -155,6 +160,12 @@ def real_class?
false
end

def icon=(txt)
# FIXME: remove gsub when we stop using ImageBuilder on
# icon images. SECURITY
self.icon = txt.gsub('..', '.')
end

def superclass
if new_record?
Node
Expand Down
4 changes: 0 additions & 4 deletions app/models/virtual_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,6 @@ def export
res
end

def icon=(txt)
self[:icon] = txt.gsub('..', '.') # SECURITY
end

# check inheritance chain through kpath
def kpath_match?(kpath)
self.kpath =~ /^#{kpath}/
Expand Down
10 changes: 10 additions & 0 deletions bricks/zena/zena/migrate/03_zerox1_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ def self.up

execute "UPDATE roles SET type = 'VirtualClass'"

native_key = 'icon'
prop_key = 'icon'
VClassMig.all.each do |rec|
value = rec[native_key]
next if value.blank?
prop = rec.prop
prop[prop_key] = value
Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
end

puts %q{
======== Migration succeded.
***********************************************************************************
Expand Down

0 comments on commit dfeeaaf

Please sign in to comment.