修改竞赛和参与竞赛的新建应用之间的关联关系
This commit is contained in:
parent
b97cdd6b0d
commit
a4df4cf893
|
@ -157,7 +157,7 @@ class ContestsController < ApplicationController
|
|||
contests = Contest.where('parent_id = ?', @contest.id)
|
||||
@softapplications = []
|
||||
for contest in contests
|
||||
@softapplications += contest.softapplications
|
||||
@softapplications += contest.contesting_softapplications
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -240,6 +240,7 @@ class ContestsController < ApplicationController
|
|||
|
||||
# @user = @contest.user
|
||||
@softapplication = Softapplication.all
|
||||
@contesting_softapplication = @contest.contesting_softapplications
|
||||
|
||||
# @temp = []
|
||||
# @softapplicationt.each do |pro|
|
||||
|
@ -292,15 +293,15 @@ class ContestsController < ApplicationController
|
|||
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)
|
||||
if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0
|
||||
if ContestingSoftapplication.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
|
||||
@contesting_softapplication = @contest.contesting_softapplications
|
||||
|
||||
render :text => params.to_json
|
||||
# respond_to do |format|
|
||||
|
|
|
@ -105,7 +105,7 @@ module ContestsHelper
|
|||
contests = Contest.find(:id)
|
||||
@softapplications = []
|
||||
for contest in contests
|
||||
@softapplications += contest.contesting_projects
|
||||
@softapplications += contest.contesting_softapplications
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
@ -122,6 +122,16 @@ module ContestsHelper
|
|||
@users.count
|
||||
end
|
||||
|
||||
def count_contest_softapplication_user
|
||||
contests = Contest.find(:id)
|
||||
@users = []
|
||||
for contest in contests
|
||||
for project in contest.softapplications
|
||||
@users += softapplication.users
|
||||
end
|
||||
end
|
||||
@users.count
|
||||
end
|
||||
def im_watching_student_id? contest
|
||||
people = []
|
||||
people << contest.author
|
||||
|
@ -152,8 +162,8 @@ module ContestsHelper
|
|||
end
|
||||
def select_option_app_helper options
|
||||
tmp = Hash.new
|
||||
options.each do |project|
|
||||
tmp[project.name] = project.id
|
||||
options.each do |option|
|
||||
tmp[option.name] = option.id
|
||||
end
|
||||
tmp
|
||||
end
|
||||
|
|
|
@ -5,8 +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 :contesting_softapplications, :dependent => :destroy
|
||||
has_many :softapplications, :through => :contesting_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
|
||||
|
|
|
@ -19,6 +19,11 @@ class ContestingProject < ActiveRecord::Base
|
|||
: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)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ class Softapplication < ActiveRecord::Base
|
|||
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
|
||||
has_many :contesting_softapplications, :dependent => :destroy
|
||||
belongs_to :user
|
||||
belongs_to :contest
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ class User < Principal
|
|||
## added by xianbo for delete
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :contesting_softapplications, :dependent => :destroy
|
||||
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
|
||||
##ended by xianbo
|
||||
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><span class="font_lighter"><%= l(:label_x_biding_project, :count => contest.contesting_projects.count) %>(<strong><span style="font-size: 17px"><%= link_to contest.contesting_projects.count %></span></strong>)</span>
|
||||
<span class="font_lighter"><%= l(:label_x_bids_responses, :count => contest.commit) %>(<strong><span style="font-size: 17px"><%= link_to contest.commit, respond_path(contest) %></span></strong>)</span>
|
||||
<span class="font_lighter"><%= l(:label_x_followers, :count => contest.watcher_users.count) %>(<strong><span style="font-size: 17px"><%= link_to contest.watcher_users.count, respond_path(contest) %></span></strong>)</span>
|
||||
<td><span class="font_lighter"><%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<strong><span style="font-size: 17px"><%= link_to contest.contesting_projects.count %></span></strong>)</span>
|
||||
<span class="font_lighter"><%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<strong><span style="font-size: 17px"><%= link_to contest.contesting_softapplications.count %></span></strong>)</span>
|
||||
<span class="font_lighter"><%= l(:label_contest_response, :count => contest.commit) %>(<strong><span style="font-size: 17px"><%= link_to contest.commit, respond_path(contest) %></span></strong>)</span>
|
||||
<span class="font_lighter"><%= l(:label_contest_watchers, :count => contest.watcher_users.count) %>(<strong><span style="font-size: 17px"><%= link_to contest.watcher_users.count, respond_path(contest) %></span></strong>)</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -12,5 +12,4 @@
|
|||
</td>
|
||||
<% end %>
|
||||
</table>
|
||||
<!-- <%= @contest.softapplications.to_json %> -->
|
||||
<%= render :partial=> "list_softapplications",:locals => {:softapplication => softapplication,:contest => @contest }%>
|
||||
<%= render :partial=> "list_softapplications",:locals => {:contesting_softapplication => contesting_softapplication,:contest => @contest }%>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<!--我要以发布应用的形式参加竞赛-弹出框-->
|
||||
<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| %>
|
||||
<%= form_for "contest_for_save", :remote=>true, :url => {:controller => 'contests', :action => 'add_softapplication'}, :update => "contesting_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>
|
||||
|
@ -97,6 +97,6 @@
|
|||
|
||||
|
||||
<div id='contesting_project_list'>
|
||||
<%#= render :partial => 'softapplication_list', :locals => {:softapplication => @softapplication,:contest => @contest} %>
|
||||
<%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
<td>开发者:<%= @softapplication.user.name %></td>
|
||||
<td>系统支持:<%= @softapplication.android_min_version_available %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>已提交竞赛: <%= @softapplication.contest.name%></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
</td>
|
||||
|
|
|
@ -1823,6 +1823,9 @@ zh:
|
|||
label_nextstep: 下一步
|
||||
label_participate: 参赛者
|
||||
label_contest_project: 参赛项目
|
||||
label_contest_softapplication: 参赛应用
|
||||
label_contest_response: 用户反馈
|
||||
label_contest_watchers: 关注人员
|
||||
label_contest_application: 参赛应用
|
||||
button_contesting_as_project: 我要参赛(新建项目)
|
||||
button_contesting_as_application: 我要参赛(发布应用)
|
||||
|
|
|
@ -45,6 +45,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'show_softapplication', via: :get
|
||||
match 'show_participator' , via: :get
|
||||
match 'add' , via: [:get, :post]
|
||||
match 'add_softapplication' , via: [:get, :post]
|
||||
match 'create' , via: :post
|
||||
match 'settings' , via: [:get, :post]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue