修改参赛应用中应用和竞赛的关联前,目前部分代码由于数据表及关联没考虑清楚,导致无法关联,下一步修改代码,重新建表,完成关联功能及应用的正常显示
This commit is contained in:
parent
be61b9d1ac
commit
b97cdd6b0d
|
@ -4,7 +4,7 @@ class ContestsController < ApplicationController
|
|||
menu_item :respond
|
||||
menu_item :project, :only => :show_project
|
||||
menu_item :application, :only => :show_softapplication
|
||||
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :create,:destroy,:more,:back,:add,:new,:show_results, :set_reward,
|
||||
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
|
||||
:show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
|
||||
|
||||
# added by fq
|
||||
|
@ -153,6 +153,22 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def show_contest_softapplication
|
||||
contests = Contest.where('parent_id = ?', @contest.id)
|
||||
@softapplications = []
|
||||
for contest in contests
|
||||
@softapplications += contest.softapplications
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def show_contest_user
|
||||
contests = Contest.find(:all)
|
||||
@users = []
|
||||
|
@ -219,6 +235,31 @@ class ContestsController < ApplicationController
|
|||
############
|
||||
##显示参赛的应用
|
||||
def show_softapplication
|
||||
# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
# @option = []
|
||||
|
||||
# @user = @contest.user
|
||||
@softapplication = Softapplication.all
|
||||
|
||||
# @temp = []
|
||||
# @softapplicationt.each do |pro|
|
||||
# if pro.project && pro.project.project_status
|
||||
# @temp << pro
|
||||
# end
|
||||
# @temp
|
||||
|
||||
# if @temp.size > 0
|
||||
# @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
# end
|
||||
# end
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# render :layout => 'base_newcontest'
|
||||
# }
|
||||
# format.api
|
||||
# end
|
||||
##########################
|
||||
@contest = Contest.find_by_id(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
|
@ -227,7 +268,7 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
###添加应标项目
|
||||
###添加已创建的参赛项目
|
||||
def add
|
||||
project = Project.find(params[:contest])
|
||||
contest_message = params[:contest_for_save][:contest_message]
|
||||
|
@ -247,7 +288,27 @@ class ContestsController < ApplicationController
|
|||
format.js
|
||||
end
|
||||
end
|
||||
###添加已发布的参赛应用
|
||||
def add_softapplication
|
||||
softapplication = Softapplication.find(params[:contest])
|
||||
contest_message = params[:contest_for_save][:contest_message]
|
||||
if Softapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0
|
||||
if Softapplication.create_contesting(@contest.id, softapplication.id, contest_message)
|
||||
flash.now[:notice] = l(:label_bidding_contest_succeed)
|
||||
end
|
||||
else
|
||||
flash.now[:error] = l(:label_bidding_fail)
|
||||
end
|
||||
|
||||
@softapplication = @contest.softapplications
|
||||
|
||||
render :text => params.to_json
|
||||
# respond_to do |format|
|
||||
|
||||
# format.html { redirect_to :back }
|
||||
# format.js
|
||||
# end
|
||||
end
|
||||
## 新建留言
|
||||
def create
|
||||
|
||||
|
|
|
@ -1419,7 +1419,15 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_more_contest_softapplication?(contest)
|
||||
if contest.softapplications.where('is_public = 1').count > 12
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def show_contest_project(bid)
|
||||
html = ''
|
||||
if contest.projects.where('is_public = 1').count == 0
|
||||
|
|
|
@ -56,21 +56,7 @@ module ContestsHelper
|
|||
end
|
||||
#end
|
||||
|
||||
# def sort_bid(state, project_type)
|
||||
# content = ''.html_safe
|
||||
# case state
|
||||
# when 0
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
#
|
||||
# when 1
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
# content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
# end
|
||||
# content = content_tag('ul', content)
|
||||
# content_tag('div', content, :class => "tabs")
|
||||
# end
|
||||
|
||||
|
||||
#huang
|
||||
def sort_contest(state)
|
||||
content = ''.html_safe
|
||||
|
@ -115,6 +101,16 @@ module ContestsHelper
|
|||
@projects.count
|
||||
end
|
||||
|
||||
def count_contest_softapplication
|
||||
contests = Contest.find(:id)
|
||||
@softapplications = []
|
||||
for contest in contests
|
||||
@softapplications += contest.contesting_projects
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
||||
|
||||
def count_contest_user
|
||||
contests = Contest.find(:id)
|
||||
@users = []
|
||||
|
@ -154,5 +150,12 @@ module ContestsHelper
|
|||
end
|
||||
tmp
|
||||
end
|
||||
def select_option_app_helper options
|
||||
tmp = Hash.new
|
||||
options.each do |project|
|
||||
tmp[project.name] = project.id
|
||||
end
|
||||
tmp
|
||||
end
|
||||
|
||||
end
|
|
@ -97,8 +97,8 @@ module WelcomeHelper
|
|||
sort_bid_by_hot
|
||||
end
|
||||
|
||||
def find_all_hot_contest
|
||||
sort_contest_by_hot
|
||||
def find_all_hot_contest limit=10
|
||||
Contest.all.take limit
|
||||
end
|
||||
|
||||
def cal_memos_count event
|
||||
|
|
|
@ -5,6 +5,8 @@ class Contest < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :projects, :through => :contesting_projects
|
||||
has_many :softapplications, :dependent => :destroy
|
||||
# has_many :softapplications, :through => :softapplications
|
||||
has_many :projects_member, :class_name => 'User', :through => :projects
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
class Softapplication < ActiveRecord::Base
|
||||
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id
|
||||
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id
|
||||
acts_as_attachable
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
belongs_to :user
|
||||
belongs_to :contest
|
||||
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
</td>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%#= render :partial=> "list_projects" %>
|
||||
<!-- <%= @contest.softapplications.to_json %> -->
|
||||
<%= render :partial=> "list_softapplications",:locals => {:softapplication => softapplication,:contest => @contest }%>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -56,8 +56,47 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<!--我要以发布应用的形式参加竞赛-弹出框-->
|
||||
<div id = 'flash' style="float:left; width: 100%; display: nonea" ></div>
|
||||
<div id="put-bid-form" style="display: nonea">
|
||||
<%= form_for "contest_for_save", :remote=>true, :url => {:controller => 'contests', :action => 'add_softapplication'}, :update => "softapplication_list", :complete => '$("#put-bid-form").hide();' do |f| %>
|
||||
<table id="contesting_table" border="0" width="100%" style="margin-left: 40px;"> <!--该table为点击我要参加后弹出的-->
|
||||
<tr>
|
||||
<td><%= select_tag 'contest', options_for_select(select_option_app_helper(@softapplication)), :name => 'contest', :class => 'grayline' %></td>
|
||||
<div id="prompt_create_pro">
|
||||
<td>
|
||||
<p>
|
||||
<div class="font_lighter" style="font-size: 13px;">
|
||||
<%= link_to '创建应用', new_softapplication_path(:target=>'_blank') %> <!--跳转到softapplication的new.html.erb-->
|
||||
</div>
|
||||
</p>
|
||||
</td>
|
||||
</div>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><%= f.text_area :contest_message, :id => "contest_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason), :style => "resize: none;", :class => 'noline'%></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">
|
||||
<%= submit_tag l(:button_add), :name => nil , :class => "enterprise",
|
||||
:onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||
:onmouseover => "this.style.backgroundPosition = 'left -30px'"%>
|
||||
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
|
||||
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id='bidding_project_list'>
|
||||
<%= render :partial => 'softapplication_list' %>
|
||||
|
||||
|
||||
<div id='contesting_project_list'>
|
||||
<%#= render :partial => 'softapplication_list', :locals => {:softapplication => @softapplication,:contest => @contest} %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>所属类别:<%= @softapplication.app_type_name %></td>
|
||||
<td>发布时间:<%=@softapplication.created_at %></span></td>
|
||||
<td>发布时间:<%=format_time @softapplication.created_at %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>开发者:<%= @softapplication.user.name %></td>
|
||||
<td>系统支持:<%= @softapplication.android_min_version_available %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>已提交竞赛: <%= @softapplication.contest.name%></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</td>
|
||||
|
|
|
@ -119,18 +119,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!--搜索框-->
|
||||
<!-- <div class="align-right">
|
||||
<%= text_field_tag 'name', params[:name], :size => 48 %>
|
||||
<%= hidden_field_tag 'project_type', params[:project_type] %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise" %>
|
||||
</div> -->
|
||||
|
||||
<!--搜索框-->
|
||||
<div style="width: 57%;margin: 10px auto;">
|
||||
<%= form_tag( method: 'post') do %>
|
||||
|
||||
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %>
|
||||
<%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:400px;'%>
|
||||
|
||||
<%= submit_tag l(:label_search), :class => "enterprise"%>
|
||||
<%= hidden_field_tag 'project_type', params[:project_type] %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%>
|
||||
<% end %>
|
||||
<div class='font_lighter' style="display: inline-block; margin-top:3px;">竞赛相关内容搜索,如竞赛题目,参赛题目,参赛人名等。</div>
|
||||
</div>
|
||||
|
@ -180,7 +176,26 @@
|
|||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
|
||||
|
||||
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>最新参赛应用</strong></h3>
|
||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %>
|
||||
<li style="background-image:none;">
|
||||
<p class="layout">
|
||||
<span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}",
|
||||
:style => "margin-left: 28px;", :target => "_blank") %></span>
|
||||
</p>
|
||||
<p class="layout-1" >
|
||||
<%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %>
|
||||
</p>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right" style="float: right; width: 48%; ">
|
||||
<ul class="welcome-message-list">
|
||||
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
|
||||
|
@ -210,48 +225,6 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
|
||||
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3>
|
||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
|
||||
<li style="background-image:none;">
|
||||
<p class="layout">
|
||||
<span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}",
|
||||
:style => "margin-left: 28px;", :target => "_blank") %></span>
|
||||
</p>
|
||||
<p class="layout-1" >
|
||||
<%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %>
|
||||
</p>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
|
||||
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门众包</strong></h3>
|
||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'index'}, :target => "_blank" %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>
|
||||
<li style="background-image:none;">
|
||||
<p class="layout">
|
||||
<span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( bid.name, respond_path(bid.id), :class => "d-g-blue d-p-project-name", :title => "#{bid.name}",
|
||||
:style => "margin-left: 28px;", :target => "_blank") %></span>
|
||||
</p>
|
||||
<p class="layout-1" >
|
||||
<%= content_tag "span", bid.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => bid.description %>
|
||||
</p>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
<div class="clr">
|
||||
</div>
|
||||
|
|
|
@ -1837,3 +1837,4 @@ zh:
|
|||
label_softapplication_developer: 开发者
|
||||
label_softapplication_name_condition: 25个汉字以内(50个字符)
|
||||
label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。
|
||||
label_contest_description_no: 暂无描述。
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
RedmineApp::Application.routes.draw do
|
||||
|
||||
##new added by linchun #以发布应用的形式参与竞赛
|
||||
resources :softapplications do
|
||||
|
||||
collection do
|
||||
|
@ -38,6 +38,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'new' , via: :post
|
||||
end
|
||||
member do
|
||||
match 'add_softapplication'
|
||||
match 'update_contest' , via: [:put]
|
||||
match 'show_contest' , via: :get
|
||||
match 'show_project' , via: :get
|
||||
|
|
48
db/schema.rb
48
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140404030103) do
|
||||
ActiveRecord::Schema.define(:version => 20140411005214) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -23,11 +23,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) do
|
|||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||
|
||||
create_table "andoidcontests", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "attachments", :force => true do |t|
|
||||
t.integer "container_id"
|
||||
t.string "container_type", :limit => 30
|
||||
|
@ -172,6 +167,16 @@ ActiveRecord::Schema.define(:version => 20140404030103) do
|
|||
t.string "reward"
|
||||
end
|
||||
|
||||
create_table "contesting_softapplications", :force => true do |t|
|
||||
t.integer "softapplication_id"
|
||||
t.integer "contest_id"
|
||||
t.integer "user_id"
|
||||
t.string "description"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "reward"
|
||||
end
|
||||
|
||||
create_table "contests", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "budget"
|
||||
|
@ -528,19 +533,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) do
|
|||
t.string "salt", :null => false
|
||||
end
|
||||
|
||||
create_table "open_source_projects", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "description", :default => ""
|
||||
t.integer "commit_count", :default => 0
|
||||
t.integer "code_line", :default => 0
|
||||
t.integer "users_count", :default => 0
|
||||
t.date "last_commit_time"
|
||||
t.string "url"
|
||||
t.date "date_collected"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "praise_tread_caches", :force => true do |t|
|
||||
t.integer "object_id", :null => false
|
||||
t.string "object_type"
|
||||
|
@ -620,21 +612,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) do
|
|||
add_index "queries", ["project_id"], :name => "index_queries_on_project_id"
|
||||
add_index "queries", ["user_id"], :name => "index_queries_on_user_id"
|
||||
|
||||
create_table "relative_memos", :force => true do |t|
|
||||
t.integer "osp_id", :null => false
|
||||
t.integer "parent_id"
|
||||
t.string "subject", :null => false
|
||||
t.text "content", :null => false
|
||||
t.integer "author_id"
|
||||
t.integer "replies_count", :default => 0
|
||||
t.integer "last_reply_id"
|
||||
t.boolean "lock", :default => false
|
||||
t.boolean "sticky", :default => false
|
||||
t.boolean "is_quote", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "repositories", :force => true do |t|
|
||||
t.integer "project_id", :default => 0, :null => false
|
||||
t.string "url", :default => "", :null => false
|
||||
|
@ -716,6 +693,9 @@ ActiveRecord::Schema.define(:version => 20140404030103) do
|
|||
t.integer "user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "contest_id"
|
||||
t.integer "softapplication_id"
|
||||
t.integer "is_public"
|
||||
end
|
||||
|
||||
create_table "students_for_courses", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue