From 560ee0a2fcdf1bfde4c4967613cb6bbe58e85e96 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 25 Jul 2014 15:24:55 +0800 Subject: [PATCH 01/49] =?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 4fae105b9698f6e6e56ece56ede5abd1def9e7b6 Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 25 Jul 2014 17:42:38 +0800 Subject: [PATCH 02/49] project testing. --- app/views/projects/new.html.erb | 35 ++---- test/fixtures/journals_for_messages.yml | 122 ++++++++++++++++++++ test/fixtures/projects.yml | 45 ++++++-- test/functional/projects_controller_test.rb | 95 +++++++++++++++ 4 files changed, 261 insertions(+), 36 deletions(-) create mode 100644 test/fixtures/journals_for_messages.yml create mode 100644 test/functional/projects_controller_test.rb diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb index 0b76a7f44..184a67e3d 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/projects/new.html.erb @@ -1,28 +1,15 @@ <% @nav_dispaly_project_label = 1 @nav_dispaly_forum_label = 1 %> + <%= labelled_form_for @project do |f| %> - - <% if @course_tag == '1' %> -

<%=l(:label_course_new)%>

-
- - <%= render :partial => 'course_form', :locals => { :f => f } %> - - <%= submit_tag l(:button_create), :class => "enterprise"%> - -
- - <% else %> -

<%=l(:label_project_new)%>

-
-

<%=raw l(:label_project_new_description)%>

- <%= render :partial => 'form', :locals => { :f => f } %> - - <%= submit_tag l(:button_create), :class => "enterprise"%> - -
- - <% end %> - <%= javascript_tag "$('#project_name').focus();" %> +

<%=l(:label_project_new)%>

+
+

<%=raw l(:label_project_new_description)%>

