显示上传截图+应用显示

This commit is contained in:
wanglinchun 2014-04-11 17:16:22 +08:00
parent a4df4cf893
commit 64895a75ed
7 changed files with 36 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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']

View File

@ -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)

View File

@ -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)

View File

@ -96,7 +96,7 @@
<div id='contesting_project_list'>
<div id='contesting_softapplication_list'>
<%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
</div>

View File

@ -1,3 +1,12 @@
<style>
.softapplication-img .soft-application {
float: left;
width: 25%;
height: 200px;
}
</style>
<p id="notice"><%= notice %></p>
<div style="height: 120px">
@ -32,8 +41,14 @@
<div style="height: 120px">
<div style="font-size: 15px">软件截图:</div>
<div></div>
<div class="softapplication-img">
<% @image_results.take(4).each do |attachment| %>
<%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %>
<% end %>
</div>
<div style='clear :left;'></div>
</div>
<div class="underline-contests_one"></div>
<div style="height: 120px">