From: <zn...@us...> - 2009-05-29 09:06:34
|
Revision: 893 http://crackerjack.svn.sourceforge.net/crackerjack/?rev=893&view=rev Author: znz Date: 2009-05-29 09:06:25 +0000 (Fri, 29 May 2009) Log Message: ----------- editable compare_log.comment Modified Paths: -------------- trunk/viewsite/app/controllers/compare_logs_controller.rb trunk/viewsite/app/models/compare_log.rb trunk/viewsite/app/views/compare_logs/show.html.erb trunk/viewsite/public/stylesheets/application.css trunk/viewsite/test/unit/compare_log_test.rb Modified: trunk/viewsite/app/controllers/compare_logs_controller.rb =================================================================== --- trunk/viewsite/app/controllers/compare_logs_controller.rb 2009-05-26 09:39:41 UTC (rev 892) +++ trunk/viewsite/app/controllers/compare_logs_controller.rb 2009-05-29 09:06:25 UTC (rev 893) @@ -22,4 +22,29 @@ format.xml { render :xml => @compare_log } end end + + # PUT /compare_logs/1 + # PUT /compare_logs/1.xml + def update + @compare_log = CompareLog.find(params[:id]) + + comment = params[:compare_log][:comment] + @compare_log.comment = comment + + respond_to do |format| + if @compare_log.save + flash[:notice] = 'compare_log was successfully updated.' + format.html { redirect_to(@compare_log) } + format.xml { head :ok } + else + format.html { + @a_execute_log = @compare_log.a_execute_log + @b_execute_log = @compare_log.b_execute_log + render :action => "show" + } + format.xml { render :xml => @compare_log.errors, :status => :unprocessable_ent +ity } + end + end + end end Modified: trunk/viewsite/app/models/compare_log.rb =================================================================== --- trunk/viewsite/app/models/compare_log.rb 2009-05-26 09:39:41 UTC (rev 892) +++ trunk/viewsite/app/models/compare_log.rb 2009-05-29 09:06:25 UTC (rev 893) @@ -23,6 +23,14 @@ # validates_presence_of :c_out_log, :c_err_log # can be empty validates_inclusion_of :compare_status, :in => 0...STATUS_MAX + #validates_length_of :comment, :maximum => 1000 + validates_each :comment do |record, attr, value| + count = record.comment_was.to_s.split(//).size + 1000 + if count < value.to_s.split(//).size + record.errors.add attr, "is too long (maximum is #{count} characters)" + end + end + delegate :test_name, :to => :system_call delegate :default_compare?, :to => :system_call Modified: trunk/viewsite/app/views/compare_logs/show.html.erb =================================================================== --- trunk/viewsite/app/views/compare_logs/show.html.erb 2009-05-26 09:39:41 UTC (rev 892) +++ trunk/viewsite/app/views/compare_logs/show.html.erb 2009-05-29 09:06:25 UTC (rev 893) @@ -1,5 +1,6 @@ <%- @title = "Compare Log" -%> +<%- unless @compare_log.invalid? -%> <p> <b>A result:</b> <%=link_to h(@a_execute_log.execute_result.to_summary), @a_execute_log %> @@ -43,13 +44,26 @@ <b>Compare status:</b> <%=h @compare_log.to_status %> </p> +<%- end -%> +<%- if true -%> + <%- form_for(@compare_log) do |f| -%> + <%= f.error_messages %> + + <p> + <%= f.label :comment %><br /> + <%= f.text_area :comment, :size => "80x5" %><br /> + <%= f.submit 'Update' %> + </p> + <%- end -%> +<%- else -%> <p> <b>Comment:</b> <%=h @compare_log.comment %> </p> +<%- end -%> -<%- if false -%> +<%- if !@compare_log.invalid? && @a_execute_log && @b_execute_log -%> <table border="1"> <tr> <th>A execute log</th> Modified: trunk/viewsite/public/stylesheets/application.css =================================================================== --- trunk/viewsite/public/stylesheets/application.css 2009-05-26 09:39:41 UTC (rev 892) +++ trunk/viewsite/public/stylesheets/application.css 2009-05-29 09:06:25 UTC (rev 893) @@ -19,3 +19,41 @@ a { text-decoration: none; } + +body { background-color: #fff; color: #333; } + +.fieldWithErrors { + padding: 2px; + background-color: red; + display: table; +} + +#errorExplanation { + width: 400px; + border: 2px solid red; + padding: 7px; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#errorExplanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + background-color: #c00; + color: #fff; +} + +#errorExplanation p { + color: #333; + margin-bottom: 0; + padding: 5px; +} + +#errorExplanation ul li { + font-size: 12px; + list-style: square; +} Modified: trunk/viewsite/test/unit/compare_log_test.rb =================================================================== --- trunk/viewsite/test/unit/compare_log_test.rb 2009-05-26 09:39:41 UTC (rev 892) +++ trunk/viewsite/test/unit/compare_log_test.rb 2009-05-29 09:06:25 UTC (rev 893) @@ -1,8 +1,9 @@ require 'test_helper' class CompareLogTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true + test "too long is invalid" do + log = CompareLog.first + log.comment = " "*10000 + assert log.invalid? end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |