Changeset 1215

Show
Ignore:
Timestamp:
2008-10-05 15:58:26 (3 months ago)
Author:
gaspard
Message:

commit 7e3ba0069afa540ea98fd9aef3345dfee7d6a679
Author: Gaspard Bucher <gaspard@teti.ch>

Fixed a bug where default text for versions was showing 'edit' instead of the title.

Files:

Legend:

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

    r1192 r1215  
    3131      end 
    3232       
    33       old = node.old_version 
    34       return true if old.nil? 
     33      old_title = node.old_title 
     34      return true if old_title.nil? 
    3535      # what changed ? 
    36       title_changed    = title            != old.title 
     36      title_changed    = title            != old_title 
    3737      fullname_changed = content.fullname != @old_fullname 
    3838      # 1. both 
    3939      if title_changed && fullname_changed 
    4040        # ignore 
    41       elsif fullname_changed && node.old_version.title == @old_fullname 
     41      elsif fullname_changed && node.old_title == @old_fullname 
    4242        # content changed and title was in sync 
    4343        self.title = content.fullname 
  • trunk/app/models/node.rb

    r1197 r1215  
    128128=end 
    129129class Node < ActiveRecord::Base 
    130   attr_accessor      :link, :old_version 
     130  attr_accessor      :link, :old_title 
    131131  zafu_readable      :name, :created_at, :updated_at, :event_at, :log_at, :kpath, :user_zip, :parent_zip, :project_zip, 
    132132                     :section_zip, :skin, :ref_lang, :fullpath, :rootpath, :position, :publish_from, :max_status, :rgroup_id,  
     
    486486                  define_method(:read) do 
    487487                    if insert_zafu_headings 
    488                       o_read.sub(%r{</head>},"  <r:stylesheets/>\n  <r:javascripts/>\n</head>") 
     488                      o_read.sub(%r{</head>},"  <r:stylesheets/>\n  <r:javascripts/>\n  <r:uses_calendar/>\n</head>") 
    489489                    else 
    490490                      o_read 
     
    15581558    # Try to keep node name in sync with published v_title in ref_lang. This is set after_publish. 
    15591559    def sync_name 
    1560       return true if @old_version.nil? || version.lang != ref_lang || name == version.title.url_name || old.name != @old_version.title.url_name 
     1560      return true if @old_title.nil? || version.lang != ref_lang || name == version.title.url_name || old.name != @old_title.url_name 
    15611561      update_attributes(:name => version.title.url_name) 
    15621562    end 
  • trunk/config/zena.rb

    r1185 r1215  
    33require 'uuidtools' 
    44require "#{RAILS_ROOT}/config/version" 
     5require 'fileutils' 
     6 
    57AUTHENTICATED_PREFIX = "oo" 
    68SITES_ROOT = "#{RAILS_ROOT}/sites" 
     
    2224  puts "\n** WARNING: drb server not running. Upload progress will not work." 
    2325  puts " * WARNING: you should start the drb server with 'lib/upload_progress_server.rb start'\n\n" 
     26end 
     27 
     28unless File.exist?(File.join(File.dirname(__FILE__), 'database.yml')) 
     29  FileUtils.cp(File.join(File.dirname(__FILE__), 'database_example.yml'), File.join(File.dirname(__FILE__), 'database.yml')) 
     30end 
     31 
     32unless File.exist?(File.join(File.dirname(__FILE__), '..', 'log')) 
     33  FileUtils.mkpath(File.join(File.dirname(__FILE__), '..', 'log')) 
    2434end 
    2535 
  • trunk/db/init/base/skins/default/Node.zafu

    r1212 r1215  
    1111  </r:void> 
    1212 
    13   <r:javascripts list='prototype,effects,zena'/> 
     13  <r:javascripts/> 
    1414  <r:uses_calendar/> 
    1515</head> 
  • trunk/lib/multiversion.rb

    r1192 r1215  
    484484           
    485485          if ok && publish_after_save 
    486             if can_apply?(:publish) 
     486            if v_status == Zena::Status[:pub] 
     487              ok = after_publish && update_publish_from 
     488            elsif can_apply?(:publish) 
    487489              ok = apply(:publish) 
    488490            elsif can_apply?(:propose) 
     
    545547             
    546548            if v && (v.user_id == visitor[:id]) && (v.status == Zena::Status[:red] || redit) 
    547               @old_version = @version 
    548               @redaction   = @version = v 
     549              @old_title = @version.title # node sync_name leaking here... 
     550              @redaction = @version = v 
    549551            elsif v 
    550552              errors.add('base', "(#{v.user.login}) is editing this node") 
  • trunk/lib/parser/lib/rules/zena.rb

    r1211 r1215  
    30383038      elsif node_kind_of?(Node) 
    30393039        "<%= #{node}.v_title %>" 
     3040      elsif node_kind_of?(Version) 
     3041        "<%= #{node}.title %>" 
    30403042      else 
    30413043        _('edit') 
  • trunk/test/unit/node_test.rb

    r1193 r1215  
    13781378  end 
    13791379   
     1380  def test_sync_name_on_v_title_change_auto_pub_no_sync 
     1381    Site.connection.execute "UPDATE sites set auto_publish = 1, redit_time = 3600 WHERE id = #{sites_id(:zena)}" 
     1382    Version.connection.execute "UPDATE versions set updated_at = '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}' WHERE node_id IN (#{nodes_id(:status)},#{nodes_id(:people)})" 
     1383    login(:tiger) 
     1384    # was not in sync 
     1385    node = secure!(Node) { nodes(:status) } 
     1386    assert node.update_attributes(:v_title => 'simply different') 
     1387    assert_equal 'status', node.name 
     1388    visitor.lang = 'fr' 
     1389    # not ref lang 
     1390    node = secure!(Node) { nodes(:people) } 
     1391    assert node.update_attributes(:v_title => 'nice people') 
     1392    assert_equal 'fr', node.v_lang 
     1393    assert_equal 'people', node.name 
     1394  end 
     1395   
     1396  def test_sync_name_on_v_title_change_auto_pub 
     1397    Site.connection.execute "UPDATE sites set auto_publish = 1, redit_time = 3600 WHERE id = #{sites_id(:zena)}" 
     1398    Version.connection.execute "UPDATE versions set updated_at = '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}' WHERE node_id IN (#{nodes_id(:people)})" 
     1399    login(:tiger) 
     1400    # was in sync, correct lang 
     1401    node = secure!(Node) { nodes(:people) } 
     1402    assert node.update_attributes(:v_title => 'nice people') 
     1403    assert_equal 'nicePeople', node.name 
     1404  end 
     1405   
    13801406  # FIXME: write test 
    13811407  def test_assets