修复版本库

This commit is contained in:
Administrator 2013-08-14 20:56:20 +08:00
parent a11b1676ff
commit 9b8c0f81b2
9 changed files with 63 additions and 31 deletions

View File

@ -99,6 +99,8 @@ class AccountController < ApplicationController
# User self-registration # User self-registration
def register 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] (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
if request.get? if request.get?
session[:auth_source_registration] = nil session[:auth_source_registration] = nil
@ -123,6 +125,15 @@ class AccountController < ApplicationController
@user.login = params[:user][:login] @user.login = params[:user][:login]
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? 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] @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 "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+params[:user][:login]+"-write \n "+
"</Limit> \n ' >>"+
@root_path+"htdocs/"+params[:user][:login]+"/.htaccess"
end end
case Setting.self_registration case Setting.self_registration

View File

@ -87,7 +87,9 @@ class MyController < ApplicationController
# Manage user's password # Manage user's password
def password def password
@root_path="/home/pdl/redmine-2.3.2-0/apache2/"
@user = User.current @user = User.current
@middle = "^"+@user.login.to_s+":"
unless @user.change_password_allowed? unless @user.change_password_allowed?
flash[:error] = l(:notice_can_t_change_password) flash[:error] = l(:notice_can_t_change_password)
redirect_to my_account_path redirect_to my_account_path
@ -96,6 +98,8 @@ class MyController < ApplicationController
if request.post? if request.post?
if @user.check_password?(params[:password]) if @user.check_password?(params[:password])
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @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 if @user.save
flash[:notice] = l(:notice_account_password_updated) flash[:notice] = l(:notice_account_password_updated)
redirect_to my_account_path redirect_to my_account_path

View File

