From 560ee0a2fcdf1bfde4c4967613cb6bbe58e85e96 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 25 Jul 2014 15:24:55 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index fe80b7d6f..c34e15d93 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 => 20140725013735) do +ActiveRecord::Schema.define(:version => 20140725034309) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -436,6 +436,26 @@ ActiveRecord::Schema.define(:version => 20140725013735) do t.datetime "updated_at", :null => false end + create_table "gitlab_projects", :force => true do |t| + t.integer "gitlab_project_id" + t.integer "project_id" + t.string "repository_url" + t.string "web_url" + t.string "localfile_url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "gitlab_users", :force => true do |t| + t.integer "gitlab_user_id" + t.integer "user_id" + t.string "email" + t.string "password" + t.string "login", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -878,19 +898,6 @@ ActiveRecord::Schema.define(:version => 20140725013735) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1 From 00cf448bda7be4f58b0313aa2b3e03f0b1558820 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 09:18:24 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=A9=BA=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.erb | 7 ++++++- db/schema.rb | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 6270b5f50..7c016e33b 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -137,7 +137,12 @@ <% end %> -

<%= act.notes.html_safe %>

+ <% if act.notes.nil? %> + <% desStr = '' %> + <% else %> + <% desStr=act.notes.html_safe %> + <% end %> +

<%= desStr %>

