Changeset 1168

Show
Ignore:
Timestamp:
2008-09-19 16:27:18 (4 months ago)
Author:
gaspard
Message:

commit 2eb44b1b17c14bf0ab71dcd0c8284027d61e8ad7
Author: Gaspard Bucher <gaspard@teti.ch>

Fixed a bug where negative values could not be used in test conditions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/models/comment.rb

    r1165 r1168  
    77=end 
    88class Comment < ActiveRecord::Base 
    9   zafu_readable      :title, :text, :author_name, :created_at, :updated_at, :status, :user_id, :user_zip 
     9  zafu_readable      :title, :text, :author_name, :created_at, :updated_at, :status 
    1010  zafu_context       :replies => ["Comment"] 
    1111  attr_accessible    :title, :text, :author_name, :discussion_id, :reply_to, :status 
     
    2323  def author_name 
    2424    self[:author_name] || (self[:user_id] ? author.fullname : nil) 
    25   end 
    26    
    27   def user_zip 
    28     user_id 
    2925  end 
    3026   
  • trunk/app/models/node.rb

    r1165 r1168  
    132132                     :section_zip, :skin, :ref_lang, :fullpath, :rootpath, :position, :publish_from, :max_status, :rgroup_id,  
    133133                     :wgroup_id, :pgroup_id, :basepath, :custom_base, :klass, :zip, :score, :comments_count, :l_status, :l_comment, 
    134                      :custom_a, :custom_b, :title, :text, :user_id, 
     134                     :custom_a, :custom_b, :title, :text, 
    135135                     :m_text, :m_title, :m_author    
    136136  zafu_context       :author => "Contact", :parent => "Node",  
  • trunk/app/models/version.rb

    r1165 r1168  
    3131 
    3232  zafu_readable      :title, :text, :summary, :comment, :created_at, :updated_at, :publish_from, :status,  
    33                      :wgroup_id, :pgroup_id, :zip, :lang, :user_zip, :user_id 
     33                     :wgroup_id, :pgroup_id, :zip, :lang, :user_zip 
    3434                      
    3535  zafu_context       :author => "Contact", :user => "User", :node => "Node" 
  • trunk/db/migrate/000_zena/021_create_relations.rb

    r1067 r1168  
    1515    end 
    1616    add_column :links, 'relation_id', :integer 
    17     # load relations fixtures 
    18     source_rel = {} 
    19     target_rel = {} 
    20     relations  = [] 
    21     YAML::load_documents( File.open( File.join(RAILS_ROOT, 'test', 'fixtures', 'relations.yml') ) ) do |entries| 
    22       entries.each do |key,value| 
    23         relation = [] 
    24         ['source_role', 'source_kpath', 'source_icon', 'target_role', 'target_kpath', 'target_icon'].each do |sym| 
    25           relation << quote(value[sym]) 
    26         end 
    27         relations << relation 
    28       end 
    29     end 
    30     # create relations for each site 
    31     Site.find(:all).each do |site| 
    32       insert = relations.map do |rel| 
    33         "(#{(rel + [site[:id]]).join(',')})" 
    34       end 
    35       execute "INSERT INTO relations (`source_role`,`source_kpath`,`source_icon`,`target_role`,`target_kpath`,`target_icon`,`site_id`) VALUES #{insert.join(', ')}" 
    36       execute "UPDATE links,nodes SET relation_id = (SELECT id FROM relations WHERE source_role = links.role OR target_role = links.role AND site_id = #{site[:id]} LIMIT 1) WHERE links.source_id = nodes.id AND nodes.site_id = #{site[:id]}" 
    37     end 
    3817  end 
    3918 
  • trunk/lib/node_query.rb

    r1165 r1168  
    163163        case $2 
    164164        when 'visitor' 
    165           if $3 == 'author_id' # FIXME: this is a bit hackish. If anyone has a better idea.. 
    166             value = "\#{visitor.id}" 
    167           else 
    168             value = "\#{Node.connection.quote(\#{#{val_start}Node.zafu_attribute(visitor.contact, #{$3.inspect})#{val_end}})}" 
    169           end 
     165          value = "\#{Node.connection.quote(\#{#{val_start}Node.zafu_attribute(visitor.contact, #{$3.inspect})#{val_end}})}" 
    170166        when 'param' 
    171167          value = "\#{Node.connection.quote(#{val_start}params[:#{$3}].to_s#{val_end})}" 
     
    347343      #   * VCLASS: a virtual class created by the user ('posts', 'houses', ...) 
    348344      #   * RELATION: a relation defined by the user ('icon_for', 'news', 'calendar', ...) 
    349       #   * CLAUSE: field = value ('log_at:year = 2005'). You can use parameters, visitor data in clause: 'log_at:year = [param:year]', 'd_assigned = [visitor:name]'. You can use version and/or dynamic attributes : 'v_comment = super', 'd_priority = low'. 
     345      #   * CLAUSE: field = value ('log_at:year = 2005'). You can use parameters, visitor data in clause: 'log_at:year = [param:year]', 'd_assigned = [visitor:name]'. You can only use 'and' in clauses. 'or' is not supported. You can use version and/or dynamic attributes : 'v_comment = super', 'd_priority = low'. 
    350346      # 
    351347      # Examples: 'todos in section where d_priority = high and d_assigned = [visitor:name]' 
  • trunk/lib/parser/lib/rules/zena.rb

    r1163 r1168  
    25572557          end 
    25582558        when :test 
    2559           if value =~ /("[^"]*"|'[^']*'|[\w:\.]+)\s*(>=|<=|<>|<|=|>|lt|le|eq|ne|ge|gt)\s*("[^"]*"|'[^']*'|[\w\.]+)/ 
     2559          if value =~ /("[^"]*"|'[^']*'|[\w:\.\-]+)\s*(>=|<=|<>|<|=|>|lt|le|eq|ne|ge|gt)\s*("[^"]*"|'[^']*'|[\w\.\-]+)/ 
    25602560            parts = [$1,$3] 
    25612561            op = {'lt' => '<','le' => '<=','eq' => '==', '=' => '==','ne' => '!=','ge' => '>=','gt' => '>'}[$2] || $2 
    2562             toi   = ( op =~ /(>|<)/ || (parts[0] =~ /^\d+$/ || parts[1] =~ /^\d+$/) ) 
     2562            toi   = ( op =~ /(>|<)/ || (parts[0] =~ /^-?\d+$/ || parts[1] =~ /^-?\d+$/) ) 
    25632563            parts.map! do |part| 
    25642564              if ['"',"'"].include?(part[0..0]) 
     
    25662566              elsif part == 'NOW' 
    25672567                "Time.now.to_i" 
    2568               elsif part =~ /^\d+$/ 
     2568              elsif part =~ /^-?\d+$/ 
    25692569                part 
    25702570              else 
  • trunk/test/helpers/node_query/filters.yml

    r1165 r1168  
    9191  src: "nodes in site group by log_at:year order by log_at:year asc, name asc" 
    9292  sql: "SELECT nodes.* FROM nodes WHERE (#{@node.secure_scope('nodes')}) GROUP BY year(nodes.log_at) ORDER BY year(nodes.log_at) ASC, nodes.name ASC" 
    93  
    94 nodes_author: 
    95   context: 
    96     visitor: ant 
    97   src: "nodes where user_id eq \"[visitor:author_id]\" in site" 
    98   sql: "SELECT nodes.* FROM nodes WHERE nodes.user_id = \#{visitor.id} AND (\#{@node.secure_scope('nodes')}) ORDER BY nodes.position ASC, nodes.name ASC" 
    99   res: "." 
  • trunk/test/helpers/node_query/relations.yml

    r1123 r1168  
    2929projects_in_site: 
    3030  sql: "SELECT nodes.* FROM nodes WHERE nodes.kpath LIKE 'NPP%' AND (#{@node.secure_scope('nodes')}) ORDER BY nodes.position ASC, nodes.name ASC" 
    31  
    32 comments_order: 
    33   src: "comments order by created_at desc" 
    34   sql: "Comment: SELECT comments.* FROM comments WHERE comments.discussion_id = #{@node.get_discussion_id} ORDER BY comments.created_at DESC" 
  • trunk/test/helpers/zena_parser/basic.yml

    r1164 r1168  
    630630  src: "<div do='project' on_if='name eq \"cleanWater\"' do='[name]'/>" 
    631631  res: "<div class='on'>cleanWater</div>" 
     632 
     633test_negative_value: 
     634  src: "<div do='void' off_if='custom_a eq -10'>...</div>" 
     635  tem: "<div<%= @node.custom_a.to_i == -10 ? \" class='off'\" : \"\" %>>...</div>" 
    632636   
    633637simple_each: