From 9fb9d2dbdfb12099e693cb008dee15f774b0a5c8 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 19 May 2014 17:39:51 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E6=96=B0=E5=BB=BA=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E4=B8=AD=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81=E6=89=80=E5=B1=9E?= =?UTF-8?q?=E7=9A=84=E6=89=98=E7=AE=A1=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 4 +-- app/controllers/projects_controller.rb | 1 + .../softapplications_controller.rb | 10 +++++++- app/models/project.rb | 2 ++ app/models/projecting_softapplication.rb | 16 ++++++++++++ app/models/softapplication.rb | 4 ++- app/models/user.rb | 1 + .../contests/show_attendingcontest.html.erb | 8 ++++++ app/views/softapplications/show.html.erb | 5 ++-- config/locales/zh.yml | 1 + .../20140519020211_add_user_id_to_projects.rb | 5 ++++ ...30825_create_projecting_softapplictions.rb | 14 +++++++++++ ...add_deposit_project_to_softapplications.rb | 5 ++++ db/schema.rb | 25 ++++++++----------- lib/redmine.rb | 4 +-- .../stylesheets/application.css | 8 ++++++ 16 files changed, 91 insertions(+), 22 deletions(-) create mode 100644 app/models/projecting_softapplication.rb create mode 100644 db/migrate/20140519020211_add_user_id_to_projects.rb create mode 100644 db/migrate/20140519030825_create_projecting_softapplictions.rb create mode 100644 db/migrate/20140519074133_add_deposit_project_to_softapplications.rb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index debda938f..e7490f5b0 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 d26cf698e..8313d5e72 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 6860bfa6a..7904ec5a6 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 e0cc27b3b..21dd4a439 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 000000000..e4c8a872a --- /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 3911424e9..5e1e1bd50 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 20624888a..ae00e4380 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 ad8222224..93a3144a5 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 c077bc822..99a811583 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 fb6e10f5a..654c95831 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 000000000..912c637bc --- /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 000000000..9379ed5c9 --- /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 000000000..0b2bf65e1 --- /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 fb241ac03..dec87fda2 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 d22feb9fc..3d3565430 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 c1aa1ff81..3239908c2 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; From f8154103811f9f9aea85fde306c96aa7b71a3c48 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 20 May 2014 09:40:13 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81=E4=B8=AD=E6=89=98?= =?UTF-8?q?=E7=AE=A1=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=98=BE=E7=A4=BA=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E5=92=8C=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/show_attendingcontest.html.erb | 7 ++----- public/themes/redpenny-master/stylesheets/application.css | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 93a3144a5..30ce077d1 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -83,7 +83,7 @@