+ <%= render :partial => 'form', :locals => { :f => f } %> + + <%= submit_tag l(:button_create), :class => "enterprise"%> + +
+ <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %> + <%= javascript_tag "$('#project_name').focus();" %> <% end %> - diff --git a/test/fixtures/journals_for_messages.yml b/test/fixtures/journals_for_messages.yml new file mode 100644 index 000000000..d0fc66d84 --- /dev/null +++ b/test/fixtures/journals_for_messages.yml @@ -0,0 +1,122 @@ +jfm_001: + id: 45 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: 我觉得这个系统挺实用,界面挺简洁美观! + status: + reply_id: 0 + created_on: 2013-08-16 15:27:2 + updated_on: 2013-08-16 15:27:2 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_048: + id: 48 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: aqfbLT wcqmhgdpgfvy, [url=http://flyhqtjjtskb.com/]flyhqtjjtskb[/url], + [link=http://idlilqzxissn.com/]idlilqzxissn[/link], http://sfeezearevbp.com/ + status: + reply_id: 0 + created_on: 2013-08-18 20:44:18 + updated_on: 2013-08-18 20:44:18 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_049: + id: 49 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: 搜索用户时,若无对应结果,没有返回提示信息,比如不会提示:暂无此人 + status: + reply_id: 0 + created_on: 2013-08-19 08:45:27 + updated_on: 2013-08-19 08:45:27 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_058: + id: 58 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: 问题板块中 “新建问题”能不能移动到靠右~ + status: + reply_id: 0 + created_on: 2013-08-20 00:24:44 + updated_on: 2013-08-20 00:24:44 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_060: + id: 60 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: something very nice + status: + reply_id: 0 + created_on: 2013-08-21 07:04:43 + updated_on: 2013-08-21 07:04:43 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_086: + id: 86 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: 谢谢大家的反馈! + status: + reply_id: 0 + created_on: 2013-08-23 02:36:48 + updated_on: 2013-08-23 02:36:48 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_087: + id: 87 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: ”与我相关“处不可以直接回复 + status: + reply_id: 0 + created_on: 2013-08-23 02:44:56 + updated_on: 2013-08-23 02:44:56 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_088: + id: 88 + jour_id: 2 + jour_type: Project + user_id: 2 + notes: 任何有关回复的地方可在任意显示处回复 + status: + reply_id: 0 + created_on: 2013-08-23 02:45:45 + updated_on: 2013-08-23 02:45:45 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: + diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml index 0105f9356..c979498fb 100644 --- a/test/fixtures/projects.yml +++ b/test/fixtures/projects.yml @@ -11,18 +11,18 @@ projects_001: parent_id: lft: 1 rgt: 10 -projects_002: - created_on: 2006-07-19 19:14:19 +02:00 - name: OnlineStore - updated_on: 2006-07-19 19:14:19 +02:00 - id: 2 - description: E-commerce web site - homepage: "" - is_public: false - identifier: onlinestore - parent_id: - lft: 11 - rgt: 12 +#projects_002: +# created_on: 2006-07-19 19:14:19 +02:00 +# name: OnlineStore +# updated_on: 2006-07-19 19:14:19 +02:00 +# id: 2 +# description: E-commerce web site +# homepage: "" +# is_public: false +# identifier: onlinestore +# parent_id: +# lft: 11 +# rgt: 12 projects_003: created_on: 2006-07-19 19:15:21 +02:00 name: eCookbook Subproject 1 @@ -71,3 +71,24 @@ projects_006: parent_id: 5 lft: 3 rgt: 4 +trustie: + id: 2 + name: SocialForge + description: "SocialForge是TrustieForge的升级版,支持社交化协同开发与合作。 SocialForge aims to provide a socialized and crowd sourcing enabled collaboration development platform. It is combining and will combine TrustieForge, Influx, Redmine and other open source projects." + homepage: http://forge.trustie.net + is_public: true + parent_id: + created_on: 2013-06-25 06:02:19.000000000 Z + updated_on: 2013-11-13 12:52:42.000000000 Z + identifier: trustie + status: 1 + lft: 11 + rgt: 12 +# lft: 115 +# rgt: 116 + project_type: 0 + hidden_repo: true + attachmenttype: 1 + user_id: + dts_test: 0 + diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb new file mode 100644 index 000000000..412165620 --- /dev/null +++ b/test/functional/projects_controller_test.rb @@ -0,0 +1,95 @@ +require File.expand_path('../../test_helper', __FILE__) + +class ProjectsControllerTest < ActionController::TestCase + fixtures :projects, + :issues, + :issue_statuses, + :enumerations, + :users, + :issue_categories, + :trackers, + :projects_trackers, + :roles, + :member_roles, + :members, + :enabled_modules, + :journals, + :journal_details, + :journals_for_messages + + def setup + @request.session[:user_id] = nil + @request.session[:ctime] = Time.now + @request.session[:atime] = Time.now + Setting.default_language = 'en' + end + + test 'get :index' do + get :index + assert_response :success + end + test ':new by admin should accept get' do + @request.session[:user_id] = 1 + get :new + assert_response :success + end + test ':new by non-admin user with add_project permission should accept get' do + Role.non_member.add_permission! :add_project + @request.session[:user_id] = 9 + get :new + assert_response :success + assert_template 'new' + end + + test ':create by admin user should create a new project' do + @request.session[:user_id] = 1 + post :create, :project => { + name: "blog1", + description: 'weblog', + homepage: 'http://weblog', + identifier: 'blog', + is_public: 1, + custom_field_values: {'3' => 'Beta'}, + tracker_ids: ['1', '3'], + :issue_custom_field_ids => ['9'], + :enabled_module_names => ['issue_tracking', 'news', 'repository'] + } + project = Project.find_by_name(blog) + assert_not_nil project + assert_redirected_to "/projects/#{project.id}/settings" + + assert_kind_of Project, project + assert project.active? + assert_equal 'weblog', project.description + assert_equal 'http://weblog', project.homepage + assert_equal true, project.is_public? + assert_nil project.parent + assert_equal 'Beta', project.custom_value_for(3).value + assert_equal [1, 3], project.trackers.map(&:id).sort + assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort + assert project.issue_custom_fields.include?(IssueCustomField.find(9)) + end + + test 'get :show trustie' do + get :show, {id: 2} + assert_response :success + end + + test 'get :search, forge' do + query_condition = "forge" + get :search, {'name' => query_condition } + projects = assigns(:projects_all) + assert projects.any?, "projects should have anything." + projects.each do |project| + assert project.name.downcase.include?(query_condition), "project name is invalid: #{project.name}" + end + end + + test 'get :feedback' do + get :feedback, {id: 2} + assert_response :success + # prject_id = 2 总有8个留言 + assert_equal assigns(:jour).count, 8 + end + +end From 00cf448bda7be4f58b0313aa2b3e03f0b1558820 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 09:18:24 +0800 Subject: [PATCH 03/49] =?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 04/49] 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 + 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 - @course.destroy - 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 - 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 - else - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - 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 05/49] =?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 06/49] =?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 cc215e6c7b094b1d39f0b4815ee197006a174d04 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 28 Jul 2014 09:47:11 +0800 Subject: [PATCH 07/49] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/show.html.erb | 5 +++++ app/views/users/show.html.erb | 24 +++++++++++++++++++++--- db/schema.rb | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index db51eca1d..e299be182 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -25,6 +25,11 @@ <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
+
+
+ <%#= textilizable e.event_url,:description %> +
+
<%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 6270b5f50..e671f7617 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -252,17 +252,35 @@ <% if e.user == User.current %> - <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> + + <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> +   + + <%= l(:label_i_new_activity) %> +   + <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> <% else %> - <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> + + <%= link_to(h(e.user), user_path(e.user_id)) %> +   + + <%= l(:label_new_activity) %> +   + <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> <% end %> -

<%= textilizable(act.description) %>

+
+
+ <%= textilizable act, :description %> +
+
+ + diff --git a/db/schema.rb b/db/schema.rb index 2927e6fac..a6e36b1e2 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 => 20140725062302) do +ActiveRecord::Schema.define(:version => 20140725073357) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 8871652e0165e859a3a9781843bf701baaf59d50 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 28 Jul 2014 10:37:22 +0800 Subject: [PATCH 08/49] =?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 | 28 +++++++++++-------- 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, 40 insertions(+), 23 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' %>