@ -143,7 +143,9 @@ class ProjectsController < ApplicationController
unless User.current.admin? unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first 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]) m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
@project.members << m @project.members << m
@projec.project_infos << project
end end
respond_to do |format| respond_to do |format|
format.html { format.html {

View File

@ -73,12 +73,12 @@ class RepositoriesController < ApplicationController
def create def create
##xianbo ##xianbo
@root_path="/home/pdl/redmine-2.3.2-0/apache2/" @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 @project_path=@root_path+"htdocs/"+@repository_name
@upasswd=params[:repository][:upassword] @repository_tag=params[:repository][:url]
attrs = pickup_extra_info attrs = pickup_extra_info
if(params[:repository][:upassword]!="") if(!@repository_tag)
params[:repository][:password]=params[:repository][:upassword] # params[:repository][:password]=params[:repository][:upassword]
if(params[:repository_scm]=="Git") if(params[:repository_scm]=="Git")
params[:repository][:url]=@project_path params[:repository][:url]=@project_path
end end
@ -96,24 +96,16 @@ class RepositoriesController < ApplicationController
@repository.project = @project @repository.project = @project
if request.post? && @repository.save if request.post? && @repository.save
if(params[:repository][:upassword]&&params[:repository_scm]=="Git") if(!@repository_tag &&params[: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"
system "git init --bare "+@project_path system "git init --bare "+@project_path
system "mv "+@project_path+"/hooks/post-update{.sample,}" system "mv "+@project_path+"/hooks/post-update{.sample,}"
system "chmod a+x"+@project_path+"/hooks/post-update" system "chmod a+x"+@project_path+"/hooks/post-update"
system "cd "+@project_path+"/hooks/" system "cd "+@project_path+"/"
system "./post-update" system "git update-server-info"
system "echo -e 'Allow from all \n Order Deny,Allow \n "+ @repository.update_attributes(:login => User.current.login.to_s)
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+
"</Limit> \n ' >>"+
@project_path+"/.htaccess"
end end
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
else if(@upasswd) else if(!@repository_tag)
render :action => 'newrepo', :layout =>'base_projects' render :action => 'newrepo', :layout =>'base_projects'
else else
render :action => 'new', :layout =>'base_projects' render :action => 'new', :layout =>'base_projects'
@ -168,8 +160,13 @@ class RepositoriesController < ApplicationController
end end
def destroy 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? @repository.destroy if request.delete?
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
if(@repository.type=="Repository::Git")
system "rm -r "+@repository_name
end
end end
def show def show
@ -180,11 +177,12 @@ class RepositoriesController < ApplicationController
if request.xhr? if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true) @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else else
(show_error_not_found; return) unless @entries #Modified by young
# (show_error_not_found; return) unless @entries
@changesets = @repository.latest_changesets(@path, @rev) @changesets = @repository.latest_changesets(@path, @rev)
@properties = @repository.properties(@path, @rev) @properties = @repository.properties(@path, @rev)
@repositories = @project.repositories @repositories = @project.repositories
render :action => 'show' render :action => 'show', :layout => 'base_projects'
end end
end end
@ -196,6 +194,7 @@ class RepositoriesController < ApplicationController
@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
@properties = @repository.properties(@path, @rev) @properties = @repository.properties(@path, @rev)
@changeset = @repository.find_changeset_by_name(@rev) @changeset = @repository.find_changeset_by_name(@rev)
render :layout => 'base_projects'
end end
def revisions def revisions
@ -210,7 +209,7 @@ class RepositoriesController < ApplicationController
all all
respond_to do |format| 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)}") } format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
end end
end end
@ -339,9 +338,11 @@ class RepositoriesController < ApplicationController
@changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
@diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
end end
render :layout => 'base_projects'
end end
def stats def stats
render :layout => 'base_projects'
end end
def graph def graph
@ -431,7 +432,7 @@ class RepositoriesController < ApplicationController
graph = SVG::Graph::Bar.new( graph = SVG::Graph::Bar.new(
:height => 300, :height => 300,
:width => 800, :width => 600,
:fields => fields.reverse, :fields => fields.reverse,
:stack => :side, :stack => :side,
:scale_integers => true, :scale_integers => true,
@ -474,7 +475,7 @@ class RepositoriesController < ApplicationController
graph = SVG::Graph::BarHorizontal.new( graph = SVG::Graph::BarHorizontal.new(
:height => 400, :height => 400,
:width => 800, :width => 600,
:fields => fields, :fields => fields,
:stack => :side, :stack => :side,
:scale_integers => true, :scale_integers => true,

View File

@ -76,10 +76,16 @@
<!-- 在这里添加赞和踩--> <!-- 在这里添加赞和踩-->
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => issue,:show_flag => true,:user_id =>User.current.id}%> </span> <span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => issue,:show_flag => true,:user_id =>User.current.id}%> </span>
<% if issue.tracker.name == 'Bug' %> <% if issue.tracker_id == 1 %>
<%= image_tag("/images/task.png", :class => "img-tag-issues") %> <%= image_tag("/images/task.png", :class => "img-tag-issues") %>
<% end %> <% 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") %> <%= image_tag("/images/issues.png", :class => "img-tag-issues") %>
<% end %> <% end %>

View File

@ -1,5 +1,5 @@
<% project_path_cut = 40 %> <% project_path_cut = 40 %>
<% ip = "222.247.54.100" %><!--Added by tanxianbo For formatting project's path--> <% ip = "repository.trustie.net" %><!--Added by tanxianbo For formatting project's path-->
<% if @project.repositories.any? %> <% if @project.repositories.any? %>
<table class="list"> <table class="list">
<thead> <thead>
@ -21,7 +21,7 @@
<td align="center"><%= checked_image repository.is_default? %></td> <td align="center"><%= checked_image repository.is_default? %></td>
<td><%=h repository.scm_name %></td> <td><%=h repository.scm_name %></td>
<%if repository.scm_name=="Git"%> <%if repository.scm_name=="Git"%>
<td>http://<%= repository.identifier%>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %></td><!--Modified by tanxianbo--> <td>http://<%= repository.login.to_s %>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %></td><!--Modified by tanxianbo-->
<%else %> <%else %>
<td><%=h repository.url %></td> <td><%=h repository.url %></td>
<% end %> <% end %>
@ -29,10 +29,18 @@
<td class="buttons"> <td class="buttons">
<% if repository.scm_name=="Subversion"%> <% if repository.scm_name=="Subversion"%>
<%if User.current.allowed_to?(:manage_repository, @project) %> <%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(:button_edit), edit_repository_path(repository),
:class => 'icon icon-edit') %> -->
<%= link_to(l(:label_user_plural), committers_repository_path(repository), <%= link_to(l(:label_user_plural), committers_repository_path(repository),
:class => 'icon icon-user') %> :class => 'icon icon-user') %>
<%= link_to(l(:button_edit), edit_repository_path(repository),
:class => 'icon icon-edit') %>
<%= delete_link repository_path(repository) %> <%= delete_link repository_path(repository) %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -11,7 +11,7 @@
</p> </p>
<p><%= f.check_box :is_default, :label => :field_repository_is_default %></p> <p><%= f.check_box :is_default, :label => :field_repository_is_default %></p>
<p><%= f.text_field :identifier, :disabled => @repository.identifier_frozen? %> <p><%= f.text_field :identifier, :required => true, :disabled => @repository.identifier_frozen? %>
<% unless @repository.identifier_frozen? %> <% unless @repository.identifier_frozen? %>
<em class="info"><%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_repository_identifier_info).html_safe %></em> <em class="info"><%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_repository_identifier_info).html_safe %></em>
<% end %></p> <% end %></p>

View File

@ -28,7 +28,7 @@ border:none
<%= l(:text_repository_identifier_info).html_safe %></em> <%= l(:text_repository_identifier_info).html_safe %></em>
<% end %></p> <% end %></p>
<!-- <p><%= f.text_field :url, :size => 60, :required => true,:readonly=>true, :class=>'textbg'%></p> --> <!-- <p><%= f.text_field :url, :size => 60, :required => true,:readonly=>true, :class=>'textbg'%></p> -->
<p><%= f.password_field :upassword, :required =>true, :label=> :field_password %></p> <!-- <p><%= f.password_field :upassword, :required =>true, :label=> :field_password %></p> -->
</div> </div>
<p> <p>
<%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %>

View File

@ -1,4 +1,4 @@
<h3 style="padding-top: 40px;"><%= l(:label_statistics) %></h3> <h3><%= l(:label_statistics) %></h3>
<p> <p>
<%= 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")) %> <%= 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")) %>