diff --git a/db/schema.rb b/db/schema.rb index c34e15d93..219666f79 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 => 20140725034309) do +ActiveRecord::Schema.define(:version => 20140725073357) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -419,10 +419,12 @@ ActiveRecord::Schema.define(:version => 20140725034309) do t.string "web_title" t.string "title" t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "page_type" t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 end create_table "forums", :force => true do |t| From 979d6dd067ff50f21f3c1786b1386c6772cc5e79 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 28 Jul 2014 09:22:52 +0800 Subject: [PATCH 03/10] dts_test. controller ===> model --- app/controllers/projects_controller.rb | 162 +++++-------------------- app/models/project.rb | 1 + 2 files changed, 33 insertions(+), 130 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f767aed10..eedb29329 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class ProjectsController < ApplicationController layout :select_project_layout + menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings @@ -459,24 +460,10 @@ class ProjectsController < ApplicationController end def new - @project_type = params[:project_type] ||= params[:course] @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all - - case @project_type - when '0' # Project - @project = Project.new - @project.safe_attributes = params[:project] - when '1' # Course - @project = Project.new - @project.safe_attributes = params[:project] - @course_tag = params[:course] - @course = Course.new - @course.safe_attributes = params[:course] - else # default Project - @project = Project.new - @project.safe_attributes = params[:project] - end + @project = Project.new + @project.safe_attributes = params[:project] render :layout => 'base' end @@ -490,128 +477,43 @@ class ProjectsController < ApplicationController end def create - - @course_tag = params[:project][:project_type] - if(@course_tag=="1") - if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER) - @course = Course.new - @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s - @course.safe_attributes = params[:project][:course] - @course.tea_id = User.current.id - # added by bai - @course.term = params[:term] - @course.time = params[:time] - #@course.school_id = params[:occupation] - @course.school_id = User.current.user_extensions.school_id - @course.setup_time = params[:setup_time] - @course.endup_time = params[:endup_time] - @course.class_period = params[:class_period] - end - end @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all @project = Project.new - @project.user_id = User.current.id - @project.dts_test = params[:project][:dts_test] @project.safe_attributes = params[:project] - if @course_tag == '1' - @project.identifier = @course.extra - end - if @course_tag == '1' - if User.current.user_extensions.identity == 0 - if@course.save - if validate_parent_id && @project.save - @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') - # Add current user as a project member if he is not admin - unless User.current.admin? - r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - m = Member.new(:user => User.current, :roles => [r]) - project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) - if params[:project][:is_public] == '1' - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag) - end - @project.members << m - @project.project_infos << project - end - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - if params[:continue] - attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} - redirect_to new_project_path(attrs, :course => '0') - #Added by young - - elsif params[:course_continue] - redirect_to new_project_path(:course => '1') - #Ended by young - else - redirect_to settings_project_path(@project,:project_type => 1) - end - } - format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } - end - else - @course.destroy - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - end - else - if validate_parent_id && @project.save - @project.delete - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end + if validate_parent_id && @project.save + @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') + # Add current user as a project member if he is not admin + #unless User.current.admin? + r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first + m = Member.new(:user => User.current, :roles => [r]) + project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) + user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) + Rails.logger.debug "UserGrade created: #{user_grades.to_json}" + if params[:project][:is_public] == '1' + project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type) + Rails.logger.debug "ProjectStatus created: #{project_status.to_json}" + end + @project.members << m + @project.project_infos << project_info + #end + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + if params[:continue] + attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} + redirect_to new_project_path(attrs, :course => '0') else - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end + redirect_to settings_project_path(@project) end - end + } + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } end else - #@project.memberships.create - if validate_parent_id && @project.save - @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') - # Add current user as a project member if he is not admin - #unless User.current.admin? - r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - m = Member.new(:user => User.current, :roles => [r]) - project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) - if params[:project][:is_public] == '1' || @course_tag=="1" - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type) - end - @project.members << m - @project.project_infos << project - #end - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - if params[:continue] - attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} - redirect_to new_project_path(attrs, :course => '0') - #Added by young - - elsif params[:course_continue] - redirect_to new_project_path(:course => '1') - #Ended by young - else - redirect_to settings_project_path(@project) - end - } - format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } - end - else - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - end + respond_to do |format| + format.html { render :action => 'new', :layout => 'base'}#Added by young + format.api { render_validation_errors(@project) } + end end end diff --git a/app/models/project.rb b/app/models/project.rb index d6283e44f..1a2c0504d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -758,6 +758,7 @@ class Project < ActiveRecord::Base 'tracker_ids', 'issue_custom_field_ids', 'project_type', + 'dts_test', 'attachmenttype' From 9c9778d433e840e1a3b01143e28de0ed0030475b Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 09:23:40 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E2=80=9C?= =?UTF-8?q?=E8=B5=84=E6=96=99=E4=B8=8B=E8=BD=BD=E2=80=9D=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E2=80=9C=E4=BD=9C=E5=93=81=E4=B8=8B=E8=BD=BD=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index bb4c445e8..73629d72b 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -498,7 +498,7 @@ zh: project_module_time_tracking: 时间跟踪 project_module_news: 新闻 project_module_documents: 文档 - project_module_files: 资料下载 + project_module_files: 作品下载 project_module_wiki: Wiki project_module_repository: 版本库 project_module_boards: 讨论区 From ef62fc1fac5ded629c02c81dd709fd59f2b7090e Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 09:46:19 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BC=BA=E9=99=B7=E7=BC=96=E5=8F=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/auto_completes/issues.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/auto_completes/issues.html.erb b/app/views/auto_completes/issues.html.erb index b097eaff4..1df31e41b 100644 --- a/app/views/auto_completes/issues.html.erb +++ b/app/views/auto_completes/issues.html.erb @@ -1,6 +1,6 @@ <%= raw @issues.map {|issue| { 'id' => issue.id, - 'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}", + 'label' => "#{issue.tracker} ##{issue.project_index}: #{truncate issue.subject.to_s, :length => 60}", 'value' => issue.id } }.to_json From 8871652e0165e859a3a9781843bf701baaf59d50 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 28 Jul 2014 10:37:22 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=EF=BC=8C=E8=AE=BE=E7=BD=AE=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA"=E6=88=91=E7=9A=84=E8=AF=BE=E7=A8=8B"?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 1 + app/controllers/welcome_controller.rb | 1 + app/views/admin/first_page_made.html.erb | 24 +++++++++++-------- app/views/layouts/_base_header.html.erb | 4 ++++ config/locales/zh.yml | 1 + .../20140728014933_first_page_add_column.rb | 5 ++++ db/schema.rb | 23 +++++++++--------- 7 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20140728014933_first_page_add_column.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 36b7e8598..c4a03adcf 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -153,6 +153,7 @@ class AdminController < ApplicationController @first_page.image_width = params[:image_width] @first_page.image_height = params[:image_height] @first_page.sort_type = params[:sort_type] + @first_page.show_course = params[:show_course] if @first_page.save respond_to do |format| flash[:notice] = l(:notice_successful_update) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 0cca7be6e..236665b7f 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -24,6 +24,7 @@ class WelcomeController < ApplicationController def index @first_page = FirstPage.where("page_type = 'project'").first + @show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"grade desc") else diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index b83e54db1..601b2b8d8 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -27,24 +27,28 @@ <%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>

-

- - - <%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> - <%= wikitoolbar_for 'first_page_description' %> -

+ + +

-

+

+ + + <%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'first_page_description' %> +

+ <%= submit_tag l(:button_save), :class => "small", :name => nil %> <% end %> diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 17f0d1e60..98e14c00a 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -40,8 +40,10 @@
  • <%=link_to_user(User.current)%>