-

- - -

+ <%= 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)%>
  • - <%= textilizable(project.short_description, :project => project) %> + <%= textilizable(project.short_description.strip, :project => project) %>

    From 74de064cca5bc69cace56578f83d45a95839eb9e Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 11:29:55 +0800 Subject: [PATCH 11/49] =?UTF-8?q?1.=E6=96=87=E4=BB=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=E4=BC=98=E5=8C=96=202.?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5=E9=99=84=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++++ app/views/attachments/_links.html.erb | 2 +- app/views/news/_course_show.html.erb | 2 +- lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 9 +++++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 026a12e9a..36dd61105 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -174,7 +174,9 @@ class AttachmentsController < ApplicationController respond_to do |format| # modify by nwb if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course) - if @course.nil? + if @attachment.container.is_a?(News) + format.html { redirect_to_referer_or news_path(@attachment.container) } + elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else format.html { redirect_to_referer_or course_path(@course) } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b6cd47924..77741e5e5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -68,6 +68,10 @@ module ApplicationHelper link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) end + def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference) + link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action]) + end + def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) end diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 52b090bd8..99ecab35d 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -15,7 +15,7 @@ :method => :delete, :class => 'delete', :title => l(:button_delete) %> - <% else %> + <% else %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 7b5d17e43..727c9eb7a 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -75,7 +75,7 @@ <%= format_time(comment.created_on) %> - <%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + <%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index b9e6174ae..9f85dc49f 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -48,8 +48,13 @@ module Redmine end def attachments_deletable?(user=User.current) - (respond_to?(:visible?) ? visible?(user) : true) && - user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) + if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:delete_permission], self.course) + else + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) + end end def saved_attachments From a4ecccc048f9fdec1239cf61379ccd8f025d2156 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 28 Jul 2014 13:53:39 +0800 Subject: [PATCH 12/49] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B4=B4=E5=90=A7?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E6=98=B5=E7=A7=B0=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=A2=AB=E6=8C=A4=E5=88=B0=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E4=BD=8D=E7=BD=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 7dd1e751d..f8c7f880d 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -166,10 +166,10 @@ <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> - 楼主: <%= link_to_user(topic.author) %> + 楼主: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %> - 最后回复:<%=link_to_user topic.last_reply.try(:author) %> + 最后回复:<% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %> 回复(<%= link_to topic.try(:replies_count), topic.event_url %>) From 2c79a51e48d2123762e92c95f3ffaabacb99b828 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 14:43:38 +0800 Subject: [PATCH 13/49] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E7=BC=96=E7=A0=81=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 36dd61105..0f29d6000 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -26,6 +26,7 @@ class AttachmentsController < ApplicationController accept_api_auth :show, :download, :upload require 'iconv' + def show respond_to do |format| format.html { @@ -41,6 +42,13 @@ class AttachmentsController < ApplicationController render :action => 'diff' elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte @content = File.new(@attachment.diskfile, "rb").read + # 编码为非 UTF-8先进行间接转码 + # 部分unicode编码不直接支持转为 UTF-8 + # modify by nwb + if @content.encoding.name != 'UTF-8' + @content = @content.force_encoding('GBK') + @content = @content.encode('UTF-8') + end render :action => 'file' else download From 18ddb8604b48dd40a9d39e4c699d02d22d530f94 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 28 Jul 2014 14:58:01 +0800 Subject: [PATCH 14/49] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=82=E8=B5=9B?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=90=8D=E7=A7=B0=E3=80=81=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 39 ++++--- .../contests/_new_softapplication.html.erb | 96 +++++++++++++++++ .../contests/show_attendingcontest.html.erb | 100 +----------------- config/locales/zh.yml | 1 + 4 files changed, 122 insertions(+), 114 deletions(-) create mode 100644 app/views/contests/_new_softapplication.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b6cd47924..dbc39f950 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -823,8 +823,11 @@ module ApplicationHelper def select_option_helper option tmp = Hash.new tmp={"" => ""} - option.each do |project| - tmp[project.name] = project.id + if option.nil? + else + option.each do |project| + tmp[project.name] = project.id + end end tmp end @@ -1168,25 +1171,27 @@ module ApplicationHelper objects = objects.first end # end - objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact - errors = objects.map {|o| o.errors.full_messages}.flatten - if errors.any? - html << "
      \n" - errors.each do |error| + if objects != nil + objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact + errors = objects.map {|o| o.errors.full_messages}.flatten + if errors.any? + html << "
        \n" + errors.each do |error| + ###by xianbo + if(error!=l(:label_repository_path_not_null)) + html << "
      • #{h error}
      • \n" + end + ###xianbo + end ###by xianbo - if(error!=l(:label_repository_path_not_null)) - html << "
      • #{h error}
      • \n" + unless params[:repository].nil? + if params[:repository][:upassword]=="" + html << "
      • "+ l(:label_password_not_null) +"
      • \n" + end end ###xianbo + html << "
      \n" end - ###by xianbo - unless params[:repository].nil? - if params[:repository][:upassword]=="" - html << "
    • "+ l(:label_password_not_null) +"
    • \n" - end - end - ###xianbo - html << "
    \n" end html.html_safe end diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb new file mode 100644 index 000000000..830bcd314 --- /dev/null +++ b/app/views/contests/_new_softapplication.html.erb @@ -0,0 +1,96 @@ +<%#= error_messages_for 'softapplication' %> +<%= form_for Softapplication.new, :url => softapplications_path do |f| %> +
    + <%= hidden_field_tag 'contest_id', @contest.id %> + + <%= l(:label_work_name) %> + * : + <%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %> + + +
    +
    +
    + + + <%= l(:label_running_platform) %> + * : + <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %> + + +
    +
    +
    + + + <%= l(:label_work_type) %> + * : + + + <%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %> + + <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %> + <%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + + + +
    +
    +
    + + + <%= l(:label_work_description) %> + * : + <%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %> + + +
    +
    +
    + + + <%= l(:label_softapplication_developers) %> + * : + <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %> + + +
    +
    +
    + + + <%= l(:label_work_deposit_project) %>: + <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %> + <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %> + +
    +
    +
    + +
    + + <%= l(:label_upload_softworkpacket_photo) %> + + <%#= render_flash_messages %> +

    + <%= render :partial => 'attachments/form' %> +

    + +

    + 1、<%= l(:label_upload_softapplication_packets_mustpacketed) %>
    +
    + 2、<%= l(:label_upload_softapplication_photo_condition) %> +

    + +
    +

    +
    + <%= submit_tag l(:button_create) %> + <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", + :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index f6b684e5f..415897492 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -88,7 +88,7 @@
    <%= l(:label_attending_contest) %>: - <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %> + <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').slideToggle();" %>
    <% else %> @@ -99,102 +99,8 @@ <% end %> -