diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 6b8c0366..8ef71924 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -15,6 +15,7 @@ class BidsController < ApplicationController
@bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
+
@offset ||= @bid_pages.reverse_offset
#@bids = @bids.offset(@offset).limit(@limit).all.reverse
unless @offset == 0
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index a2167bdf..2c6b92d0 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -76,6 +76,8 @@ class RepositoriesController < ApplicationController
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@project_path=@root_path+"htdocs/"+@repository_name
@repository_tag=params[:repository][:upassword]
+ @repo_name=User.current.login.to_s+"-"+params[:repository][:identifier]
+ @middle=User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"
attrs = pickup_extra_info
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
params[:repository][:url]=@project_path
@@ -91,23 +93,26 @@ class RepositoriesController < ApplicationController
@repository.project = @project
if request.post? && @repository.save
if(params[:repository_scm]=="Git")
- system "htpasswd -mb "+@root_path+"user.passwd "+User.current.login.to_s+" "+@repository_tag
- system "echo -e '\n"+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"+
- " "+User.current.login.to_s+"' >> "+@root_path+"group.passwd"
+ system "htpasswd -mb "+@root_path+" "+@repo_name+" "+@repository_tag
+ logger.info "htpasswd -mb "+@root_path+" "+@repo_name+" "+@repository_tag+create_passwd
+ system "echo -e '\n"+@repo_name+"-write:"+
+ " "+@repo_name+"' >> "+@root_path+"group.passwd"
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
system "git init --bare "+@project_path
system "mv "+@project_path+"/hooks/post-update{.sample,}"
system "chmod a+x "+@project_path+"/hooks/post-update"
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
" \n"+
- "Require group "+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write \n "+
+ "Require group "+@repo_name+"-write \n "+
" \n ' >> "+
- @root_path+"htdocs/"+ @repository_name+"/.htaccess"
-
- puts "before ======================================================================"
- puts system "cd "+@project_path+" ;git update-server-info"
- flag = system "cd "+@project_path+" ;git update-server-info"
- puts "after flag:#{flag} ======================================================================"
+ @root_path+"htdocs/"+ @repository_name+"/.htaccess"
+ system "cd "+@project_path+" ;git update-server-info"
+ # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
+ # else
+ # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
+ # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
+ # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
+ # end
@repository.update_attributes(:login => User.current.login.to_s)
end
redirect_to settings_project_path(@project, :tab => 'repositories')
@@ -170,11 +175,15 @@ class RepositoriesController < ApplicationController
@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")
- puts "before destroy system cmd ======================================="
- puts "rm -r "+@root_path+@repository_name
- flag = system "rm -r "+@root_path+"htdocs/"+@repository_name
- puts "after destroy system cmd :#{flag} ======================================="
+ if(@repository.type=="Repository::Git")
+ system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd"
+ system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd"
+ system "rm -r "+@root_path+"htdocs/"+@repository_name
+ # if(@sed_user&&@sed_group&&@remove)
+ # else
+ # logger.info "An error occured when destory the repository"+"delete form passwd: \n"+
+ # @sed_user+"delete from group"+@sed_group+"delete from file"+@remove
+ # end
end
end
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index ab05474f..ccfeccd6 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -7,6 +7,7 @@ class TagsController < ApplicationController
include UsersHelper
include BidsHelper
include ActsAsTaggableOn::TagsHelper
+ helper :projects
$selected_tags = Array.new
$related_tags = Array.new
@@ -21,23 +22,56 @@ class TagsController < ApplicationController
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
- @issues_results = get_issues_by_tag($selected_tags)
- @projects_results = get_projects_by_tag($selected_tags)
- @users_results = get_users_by_tag($selected_tags)
- @bids_results = get_bids_by_tag($selected_tags)
+ # 这里为了提高系统的响应速度 把搜索结果放到case中去了
+ @users_results = nil
+ @projects_results = nil
+ @issues_results = nil
+ @bids_results = nil
+ @obj_pages = nil
@obj_id = params[:obj_id]
@obj_flag = params[:object_flag]
+ @numbers = Setting.tags_show_search_results
case @obj_flag
when '1' then
+ @users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @users_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then
+ @projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @projects_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
+
when '3' then
+ @issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @issues_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
+ @bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @bids_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @bids_results = @bids_results.offset(@offset).limit(@limit).all
+
else
@obj = nil
end
@@ -83,4 +117,12 @@ class TagsController < ApplicationController
end
+ def for_pagination(results)
+ @offset, @limit = api_offset_and_limit({:limit => 2})
+ @project_count = results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ results = results.offset(@offset).limit(@limit).order('lft').all
+ end
+
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d268e100..e99ff4ee 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1311,6 +1311,9 @@ module ApplicationHelper
def show_watcher_profile(obj)
count = 0
html = ''
+ if User.watched_by(obj.id).count == 0
+ html << (content_tag "span", l(:label_no_current_watchers))
+ end
for user in User.watched_by(obj.id)
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
count = count + 1
@@ -1333,6 +1336,9 @@ module ApplicationHelper
def show_fans_picture(obj)
html = ''
count = 0
+ if obj.watcher_users.count == 0
+ html << (content_tag "span", l(:label_no_current_fans))
+ end
for user in obj.watcher_users
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
count = count + 1
diff --git a/app/models/user.rb b/app/models/user.rb
index e27c6a78..ae672b53 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -99,7 +99,9 @@ class User < Principal
acts_as_taggable
scope :by_join_date, order("created_at DESC")
############################# added by liuping 关注
- acts_as_watchable
+ acts_as_watchable
+ has_one :user_extensions
+ ## end
attr_accessor :password, :password_confirmation
attr_accessor :last_before_login_on
diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb
index f70cddad..47578e66 100644
--- a/app/models/user_extensions.rb
+++ b/app/models/user_extensions.rb
@@ -1,4 +1,5 @@
class UserExtensions < ActiveRecord::Base
+ belongs_to :user
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
#this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil,
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 9a75481a..2143dee6 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -5,8 +5,6 @@
<%= l(:label_my_account)%>
-
-
@@ -70,6 +68,15 @@
<%= render :partial => 'users/preferences' %>
+
+
+
+ <%= l(:label_user_extensions)%>
+
+
+ <%= render :partial => 'users/user_extensions' %>
+
+
<%= submit_tag l(:button_save) %>
<% end %>
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 4435727f..8f4852ef 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -25,7 +25,7 @@
diff --git a/app/views/tags/_related_tags.html.erb b/app/views/tags/_related_tags.html.erb
index 84fb0692..42b3c010 100644
--- a/app/views/tags/_related_tags.html.erb
+++ b/app/views/tags/_related_tags.html.erb
@@ -1,5 +1,5 @@
<% if related_tags %>
-
+
<% for rt in related_tags %>
<%= link_to image_tag("/images/sidebar/add.png"),:action => "add_tag",:remote => true,:tag => rt,:show_flag => show_flag %>
diff --git a/app/views/tags/_selected_tags.html.erb b/app/views/tags/_selected_tags.html.erb
index f3afa4d8..78f96374 100644
--- a/app/views/tags/_selected_tags.html.erb
+++ b/app/views/tags/_selected_tags.html.erb
@@ -1,5 +1,5 @@
<% if selected_tags %>
-
+
<% for sg in selected_tags %>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %>
diff --git a/app/views/tags/_show_bids.html.erb b/app/views/tags/_show_bids.html.erb
index fd46f87f..4e808829 100644
--- a/app/views/tags/_show_bids.html.erb
+++ b/app/views/tags/_show_bids.html.erb
@@ -10,4 +10,9 @@
<% end %>
<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tags/_show_issues.html.erb b/app/views/tags/_show_issues.html.erb
index e29edb30..32654e40 100644
--- a/app/views/tags/_show_issues.html.erb
+++ b/app/views/tags/_show_issues.html.erb
@@ -12,3 +12,8 @@
<% end %>
+
diff --git a/app/views/tags/_show_projects.html.erb b/app/views/tags/_show_projects.html.erb
index aa9f5874..7e706ddd 100644
--- a/app/views/tags/_show_projects.html.erb
+++ b/app/views/tags/_show_projects.html.erb
@@ -11,6 +11,10 @@
<% end %>
-
<% end %>
+
\ No newline at end of file
diff --git a/app/views/tags/_show_users.html.erb b/app/views/tags/_show_users.html.erb
index 7ce8328f..552b7b6b 100644
--- a/app/views/tags/_show_users.html.erb
+++ b/app/views/tags/_show_users.html.erb
@@ -11,4 +11,9 @@
<% end %>
<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb
index 8c2c3d90..123e9ef3 100644
--- a/app/views/tags/_tag.html.erb
+++ b/app/views/tags/_tag.html.erb
@@ -41,7 +41,7 @@
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show",
:complete => '$("#put-tag-form").hide();' do |f| %>
- <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => 25,:minlength=>1 %>
+ <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit "add"%>
diff --git a/app/views/tags/_tag_search_results.html.erb b/app/views/tags/_tag_search_results.html.erb
index 9e816af8..bb584c91 100644
--- a/app/views/tags/_tag_search_results.html.erb
+++ b/app/views/tags/_tag_search_results.html.erb
@@ -3,7 +3,7 @@
<% case %>
<% when show_flag == '1' %>
<%=l(:label_user)%>
- <%= render :partial => "show_users",:locals => {:users_results => users_results }%>
+ <%= render :partial => "show_users",:locals => {:users_results => users_results}%>
<% when show_flag == '2'%>
<%=l(:label_project)%>
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
@@ -12,7 +12,7 @@
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
<% when show_flag == '4'%>
<%= l(:label_requirement)%>
- <%= render :partial => "show_bids",:locals => {:bids_results => bids_results }%>
+ <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% else %>
<%= l(:label_tags_all_objects)%>
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb
index 4fabfcf0..8e65d92e 100644
--- a/app/views/tags/index.html.erb
+++ b/app/views/tags/index.html.erb
@@ -1,10 +1,11 @@
<% content_for :sidebar do %>
-
Selected Tags
+
Selected Tags
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
-
Related Tags
+
+
Related Tags
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
@@ -13,7 +14,7 @@
<% content_for :content do %>
Search Results
-