From 9b8c0f81b232890f05dafb3266baaa4edace1834 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 14 Aug 2013 20:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 11 +++++ app/controllers/my_controller.rb | 4 ++ app/controllers/projects_controller.rb | 2 + app/controllers/repositories_controller.rb | 45 ++++++++++--------- app/views/issues/_list.html.erb | 10 ++++- .../projects/settings/_repositories.html.erb | 16 +++++-- app/views/repositories/_form.html.erb | 2 +- app/views/repositories/_form_create.html.erb | 2 +- app/views/repositories/stats.html.erb | 2 +- 9 files changed, 63 insertions(+), 31 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 85276ca46..88c4f5ccf 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -99,6 +99,8 @@ class AccountController < ApplicationController # User self-registration def register + @root_path="/home/pdl/redmine-2.3.2-0/apache2/" + (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @@ -123,6 +125,15 @@ class AccountController < ApplicationController @user.login = params[:user][:login] unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] + system "htpasswd -mb "+@root_path+"user.passwd "+params[:user][:login]+" "+user_params[:password] + system "echo -e '\n"+params[:user][:login]+"-write:"+ + " "+user_params[:password]+"' >> "+@root_path+"group.passwd" + system "mkdir"+@root_path+"htdocs/"+params[:user][:login] + system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + " \n"+ + "Require group "+params[:user][:login]+"-write \n "+ + " \n ' >>"+ + @root_path+"htdocs/"+params[:user][:login]+"/.htaccess" end case Setting.self_registration diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index bda2f0dc2..2720e11f9 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -87,7 +87,9 @@ class MyController < ApplicationController # Manage user's password def password + @root_path="/home/pdl/redmine-2.3.2-0/apache2/" @user = User.current + @middle = "^"+@user.login.to_s+":" unless @user.change_password_allowed? flash[:error] = l(:notice_can_t_change_password) redirect_to my_account_path @@ -96,6 +98,8 @@ class MyController < ApplicationController if request.post? if @user.check_password?(params[:password]) @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] + system "sed -i /"+@middle+"/{d} "+@root_path+"user.passwd" + system "htpasswd -mb "+@root_path+"user.passwd "+@user.login.to_s+" "+params[:new_password] if @user.save flash[:notice] = l(:notice_account_password_updated) redirect_to my_account_path diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f749c641b..8084c756c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -143,7 +143,9 @@ class ProjectsController < ApplicationController 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) @project.members << m + @projec.project_infos << project end respond_to do |format| format.html { diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e22a761d8..d781d6fe0 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -73,12 +73,12 @@ class RepositoriesController < ApplicationController def create ##xianbo @root_path="/home/pdl/redmine-2.3.2-0/apache2/" - @repository_name=params[:project_id]+"/"+params[:repository][:identifier]+".git" + @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @upasswd=params[:repository][:upassword] + @repository_tag=params[:repository][:url] attrs = pickup_extra_info - if(params[:repository][:upassword]!="") - params[:repository][:password]=params[:repository][:upassword] + if(!@repository_tag) + # params[:repository][:password]=params[:repository][:upassword] if(params[:repository_scm]=="Git") params[:repository][:url]=@project_path end @@ -96,24 +96,16 @@ class RepositoriesController < ApplicationController @repository.project = @project if request.post? && @repository.save - if(params[:repository][:upassword]&¶ms[:repository_scm]=="Git") - system "htpasswd -mb "+@root_path+"user.passwd "+params[:repository][:identifier]+" "+@upasswd - system "echo -e '\n"+params[:project_id]+"-"+params[:repository][:identifier]+"-write:"+ - " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" + if(!@repository_tag &¶ms[:repository_scm]=="Git") system "git init --bare "+@project_path system "mv "+@project_path+"/hooks/post-update{.sample,}" system "chmod a+x"+@project_path+"/hooks/post-update" - system "cd "+@project_path+"/hooks/" - system "./post-update" - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+ - " \n ' >>"+ - @project_path+"/.htaccess" - + system "cd "+@project_path+"/" + system "git update-server-info" + @repository.update_attributes(:login => User.current.login.to_s) end redirect_to settings_project_path(@project, :tab => 'repositories') - else if(@upasswd) + else if(!@repository_tag) render :action => 'newrepo', :layout =>'base_projects' else render :action => 'new', :layout =>'base_projects' @@ -168,8 +160,13 @@ class RepositoriesController < ApplicationController end def destroy + @root_path="/home/pdl/redmine-2.3.2-0/apache2/" + @repository_name=User.current.login.to_s+"/"+@repository.identifier.to_s+".git" @repository.destroy if request.delete? redirect_to settings_project_path(@project, :tab => 'repositories') + if(@repository.type=="Repository::Git") + system "rm -r "+@repository_name + end end def show @@ -180,11 +177,12 @@ class RepositoriesController < ApplicationController if request.xhr? @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - (show_error_not_found; return) unless @entries + #Modified by young + # (show_error_not_found; return) unless @entries @changesets = @repository.latest_changesets(@path, @rev) @properties = @repository.properties(@path, @rev) @repositories = @project.repositories - render :action => 'show' + render :action => 'show', :layout => 'base_projects' end end @@ -196,6 +194,7 @@ class RepositoriesController < ApplicationController @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) + render :layout => 'base_projects' end def revisions @@ -210,7 +209,7 @@ class RepositoriesController < ApplicationController all respond_to do |format| - format.html { render :layout => false if request.xhr? } + format.html { render :layout => 'base_projects' } format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") } end end @@ -339,9 +338,11 @@ class RepositoriesController < ApplicationController @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) end + render :layout => 'base_projects' end def stats + render :layout => 'base_projects' end def graph @@ -431,7 +432,7 @@ class RepositoriesController < ApplicationController graph = SVG::Graph::Bar.new( :height => 300, - :width => 800, + :width => 600, :fields => fields.reverse, :stack => :side, :scale_integers => true, @@ -474,7 +475,7 @@ class RepositoriesController < ApplicationController graph = SVG::Graph::BarHorizontal.new( :height => 400, - :width => 800, + :width => 600, :fields => fields, :stack => :side, :scale_integers => true, diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index b4a28c59b..553043802 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -76,10 +76,16 @@ <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => issue,:show_flag => true,:user_id =>User.current.id}%> - <% if issue.tracker.name == 'Bug' %> + <% if issue.tracker_id == 1 %> <%= image_tag("/images/task.png", :class => "img-tag-issues") %> <% end %> - <% if issue.tracker.name == '任务'%> + <% if issue.tracker_id == 2 %> + <%= image_tag("/images/feature.png", :class => "img-tag-issues") %> + <% end %> + <% if issue.tracker_id == 3 %> + <%= image_tag("/images/support.png", :class => "img-tag-issues") %> + <% end %> + <% if issue.tracker_id == 4 %> <%= image_tag("/images/issues.png", :class => "img-tag-issues") %> <% end %> diff --git a/app/views/projects/settings/_repositories.html.erb b/app/views/projects/settings/_repositories.html.erb index 50dce4ce2..6610300b7 100644 --- a/app/views/projects/settings/_repositories.html.erb +++ b/app/views/projects/settings/_repositories.html.erb @@ -1,5 +1,5 @@ <% project_path_cut = 40 %> -<% ip = "222.247.54.100" %> +<% ip = "repository.trustie.net" %> <% if @project.repositories.any? %> @@ -21,7 +21,7 @@ <%if repository.scm_name=="Git"%> - + <%else %> <% end %> @@ -29,10 +29,18 @@
<%= checked_image repository.is_default? %> <%=h repository.scm_name %>http://<%= repository.identifier%>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %>http://<%= repository.login.to_s %>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %><%=h repository.url %> <% if repository.scm_name=="Subversion"%> <%if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:button_edit), edit_repository_path(repository), + :class => 'icon icon-edit') %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository), + :class => 'icon icon-user') %> + <%= delete_link repository_path(repository) %> + <% end %> + <% elsif repository.scm_name=="Git"%> + <%if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository), :class => 'icon icon-user') %> - <%= link_to(l(:button_edit), edit_repository_path(repository), - :class => 'icon icon-edit') %> <%= delete_link repository_path(repository) %> <% end %> <% end %> diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb index c05658707..7ecbb7ddb 100644 --- a/app/views/repositories/_form.html.erb +++ b/app/views/repositories/_form.html.erb @@ -11,7 +11,7 @@

<%= f.check_box :is_default, :label => :field_repository_is_default %>

-

<%= f.text_field :identifier, :disabled => @repository.identifier_frozen? %> +

<%= f.text_field :identifier, :required => true, :disabled => @repository.identifier_frozen? %> <% unless @repository.identifier_frozen? %> <%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_repository_identifier_info).html_safe %> <% end %>

diff --git a/app/views/repositories/_form_create.html.erb b/app/views/repositories/_form_create.html.erb index de6d15438..be3296704 100644 --- a/app/views/repositories/_form_create.html.erb +++ b/app/views/repositories/_form_create.html.erb @@ -28,7 +28,7 @@ border:none <%= l(:text_repository_identifier_info).html_safe %> <% end %>

-

<%= f.password_field :upassword, :required =>true, :label=> :field_password %>

+

<%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> diff --git a/app/views/repositories/stats.html.erb b/app/views/repositories/stats.html.erb index 50648f66f..8299af0f6 100644 --- a/app/views/repositories/stats.html.erb +++ b/app/views/repositories/stats.html.erb @@ -1,4 +1,4 @@ -

<%= l(:label_statistics) %>

+

<%= l(:label_statistics) %>

<%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %>