初步增加了新建参赛作品中参赛作品所属的托管项目列表

This commit is contained in:
wanglinchun 2014-05-19 17:39:51 +08:00
parent 84ae8a1cde
commit 9fb9d2dbdf
16 changed files with 91 additions and 22 deletions

View File

@ -293,7 +293,7 @@ class ContestsController < ApplicationController
###我要参赛
def show_attendingcontest
##取出参赛项目
##取出参赛项目--项目列表
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
# @contesting_project_count = @contesting_project_all.count
@ -333,7 +333,7 @@ class ContestsController < ApplicationController
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
end
end
##取出参赛应用
##取出参赛应用 --应用列表
@softapplication = Softapplication.all
@contesting_softapplication = @contest.contesting_softapplications.
joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id").

View File

@ -564,6 +564,7 @@ class ProjectsController < ApplicationController
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.user_id = User.current.id
@project.safe_attributes = params[:project]
if @course_tag == '1'
@project.identifier = @course.extra

View File

@ -47,6 +47,7 @@ class SoftapplicationsController < ApplicationController
def show
@softapplication = Softapplication.find(params[:id])
@project = Project.find_by_identifier(@softapplication.deposit_project)
# 打分统计
stars_reates = @softapplication.
rates(:quality)
@ -87,6 +88,10 @@ class SoftapplicationsController < ApplicationController
def new
@softapplication = Softapplication.new
#添加当前用户创建过的项目作为托管项目(下拉项目列表)
project = Project.find(params[:user_id])
#end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @softapplication }
@ -122,7 +127,10 @@ class SoftapplicationsController < ApplicationController
def create
@softapplication = Softapplication.new(params[:softapplication])
@softapplication.user = User.current
@softapplication.deposit_project = params[:project]
@softapplication.save_attachments(params[:attachments])
respond_to do |format|
if @softapplication.save
ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id)

View File

@ -56,6 +56,8 @@ class Project < ActiveRecord::Base
#added by xianbo for delete biding_project
has_many :biding_projects, :dependent => :destroy
has_many :contesting_projects, :dependent => :destroy
has_many :projecting_softapplications, :dependent => :destroy
has_many :softapplications, :through => :projecting_softapplications
#ended by xianbo
# added by fq
has_many :journals_for_messages, :as => :jour, :dependent => :destroy

View File

@ -0,0 +1,16 @@
class ProjectingSoftapplication < ActiveRecord::Base
attr_accessible :project_id, :softapplication_id, :user_id
belongs_to :project
belongs_to :softapplication
belongs_to :user
def self.create_softapplication_projecting(project_id, softapplication_id)
self.create(:user_id => User.current.id, :project_id => project_id,
:softapplication_id => softapplication_id)
end
end

View File

@ -1,12 +1,14 @@
class Softapplication < ActiveRecord::Base
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers, :deposit_project_url
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers, :deposit_project_url, :deposit_project
acts_as_attachable
seems_rateable :allow_update => true, :dimensions => :quality
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
has_many :projecting_softapplications, :dependent => :destroy
belongs_to :user
belongs_to :project
has_many :contests, :through => :contesting_softapplications
def add_jour(user, notes, reference_user_id = 0, options = {})

View File

@ -80,6 +80,7 @@ class User < Principal
has_many :biding_projects, :dependent => :destroy
has_many :contesting_projects, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
has_many :projecting_softapplications, :dependent => :destroy
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
##ended by xianbo

View File

@ -125,6 +125,14 @@
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2' %></span>
<span><%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target=>'_blank'%></span>
</tr><br/>
<br />
<br />
<fieldset style="width: 500px", style="padding-top: 10px">
<legend>
上传作品软件包和作品截图

View File

@ -48,8 +48,9 @@
</tr>
<tr>
<td style="padding-left: 40px">
<% unless @softapplication.deposit_project_url.nil? %>
<%= textilizable ("托管项目网址: " + @softapplication.deposit_project_url) %>
<% unless @softapplication.deposit_project.nil? %>
<%#= textilizable ("托管项目: " + @project.name) %>
托管项目:<%=@project.name%>
<% end %>
</td>
</tr>

View File

@ -1864,6 +1864,7 @@ zh:
label_softapplication_developer: 上传人员
label_softapplication_developers: 开发人员
label_work_deposit_project_url: 托管项目网址
label_work_deposit_project: 托管项目
label_softapplication_name_condition: 25个汉字以内50个字符
label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。
label_contest_description_no: 暂无描述。

View File

@ -0,0 +1,5 @@
class AddUserIdToProjects < ActiveRecord::Migration
def change
add_column :projects, :user_id, :integer
end
end

View File

@ -0,0 +1,14 @@
class CreateProjectingSoftapplictions < ActiveRecord::Migration
def up
create_table :projecting_softapplictions do |t|
t.integer :user_id
t.integer :softapplication_id
t.integer :project_id
t.timestamps
end
def down
drop_table :projecting_softapplictions
end
end
end

View File

@ -0,0 +1,5 @@
class AddDepositProjectToSoftapplications < ActiveRecord::Migration
def change
add_column :softapplications, :deposit_project, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140513073801) do
ActiveRecord::Schema.define(:version => 20140519074133) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -599,6 +599,14 @@ ActiveRecord::Schema.define(:version => 20140513073801) do
add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade"
create_table "projecting_softapplictions", :force => true do |t|
t.integer "user_id"
t.integer "softapplication_id"
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "projects", :force => true do |t|
t.string "name", :default => "", :null => false
t.text "description"
@ -614,6 +622,7 @@ ActiveRecord::Schema.define(:version => 20140513073801) do
t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type"
t.boolean "hidden_repo", :default => false, :null => false
t.integer "user_id"
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"
@ -747,6 +756,7 @@ ActiveRecord::Schema.define(:version => 20140513073801) do
t.integer "is_public"
t.string "application_developers"
t.string "deposit_project_url"
t.string "deposit_project"
end
create_table "students_for_courses", :force => true do |t|
@ -870,19 +880,6 @@ ActiveRecord::Schema.define(:version => 20140513073801) do
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
create_table "user_scores", :force => true do |t|
t.integer "user_id", :null => false
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
t.integer "file"
t.integer "issue"
end
create_table "user_statuses", :force => true do |t|
t.integer "changesets_count"
t.integer "watchers_count"

View File

@ -279,8 +279,8 @@ end
###new add by linchun
Redmine::MenuManager.map :contest_menu do |menu|
menu.push :respond, :show_contest_contest_path, :caption => :label_user_response
#menu.push :project, :show_project_contest_path, :caption => :label_contest_project
#menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application
menu.push :project, :show_project_contest_path, :caption => :label_contest_project
menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application
menu.push :attendingcontest, {:controller => 'contests', :action => 'show_attendingcontest'}, :caption => :label_attending_contest
# menu.push :attendingcontest, :show_attendingcontest_contest_path, :caption => :label_attendin,g_contest
# menu.push :result, { :controller => 'bids', :action => 'show_results' },

View File

@ -1867,6 +1867,14 @@ a.reference {
color: #ACAEB1;
width: 100%;
}
.grayline2{
border: #d5dee9 1px solid;
font-size: 12px;
color: #ACAEB1;
width: 69%;
}
div.tableline{
height: 1px;
background-color: #ACAEB1;