diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 01d2ea89..0c42c405 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -172,7 +172,7 @@ private @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' @project = @attachment.project end rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 4ca1c193..ccc5c51a 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -294,7 +294,7 @@ class ContestsController < ApplicationController softapplication = Softapplication.find(params[:contest]) contest_message = params[:contest_for_save][:contest_message] if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 - if ContestingSoftapplication.create_contesting(@contest.id, softapplication.id, contest_message) + if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message) flash.now[:notice] = l(:label_bidding_contest_succeed) end else @@ -303,12 +303,11 @@ class ContestsController < ApplicationController @contesting_softapplication = @contest.contesting_softapplications - render :text => params.to_json - # respond_to do |format| + respond_to do |format| - # format.html { redirect_to :back } - # format.js - # end + format.html { redirect_to :back } + format.js + end end ## 新建留言 def create diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 0a0f2541..a1410722 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -15,6 +15,10 @@ class SoftapplicationsController < ApplicationController def show @softapplication = Softapplication.find(params[:id]) @jours = @softapplication.journals_for_messages.order('created_on DESC') + @image_results = [] + @softapplication.attachments.each do |f| + f.image? ? @image_results << f : @image_results + end @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 344238e8..8533c401 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -111,6 +111,14 @@ module ApplicationHelper link_to text, url, html_options end + def link_to_attachment_img(attachment, options={}) + text = options.delete(:text) || attachment.filename + route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path + html_options = options.slice!(:only_path) + url = send(route_method, attachment, attachment.filename, options) + image_tag url, html_options + end + # Generates a link to a SCM revision # Options: # * :text - Link text (default to the formatted revision) diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb index c0c36054..cb2a7fe3 100644 --- a/app/models/contesting_project.rb +++ b/app/models/contesting_project.rb @@ -18,11 +18,7 @@ class ContestingProject < ActiveRecord::Base self.create(:user_id => User.current.id, :contest_id => contest_id, :project_id => project_id, :description => description) end - - def self.cerate_softapplication_contesting(contest_id, softapplication_id, description = nil) - self.create_softapplication(:user_id => User.current.id, :contest_id => contest_id, - :softapplication_id => softapplication_id, :description => description) - end + def update_reward(which) self.update_attribute(:reward,which) diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index fd643a0b..3d6a1d73 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -96,7 +96,7 @@ -
<%= notice %>