diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index debda938..e7490f5b 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -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"). diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d26cf698..8313d5e7 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 6860bfa6..7904ec5a 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -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) @@ -86,7 +87,11 @@ class SoftapplicationsController < ApplicationController # GET /softapplications/new.json 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) diff --git a/app/models/project.rb b/app/models/project.rb index e0cc27b3..21dd4a43 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/models/projecting_softapplication.rb b/app/models/projecting_softapplication.rb new file mode 100644 index 00000000..e4c8a872 --- /dev/null +++ b/app/models/projecting_softapplication.rb @@ -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 diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 3911424e..5e1e1bd5 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -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 = {}) diff --git a/app/models/user.rb b/app/models/user.rb index 20624888..ae00e438 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index ad822222..93a3144a 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -124,6 +124,14 @@


+ + + <%= l(:label_work_deposit_project) %>: + <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2' %> + <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target=>'_blank'%> +
+
+
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index c077bc82..99a81158 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -48,8 +48,9 @@ - <% unless @softapplication.deposit_project_url.nil? %> - <%= textilizable ("托管项目网址: " + @softapplication.deposit_project_url) %> + <% unless @softapplication.deposit_project.nil? %> + <%#= textilizable ("托管项目: " + @project.name) %> + 托管项目:<%=@project.name%> <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index fb6e10f5..654c9583 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: 暂无描述。 diff --git a/db/migrate/20140519020211_add_user_id_to_projects.rb b/db/migrate/20140519020211_add_user_id_to_projects.rb new file mode 100644 index 00000000..912c637b --- /dev/null +++ b/db/migrate/20140519020211_add_user_id_to_projects.rb @@ -0,0 +1,5 @@ +class AddUserIdToProjects < ActiveRecord::Migration + def change + add_column :projects, :user_id, :integer + end +end diff --git a/db/migrate/20140519030825_create_projecting_softapplictions.rb b/db/migrate/20140519030825_create_projecting_softapplictions.rb new file mode 100644 index 00000000..9379ed5c --- /dev/null +++ b/db/migrate/20140519030825_create_projecting_softapplictions.rb @@ -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 diff --git a/db/migrate/20140519074133_add_deposit_project_to_softapplications.rb b/db/migrate/20140519074133_add_deposit_project_to_softapplications.rb new file mode 100644 index 00000000..0b2bf65e --- /dev/null +++ b/db/migrate/20140519074133_add_deposit_project_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddDepositProjectToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :deposit_project, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index fb241ac0..dec87fda 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/lib/redmine.rb b/lib/redmine.rb index d22feb9f..3d356543 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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' }, diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index c1aa1ff8..3239908c 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -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;