From 261c3fc3378b745b51168d86a9c70f3d1f53fec8 Mon Sep 17 00:00:00 2001
From: huangjingquan
Date: Thu, 12 Sep 2013 10:41:15 +0800
Subject: [PATCH] new version
---
Gemfile | 2 -
app/assets/javascripts/teachers.js | 2 +
app/assets/stylesheets/teachers.css | 4 +
app/controllers/account_controller.rb | 21 +-
app/controllers/bids_controller.rb | 145 ++++++--
app/controllers/courses_controller.rb | 39 ++
app/controllers/my_controller.rb | 34 ++
app/controllers/projects_controller.rb | 340 ++++++++++++++----
app/controllers/tags_controller.rb | 283 ++++++---------
app/controllers/teachers_controller.rb | 5 +
app/controllers/users_controller.rb | 176 ++++++++-
app/controllers/watchers_controller.rb | 61 +++-
app/controllers/words_controller.rb | 10 +-
app/helpers/application_helper.rb | 3 +-
app/helpers/bids_helper.rb | 17 +-
app/helpers/groups_helper.rb | 2 +-
app/helpers/issues_helper.rb | 2 +-
app/helpers/journals_helper.rb | 6 +-
app/helpers/members_helper.rb | 2 +-
app/helpers/projects_helper.rb | 35 +-
app/helpers/teachers_helper.rb | 2 +
app/helpers/users_helper.rb | 51 ++-
app/helpers/watchers_helper.rb | 14 +
app/models/bid.rb | 8 +-
app/models/changeset.rb | 5 +
app/models/course.rb | 11 +-
app/models/homework_for_course.rb | 8 +
app/models/project.rb | 18 +-
app/models/project_status.rb | 21 ++
app/models/students_for_course.rb | 10 +
app/models/teacher.rb | 13 +
app/models/user.rb | 34 +-
app/models/user_extensions.rb | 2 +-
app/models/user_status.rb | 20 ++
app/models/watcher.rb | 4 +
app/views/account/login.html.erb | 14 +-
app/views/account/register.html.erb | 9 +-
app/views/bids/_bid_show.html.erb | 22 +-
app/views/bids/_history.html.erb | 15 +-
app/views/bids/_project_list.html.erb | 12 +-
app/views/bids/index.html.erb | 15 +
app/views/bids/show.html.erb | 12 +-
app/views/files/index.html.erb | 2 +-
app/views/git_usage/ch_usage.html.erb | 70 +++-
app/views/git_usage/en_usage.html.erb | 71 +++-
app/views/issues/_history.html.erb | 4 +-
app/views/issues/index.html.erb | 2 +-
app/views/issues/update_form.js.erb | 2 +-
app/views/layouts/_base_header.html.erb | 11 +-
app/views/layouts/base_bids.html.erb | 6 +-
app/views/layouts/base_courses.html.erb | 43 ++-
app/views/layouts/base_projects.html.erb | 18 +-
app/views/layouts/base_users.html.erb | 24 +-
app/views/my/account.html.erb | 10 +-
app/views/news/index.html.erb | 6 +-
app/views/news/show.html.erb | 145 ++++----
app/views/projects/_course_form.html.erb | 3 +-
app/views/projects/_edit.html.erb | 2 +-
app/views/projects/_homework_form.html.erb | 36 ++
app/views/projects/_new_homework.html.erb | 81 +++++
app/views/projects/_new_join.html.erb | 16 +
app/views/projects/_new_respond.html.erb | 8 +
app/views/projects/_project.html.erb | 15 +-
app/views/projects/feedback.html.erb | 46 ++-
app/views/projects/homework.html.erb | 6 -
app/views/projects/index.html.erb | 18 +-
app/views/projects/new_homework.html.erb | 4 +-
app/views/projects/new_join.js.erb | 3 +
app/views/projects/project_respond.html.erb | 0
app/views/projects/search.html.erb | 67 ++++
app/views/projects/settings.html.erb | 2 +-
app/views/projects/show.html.erb | 6 +-
app/views/projects/show_new.html.erb | 7 +-
app/views/projects/watcherlist.html.erb | 33 ++
app/views/repositories/show.html.erb | 5 +-
app/views/settings/_display.html.erb | 2 +-
app/views/tags/_pagination.html.erb | 5 +
app/views/tags/_related_tags.html.erb | 10 +-
app/views/tags/_selected_tags.html.erb | 9 +-
app/views/tags/_show_bids.html.erb | 4 +-
app/views/tags/_sidebar_tags.html.erb | 10 +
app/views/tags/_tag_name.html.erb | 6 +-
app/views/tags/_tag_search_results.html.erb | 19 +-
app/views/tags/add_tag.js.erb | 7 +-
app/views/tags/delete_tag.js.erb | 4 +-
app/views/tags/index.html.erb | 37 +-
app/views/tags/show_all.html.erb | 2 +-
app/views/users/index.html.erb | 29 +-
app/views/users/info.html.erb | 6 +-
app/views/users/search.html.erb | 140 ++++++++
app/views/users/show.html.erb | 110 +++++-
app/views/users/user_fanslist.html.erb | 6 +-
app/views/users/user_newfeedback.html.erb | 2 +-
app/views/users/user_projects.html.erb | 6 +-
app/views/users/user_watchlist.html.erb | 4 +-
app/views/users/watch_bids.html.erb | 26 +-
app/views/versions/index.html.erb | 2 +-
app/views/watchers/_set_join.js.erb | 3 +
app/views/watchers/_set_watcher.js.erb | 3 -
app/views/welcome/index.html.erb | 24 +-
app/views/words/_message.html.erb | 6 +-
app/views/words/_new.html.erb | 16 +-
config/locales/en.yml | 151 ++++++--
config/locales/zh.yml | 127 ++++++-
config/routes.rb | 35 +-
.../20130823133435_create_project_statuses.rb | 9 +
.../20130823143552_create_user_statuses.rb | 11 +
.../20130828004955_stored_status_procedure.rb | 76 ++++
...130828080407_add_index_to_user_statuses.rb | 6 +
db/migrate/20130831080808_create_teachers.rb | 12 +
.../20130831080955_add_extra_to_teacher.rb | 5 +
.../20130906124330_add_location_to_course.rb | 5 +
...30910075221_create_homework_for_courses.rb | 8 +
...30911005626_create_students_for_courses.rb | 10 +
db/schema.rb | 20 +-
files/2013/09/130909091918_twurn.com_.png | Bin 0 -> 49880 bytes
files/2013/09/130909102300_twurn.com_.png | Bin 0 -> 49880 bytes
...02607_48a3823e1ee72a1a06a62cbdcb4a5cd0.txt | 7 +
lib/redmine.rb | 4 +-
public/500.html | 56 +--
public/images/avatars/Project/6408 | Bin 0 -> 2310 bytes
public/images/avatars/Project/6446 | Bin 0 -> 1336 bytes
public/images/logo.png | Bin 5983 -> 6624 bytes
public/images/twurn.com_.png | Bin 0 -> 57423 bytes
public/stylesheets/application.css | 267 +++++++++++---
.../stylesheets/application.css | 62 ++--
126 files changed, 2835 insertions(+), 815 deletions(-)
create mode 100644 app/assets/javascripts/teachers.js
create mode 100644 app/assets/stylesheets/teachers.css
create mode 100644 app/controllers/courses_controller.rb
create mode 100644 app/controllers/teachers_controller.rb
create mode 100644 app/helpers/teachers_helper.rb
create mode 100644 app/models/homework_for_course.rb
create mode 100644 app/models/project_status.rb
create mode 100644 app/models/students_for_course.rb
create mode 100644 app/models/teacher.rb
create mode 100644 app/models/user_status.rb
create mode 100644 app/views/projects/_homework_form.html.erb
create mode 100644 app/views/projects/_new_homework.html.erb
create mode 100644 app/views/projects/_new_join.html.erb
create mode 100644 app/views/projects/_new_respond.html.erb
create mode 100644 app/views/projects/new_join.js.erb
create mode 100644 app/views/projects/project_respond.html.erb
create mode 100644 app/views/projects/search.html.erb
create mode 100644 app/views/projects/watcherlist.html.erb
create mode 100644 app/views/tags/_pagination.html.erb
create mode 100644 app/views/tags/_sidebar_tags.html.erb
create mode 100644 app/views/users/search.html.erb
create mode 100644 app/views/watchers/_set_join.js.erb
create mode 100644 db/migrate/20130823133435_create_project_statuses.rb
create mode 100644 db/migrate/20130823143552_create_user_statuses.rb
create mode 100644 db/migrate/20130828004955_stored_status_procedure.rb
create mode 100644 db/migrate/20130828080407_add_index_to_user_statuses.rb
create mode 100644 db/migrate/20130831080808_create_teachers.rb
create mode 100644 db/migrate/20130831080955_add_extra_to_teacher.rb
create mode 100644 db/migrate/20130906124330_add_location_to_course.rb
create mode 100644 db/migrate/20130910075221_create_homework_for_courses.rb
create mode 100644 db/migrate/20130911005626_create_students_for_courses.rb
create mode 100644 files/2013/09/130909091918_twurn.com_.png
create mode 100644 files/2013/09/130909102300_twurn.com_.png
create mode 100644 files/2013/09/130909102607_48a3823e1ee72a1a06a62cbdcb4a5cd0.txt
create mode 100644 public/images/avatars/Project/6408
create mode 100644 public/images/avatars/Project/6446
create mode 100644 public/images/twurn.com_.png
diff --git a/Gemfile b/Gemfile
index 7309c6e99..dd19b4435 100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,8 +20,6 @@ group :openid do
end
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
-
-
platforms :jruby do
# jruby-openssl is bundled with JRuby 1.7.0
gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
diff --git a/app/assets/javascripts/teachers.js b/app/assets/javascripts/teachers.js
new file mode 100644
index 000000000..dee720fac
--- /dev/null
+++ b/app/assets/javascripts/teachers.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/app/assets/stylesheets/teachers.css b/app/assets/stylesheets/teachers.css
new file mode 100644
index 000000000..afad32db0
--- /dev/null
+++ b/app/assets/stylesheets/teachers.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index a273afe51..dc7036f6a 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -42,7 +42,7 @@ class AccountController < ApplicationController
redirect_to home_url
elsif request.post?
logout_user
- redirect_to signin_path
+ redirect_to home_url
end
# display the logout form
end
@@ -147,6 +147,13 @@ class AccountController < ApplicationController
else
register_manually_by_administrator(@user)
end
+
+ #added by bai
+ unless @user.id.nil?
+ UserExtensions.create(:identity => params[:identity].to_i, :user_id => @user.id)
+ end
+ #end
+
end
end
end
@@ -178,9 +185,11 @@ class AccountController < ApplicationController
def password_authentication
user = User.try_to_login(params[:username], params[:password])
-
+
if user.nil?
invalid_credentials
+ elsif user.status == 2
+ invalid_credentials_new
elsif user.new_record?
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
else
@@ -270,6 +279,11 @@ class AccountController < ApplicationController
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
flash.now[:error] = l(:notice_account_invalid_creditentials)
end
+
+ def invalid_credentials_new
+ logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
+ flash.now[:error] = l(:notice_account_invalid_creditentials_new)
+ end
# Register a user for email activation.
#
@@ -277,6 +291,7 @@ class AccountController < ApplicationController
def register_by_email_activation(user, &block)
token = Token.new(:user => user, :action => "register")
if user.save and token.save
+ UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
Mailer.register(token).deliver
flash[:notice] = l(:notice_account_register_done)
redirect_to signin_path
@@ -293,6 +308,7 @@ class AccountController < ApplicationController
user.activate
user.last_login_on = Time.now
if user.save
+ UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
self.logged_user = user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_path
@@ -306,6 +322,7 @@ class AccountController < ApplicationController
# Pass a block for behavior when a user fails to save
def register_manually_by_administrator(user, &block)
if user.save
+ UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0)
# Sends an email to the administrators
Mailer.account_activation_request(user).deliver
account_pending
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 43b24d1e0..b4127f151 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -15,15 +15,53 @@ 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
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ # unless @offset == 0
+ # @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ # else
+ # limit = @bid_count % @limit
+ # @bids = @bids.offset(@offset).limit(limit).all.reverse
+ # end
+ #added by nie
+ if params[:bid_sort_type].present?
+ case params[:bid_sort_type]
+ when '0'
+ unless @offset == 0
+ @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @bid_count % @limit
+ @bids = @bids.offset(@offset).limit(limit).all.reverse
+ end
+ @s_state = 0
+ when '1'
+ unless @offset == 0
+ @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @bid_count % @limit
+ @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+ end
+ @s_state = 1
+ when '2'
+ unless @offset == 0
+ @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @bid_count % @limit
+ @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ end
+ @s_state = 0
+ end
else
- limit = @bid_count % @limit
- @bids = @bids.offset(@offset).limit(limit).all.reverse
+ unless @offset == 0
+ @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @bid_count % @limit
+ @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
+ end
+ @s_state = 1
end
+ #end
# @limit = api_offset_and_limit({:limit => 5})
# @bids = Bid.visible
# @bids = @bids.like(params[:name]) if params[:name].present?
@@ -107,7 +145,7 @@ class BidsController < ApplicationController
if params[:bid_message][:message].size>0
if params[:reference_content]
- message = params[:reference_content] + params[:bid_message][:message]
+ message = params[:bid_message][:message] + "\n" + params[:reference_content]
else
message = params[:bid_message][:message]
end
@@ -138,8 +176,10 @@ class BidsController < ApplicationController
##删除留言
def destroy
- JournalsForMessage.delete_message(params[:object_id])
@user = @bid.author
+ if User.current.admin? || User.current.id == @user.id
+ JournalsForMessage.delete_message(params[:object_id])
+ end
@jours = @bid.journals_for_messages.reverse
@limit = 10
@feedback_count = @jours.count
@@ -185,39 +225,39 @@ class BidsController < ApplicationController
def new_bid
@bid = Bid.new
@bid.safe_attributes = params[:bid]
- # if params[:bid_title]
- # # if params[:bid_budget].to_s =~ /^(\d+)$|^(\d+).([0-9]{2})$/
- # unless params[:bid_reward_type] == "0"
- # if params[:bid_deadline].to_s =~ /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
- # bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description], params[:bid_reward_type].to_i)
- # unless bid.watched_by?(User.current)
- # if bid.add_watcher(User.current)
- # flash[:notice] = l(:label_bid_succeed)
- # end
- # end
- # else
- # flash[:error] = l(:label_wrong_date)
- # end
- # else
- # flash[:error] = "wrong"
- # end
- # # else
- # # flash[:error] = l(:label_wrong_budget)
- # # end
- # end
- # @limit = 5
- # @bid_count = Bid.count
- # @bid_pages = Paginator.new @bid_count, @limit, params['page']
- # @offset ||= @bid_pages.offset
- # @bids = Bid.offset(@offset).limit(@limit).all
- # respond_to do |format|
- # # format.html
- # format.html { redirect_to :back }
- # format.js
- # # format.api { render_api_ok }
- # end
+ # if params[:bid_title]
+ # # if params[:bid_budget].to_s =~ /^(\d+)$|^(\d+).([0-9]{2})$/
+ # unless params[:bid_reward_type] == "0"
+ # if params[:bid_deadline].to_s =~ /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
+ # bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description], params[:bid_reward_type].to_i)
+ # unless bid.watched_by?(User.current)
+ # if bid.add_watcher(User.current)
+ # flash[:notice] = l(:label_bid_succeed)
+ # end
+ # end
+ # else
+ # flash[:error] = l(:label_wrong_date)
+ # end
+ # else
+ # flash[:error] = "wrong"
+ # end
+ # # else
+ # # flash[:error] = l(:label_wrong_budget)
+ # # end
+ # end
+ # @limit = 5
+ # @bid_count = Bid.count
+ # @bid_pages = Paginator.new @bid_count, @limit, params['page']
+ # @offset ||= @bid_pages.offset
+ # @bids = Bid.offset(@offset).limit(@limit).all
+ # respond_to do |format|
+ # # format.html
+ # format.html { redirect_to :back }
+ # format.js
+ # # format.api { render_api_ok }
+ # end
end
-
+
def create_bid
@bid = Bid.new
@bid.name = params[:bid][:name]
@@ -239,6 +279,32 @@ class BidsController < ApplicationController
render :action => 'new_bid'
end
end
+
+ def create_homework
+ @bid = Bid.new
+ @bid.name = params[:bid][:name]
+ @bid.description = params[:bid][:description]
+ @bid.reward_type = 3
+ # @bid.budget = params[:bid][:budget]
+ @bid.deadline = params[:bid][:deadline]
+ @bid.budget = 0
+ @bid.author_id = User.current.id
+ @bid.commit = 0
+ # @bid.
+ if @bid.save
+ HomeworkForCourse.create(:project_id => params[:course_id], :bid_id => @bid.id)
+ unless @bid.watched_by?(User.current)
+ if @bid.add_watcher(User.current)
+ flash[:notice] = l(:label_bid_succeed)
+ end
+ end
+ redirect_to respond_path(@bid)
+ else
+ @bid.safe_attributes = params[:bid]
+ render :action => 'new_bid'
+ end
+
+ end
def more
@jour = @bid.journals_for_messages
@@ -251,6 +317,7 @@ class BidsController < ApplicationController
#format.api { render_api_ok }
end
end
+
def back
@jour = @bid.journals_for_messages
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
new file mode 100644
index 000000000..8011b238b
--- /dev/null
+++ b/app/controllers/courses_controller.rb
@@ -0,0 +1,39 @@
+class CourseController < ApplicationController
+
+ before_filter :require_login, :only => [:join, :unjoin]
+
+ def join
+ if User.current.logged?
+ course = Project.find(params[:object_id])
+ if params[:course_password] == '123'
+ members = []
+ members << Member.new(:role_ids => [5], :user_id => User.current.id)
+ course.members << members
+
+ StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
+ else
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+
+ def unjoin
+ if User.current.logged?
+
+ @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id)
+ @member.first.destroy
+
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
+ joined.each do |join|
+ join.delete
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 62a8e4a4e..d5a4834a4 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -50,12 +50,46 @@ class MyController < ApplicationController
def account
@user = User.current
@pref = @user.pref
+
+
+
+ # if @user.user_extensions.nil?
+ # se = UserExtebsions.new
+ # se.user_id = @user.id
+ # se.occupation = params[:occupation]
+ # se.save
+ # else
+ # # = @user.user_extensions
+ # end
+ # @occupation = UserExtensions.occupation
+ # @occupation.save
if request.post?
@user.safe_attributes = params[:user]
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
+
+ # # UserExtensions.create(:user_id => @user.id, :occupation => params[:occupation])
+ # else
+ # ue = @user.user_extensions
+ # ue.occupation = params[:occupation]
+ # ue.save
+ # end
+
+ # added by bai
+ if @user.UserExtensions.nil?
+ se = UserExtensions.new
+ se.user_id = @user.id
+ se.occupation = params[:occupation]
+ se.save
+ else
+ se = @user.user_extensions
+ se.occupation = params[:occupation]
+ se.save
+ end
+ # end
+
if @user.save
@user.pref.save
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ee98739e4..5908c5940 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -14,20 +14,24 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
class ProjectsController < ApplicationController
layout 'base_projects'# by young
menu_item :overview
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
- menu_item :homework, :only => :homework
+ menu_item l(:label_sort_by_time), :only => :index
+ menu_item l(:label_sort_by_active), :only => :index
+ menu_item l(:label_sort_by_influence), :only => :index
+ #by huang
+ # menu_item :files, :only => :files
+ # menu_tiem :news, :only => :news
- before_filter :find_project, :except => [ :index, :list, :new, :create, :copy, :statistics]
- before_filter :authorize, :except => [:new_homework, :homework, :statistics, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
+ before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join]
+ before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
before_filter :authorize_global, :only => [:new, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
#by young
- before_filter :member, :file
+ before_filter :member, :file, :statistics, :watcherlist
#
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
@@ -37,7 +41,7 @@ class ProjectsController < ApplicationController
controller.send :expire_action, :controller => 'welcome', :action => 'robots'
end
end
-
+
helper :bids
include BidsHelper
helper :sort
@@ -54,49 +58,138 @@ class ProjectsController < ApplicationController
helper :activities
helper :documents
helper :watchers
+ # helper :watcherlist
### added by william
include ActsAsTaggableOn::TagsHelper
-
-
+
+ # Lists visible projects
+ # def index
+ # respond_to do |format|
+ # format.html {
+ # scope = Project
+ # unless params[:closed]
+ # scope = scope.active
+ # end
+ # @projects = scope.visible.order('lft').all
+ # }
+ # format.api {
+ # @offset, @limit = api_offset_and_limit
+ # @project_count = Project.visible.count
+ # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
+ # }
+ # format.atom {
+ # projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
+ # render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
+ # }
+ # end
+ # end
+
def index
#Modified by nie
# @offset, @limit = api_offset_and_limit({:limit => 10})
# @project_count = Project.visible.count
# @project_pages = Paginator.new @project_count, @limit, params['page']
- # @offset ||= @project_pages.offset
+ # @offset ||= @project_pages.offset
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
-
+
@offset, @limit = api_offset_and_limit({:limit => 10})
- @projects = Project.visible
+ @projects_status = ProjectStatus.visible
+ # @projects.each do |project|
+ # @admin = project.users_by_role[Role.find(3)]
+ # unless @admin.nil?
+ # @admin.each do |user|
+ # ProjectInfo.create(:user_id => user.id, :project_id => project.id)
+ # end
+ #
+ # end
+ # end
# @projects.each do |project|
- # @admin = project.users_by_role[Role.find(3)]
- # unless @admin.nil?
- # @admin.each do |user|
- # ProjectInfo.create(:user_id => user.id, :project_id => project.id)
- # end
-#
- # end
+ # ProjectStatus.create(:changesets_count => project.changesets.count, :project_id => project.id, :watchers_count => project.watcher_users.count)
# end
- @projects = Project.visible.like(params[:name]) if params[:name].present?
- @project_count = @projects.count
+ #@projects_status = Project.visible.like(params[:name]) if params[:name].present?
+ @project_count = @projects_status.count
@project_pages = Paginator.new @project_count, @limit, params['page']
- @offset ||= @project_pages.offset
- @projects = @projects.offset(@offset).limit(@limit).order('created_on DESC').all
+
+ @offset ||= @project_pages.reverse_offset
+
+ #@projects = @projects.offset(@offset).limit(@limit).order('created_on DESC').all
+ if params[:project_sort_type].present?
+ case params[:project_sort_type]
+ when '0'
+ @offset ||= @project_pages.reverse_offset
+ unless @offset == 0
+ @projects_status = @projects_status.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @project_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @projects_status = @projects_status.offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 0
+ # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
+ # @projects = @projects[@offset, @limit]
+ when '1'
+ @offset ||= @project_pages.reverse_offset
+ unless @offset == 0
+ @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @project_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 1
+
+ #@projects = @projects[@offset, @limit]
+ when '2'
+ @offset ||= @project_pages.reverse_offset
+ unless @offset == 0
+ @projects_status = @projects_status.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @project_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @projects_status = @projects_status.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 2
+ end
+ else
+ @offset ||= @project_pages.reverse_offset
+ unless @offset == 0
+ @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @project_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 1
+ # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
+ # @projects = @projects[@offset, @limit]
+ end
+
+ @projects = []
+ @projects_status.each do |obj|
+ @projects << Project.find_by_id("#{obj.project_id}")
+ end
#end
- respond_to do |format|
+ respond_to do |format|
format.html {
- render :layout => 'base'
+ render :layout => 'base'
scope = Project
unless params[:closed]
- scope = scope.active
+ scope = scope.active
end
- @projects = scope.visible.offset(@offset).limit(@limit).order('created_on DESC').all
}
format.api {
-# @offset, @limit = api_offset_and_limit
-# @project_count = Project.visible.count
-# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
+ # @offset, @limit = api_offset_and_limit
+ # @project_count = Project.visible.count
+ # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
}
format.atom {
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
@@ -105,14 +198,48 @@ class ProjectsController < ApplicationController
end
end
+ def search
+
+ @projects = Project.visible
+ @projects = @projects.visible.like(params[:name]) if params[:name].present?
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @project_count = @projects.visible.count
+ @project_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @project_pages.offset
+ @projects = @projects.visible.offset(@offset).limit(@limit).all
+ respond_to do |format|
+ format.html {
+ render :layout => 'base'
+ scope = Project
+ unless params[:closed]
+ scope = scope.active
+ end
+ }
+ format.api {
+ # @offset, @limit = api_offset_and_limit
+ # @project_count = Project.visible.count
+ # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
+ }
+ format.atom {
+ projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
+ render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
+ }
+ end
+ end
+
+ # added by fq
+ def new_join
+ @course = Project.find(params[:object_id])
+ end
+
#Added by young
- def homework
+ def homework
@offset, @limit = api_offset_and_limit({:limit => 10})
- @bids = Bid.visible
+ @bids = @project.homeworks
@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
@@ -122,16 +249,15 @@ class ProjectsController < ApplicationController
@bids = @bids.offset(@offset).limit(limit).all.reverse
end
render :layout => 'base_courses'
- end
-
- def new_homework
+ end
+
+ def new_homework
@homework = Bid.new
- @homework.safe_attributes = params[:bid]
+ @homework.safe_attributes = params[:bid]
render :layout => 'base_courses'
- end
-#Ended by young
+ end
+ #Ended by young
-
def feedback
@jours = @project.journals_for_messages.reverse
@limit = 10
@@ -142,40 +268,80 @@ class ProjectsController < ApplicationController
@state = false
end
+ def project_respond
+
+ if params[:project_respond].size>0
+ jour = JournalsForMessage.find(params[:reference_id]) if params[:reference_id]
+ if jour
+ user = jour.user
+ text = jour.notes
+ else
+ user = User.current
+ text = []
+ end
+ # Replaces pre blocks with [...]
+ text = text.to_s.strip.gsub(%r{((.|\s)*?) }m, '[...]')
+ reference_content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
+ reference_content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
+ # reference_message = JournalForMessage.find(params[:reference_id])
+ message = params[:project_respond] + "\n" + reference_content
+
+
+ user.add_jour(User.current, message, user.id)
+ flash[:notice]=l(:label_projects_feedback_respond_success)
+ # if a_message.size > 5
+ # @message = a_message[-5, 5]
+ # else
+ # @message = a_message
+ # end
+ # @message_count = a_message.count
+ end
+
+ respond_to do |format|
+ format.html { redirect_to :back }
+ #format.api { render_api_ok }
+ end
+ # redirect_to project_feedback_path(@project)
+ end
+
def new
@course_tag = params[:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
- ##add by xianbo
+ ##add by huang
@course=Course.new
@course.safe_attributes = params[:course]
##end
- render :layout => 'base'
+ render :layout => 'base'
end
-
def create
- @course_tag = params[:project][:project_type]
- @course = Course.new
- @course.extra=params[:project][:identifier]
- @course.safe_attributes = params[:project][:course]
-
+ @course_tag = params[:project][:project_type]
+ if(@course_tag=="1")
+ @course = Course.new
+ @course.extra=params[:project][:identifier]
+ @course.safe_attributes = params[:project][:course]
+ @course.save
+ # project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id)
+ # project_status = ProjectStatus.create(:project_id => @project.id)
+ end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
- @course.save
- if validate_parent_id && @project.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)
- @project.members << m
- @project.project_infos << project
+ project_status = ProjectStatus.create(:project_id => @project.id)
+ @project.members << m
+ @project.project_infos << project
end
respond_to do |format|
format.html {
@@ -227,21 +393,23 @@ class ProjectsController < ApplicationController
end
end
rescue ActiveRecord::RecordNotFound
- # source_project not found
+ # source_project not found
render_404
- end
+ end
# Show @project
def show
# try to redirect to the requested menu item
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
- return
+ return
end
@users_by_role = @project.users_by_role
@subprojects = @project.children.visible.all
@news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all
@trackers = @project.rolled_up_trackers
+ @user = User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id)
+
cond = @project.project_condition(Setting.display_subprojects_issues?)
@open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker)
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
@@ -251,13 +419,13 @@ class ProjectsController < ApplicationController
end
@key = User.current.rss_key
- #新增内容
+ #新增内容
@days = Setting.activity_days_default.to_i
if params[:from]
begin; @date_to = params[:from].to_date + 1; rescue; end
end
-
+
has = {
"show_issues" => true,
"show_files" => true,
@@ -268,24 +436,24 @@ class ProjectsController < ApplicationController
@date_from = @date_to - @days
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
-# 决定显示所用用户或单个用户活动
+ # 决定显示所用用户或单个用户活动
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
:with_subprojects => @with_subprojects,
:author => @author)
@activity.scope_select {|t| !has["show_#{t}"].nil?}
- # @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
+ # @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
#Added by young
events = @activity.events(@date_from, @date_to)
-
+
@offset, @limit = api_offset_and_limit({:limit => 10})
@events_count = events.count
@events_pages = Paginator.new @events_count, @limit, params['page']
- @offset ||= @events_pages.offset
+ @offset ||= @events_pages.offset
events = events.slice(@offset,@limit)
#Ended by young
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
- # documents
- @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
+ # documents
+ @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
documents = @project.documents.includes(:attachments, :category).all
case @sort_by
when 'date'
@@ -295,17 +463,16 @@ class ProjectsController < ApplicationController
when 'author'
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
else
- @grouped = documents.group_by(&:category)
+ @grouped = documents.group_by(&:category)
end
@document = @project.documents.build
-#
+ #
@base_courses_tag = @project.project_type
respond_to do |format|
- format.html{render :layout => 'base_courses' if @base_courses_tag }
+ format.html{render :layout => 'base_courses' if @base_courses_tag==1}
format.api
end
end
-
def settings
@issue_custom_fields = IssueCustomField.sorted.all
@@ -314,30 +481,37 @@ class ProjectsController < ApplicationController
@trackers = Tracker.sorted.all
@wiki ||= @project.wiki
#Added by young
- @course_tag = params[:course]
- if @course_tag == '1'
+ # @course_tag = params[:course]
+ # if @course_tag == '1'
+ if @project.project_type
render :layout => 'base_courses'
end
- #Ended by young
+ #Ended by young
end
def edit
end
-
+
#by young
def member
end
-
-
+
def file
+ # @course_tag = params[:course]
+ # if @course_tag == '1'
+ # render :layout => 'base_courses'
+ # end
+
+ # User.current
+ end
+
+ def statistics
+
end
-
#end
def update
@project.safe_attributes = params[:project]
- @Course.safe_attributes=params[:project][:course]
- @Course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
respond_to do |format|
@@ -397,9 +571,9 @@ class ProjectsController < ApplicationController
format.html { redirect_to admin_projects_path }
format.api { render_api_ok }
end
- else
- render :layout => "base"
- end
+ else
+ render :layout => "base"
+ end
# hide project in layout
@project = nil
end
@@ -415,9 +589,17 @@ class ProjectsController < ApplicationController
parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
unless @project.allowed_parents.include?(parent)
@project.errors.add :parent_id, :invalid
- return false
+ return false
end
end
true
end
+
+ # added by huang
+
+ def watcherlist
+ if @watched
+ @users -= watched.watcher_users
+ end
+ end
end
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index a7c787746..e99d2500c 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -9,222 +9,106 @@ class TagsController < ApplicationController
include BidsHelper
include ActsAsTaggableOn::TagsHelper
helper :projects
-
+
before_filter :require_admin,:only => [:delete,:show_all]
- $selected_tags = Array.new
- $related_tags = Array.new
+ # $selected_tags = Array.new
+ # $related_tags = Array.new
+ NUMBERS = Setting.tags_show_search_results
- def index
- $selected_tags = []
- $related_tags = []
- $selected_tags << params[:q]
-
- @issues_tags_num = Issue.tag_counts.size
- @projects_tags_num = Project.tag_counts.size
- @users_tags_num = User.tag_counts.size
- @bids_tags_num = Bid.tag_counts.size
-
- # 这里为了提高系统的响应速度 把搜索结果放到case中去了
- @users_results = nil
- @projects_results = nil
- @issues_results = nil
- @bids_results = nil
- @obj_pages = nil
-
+ # 接收参数解释:
+ # params[:q]这是在其他页面点击tag,跳转到该页面后的结果显示 ;params[:selected_tags],这是在过滤页面增删tag进行过滤传过来的参数
+ # 最后是2个过滤何种数据,显示结果的控制参数params[:obj_id],params[:object_falg]
+ # 0代表删除tag 1代表增加tag
+ def index
+
@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
-
+
+ @selected_tags = Array.new
+ @related_tags = nil
+
+ if params[:q]
+ @selected_tags << params[:q]
else
- @obj = nil
+ @do_what = params[:do_what]
+ @tag = params[:tag]
+ @selected_tags = params[:current_selected_tags]
+ @selected_tags = @selected_tags.nil? ? Array.new : @selected_tags
+
+ case @do_what
+ when '0' then
+ @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop
+ when '1' then
+ # 判断是否已存在该tag 主要用来处理分页的情况
+ unless @selected_tags.include? @tag
+ @selected_tags << @tag
+ end
+ end
end
+
+ @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num = get_tags_size
+
+ # 获取搜索结果
+ @obj,@obj_pages,@results_count,@users_results,
+ @projects_results,
+ @issues_results,
+ @bids_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
+ # 这里是做tag推荐用的, 用来生产推荐的tags
unless @obj.nil?
@tags = @obj.tag_list
- $selected_tags.each do |i|
+ @selected_tags.each do |i|
@tags.delete(i)
- end
- $related_tags = @tags
+ end
+ @related_tags = @tags
else
- return
+ return
end
end
-
+
+ # 增加已选的tag
def add_tag
@tag = params[:tag]
@show_flag = params[:show_flag]
+
$selected_tags << @tag
$related_tags.delete(@tag)
- @obj_pages = nil
- @numbers = Setting.tags_show_search_results
-
- # @issues_results = get_issues_by_tag($selected_tags)
- # @projects_results = get_projects_by_tag($selected_tags)
- # @users_results = get_users_by_tag($selected_tags)
- case @show_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
+ # 获取搜索结果
+ @obj,@obj_pages,@users_results,
+ @projects_results,
+ @issues_results,
+ @bids_results = refresh_results(@obj_id,@show_flag)
end
+ # 删除已选tag
def delete_tag
@tag = params[:tag]
@show_flag = params[:show_flag]
+
$related_tags << @tag
$selected_tags.delete(@tag)
- @obj_pages = nil
- @numbers = Setting.tags_show_search_results
-
- # @issues_results = get_issues_by_tag($selected_tags)
- # @projects_results = get_projects_by_tag($selected_tags)
- # @users_results = get_users_by_tag($selected_tags)
- case @show_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
+ # 获取搜索结果
+ @obj,@obj_pages,@results_count,@users_results,
+ @projects_results,
+ @issues_results,
+ @bids_results = refresh_results(@obj_id,@show_flag)
- else
- @obj = nil
- end
- end
-
- def count(name)
end
def show_all
@tags = ActsAsTaggableOn::Tag.find(:all)
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
+ #完全从数据库删除tag
def delete
if params[:q]
@tag = ActsAsTaggableOn::Tag.find_by_id(params[:q])
- @tag.delete
-
+ @tag.delete
@taggings = ActsAsTaggableOn::Tagging.find_all_by_tag_id(@tag.id)
-
@taggings.each do |tagging|
tagging.delete
end
@@ -233,9 +117,52 @@ class TagsController < ApplicationController
end
private
+ # 这里用来刷新搜索结果的区域
+ # 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果
+ def refresh_results(obj_id,obj_flag,selected_tags)
+ @users_results = nil
+ @projects_results = nil
+ @issues_results = nil
+ @bids_results = nil
+ @obj_pages = nil
+ @obj = nil
+
+ # 这里为了提高系统的响应速度 把搜索结果放到case中去了
+ case obj_flag
+ when '1' then
+ @obj = User.find_by_id(obj_id)
+ @obj_pages,@users_results,@results_count = for_pagination(get_users_by_tag(selected_tags))
+ when '2' then
+ @obj = Project.find_by_id(obj_id)
+ @obj_pages,@projects_results,@results_count = for_pagination(get_projects_by_tag(selected_tags))
+ when '3' then
+ @obj = Issue.find_by_id(obj_id)
+ @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags))
+ when '4' then
+ @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
+ @obj = Bid.find_by_id(obj_id)
+ else
+ @obj = nil
+ end
+ return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results
+ end
- def tagged_on_object(object)
-
+ def for_pagination(results)
+ @offset, @limit = api_offset_and_limit({:limit => NUMBERS }) # 设置每页显示的个数
+ @results_count = results.count
+ @obj_pages = Paginator.new @results_count, @limit, params['page'] # 3个参数分别是:总数,每页显示数目,第几页
+ @offset ||= @obj_pages.offset
+ results = results.offset(@offset).limit(@limit).all # 这里默认设置为按时间排序
+ return @obj_pages,results, @results_count
+ end
+
+ #获取有某类对象的tag总数
+ def get_tags_size
+ @issues_tags_num = Issue.tag_counts.size
+ @projects_tags_num = Project.tag_counts.size
+ @users_tags_num = User.tag_counts.size
+ @bids_tags_num = Bid.tag_counts.size
+ return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num
end
end
diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb
new file mode 100644
index 000000000..b4d0c4839
--- /dev/null
+++ b/app/controllers/teachers_controller.rb
@@ -0,0 +1,5 @@
+class TeachersController < ApplicationController
+ def show
+
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 751d497ca..fa8879921 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -19,13 +19,13 @@ class UsersController < ApplicationController
#Added by young
menu_item :activity
menu_item :user_information, :only => :info
- menu_item :project, :only => :user_projects
+ menu_item :user_project, :only => :user_projects
menu_item :requirement_focus, :only => :watch_bids
menu_item :user_newfeedback, :only => :user_newfeedback
#Ended by young
- before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update]
+ before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update]
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
@@ -154,16 +154,125 @@ class UsersController < ApplicationController
"show_changesets" => true
}
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
-
- scope = User.logged.status(@status)
- scope = scope.like(params[:name]) if params[:name].present?
+
+ scope = UserStatus.visible
+
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
-
+ # scope.each do |user|
+ # UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
+ # end
@user_count = scope.count
@user_pages = Paginator.new @user_count, @limit, params['page']
- @offset ||= @user_pages.offset
- @users = scope.order(sort_clause).limit(@limit).offset(@offset).all
+ #@offset ||= @user_pages.offset
+ #@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
@user_base_tag = params[:id]?'base_users':'base'
+ if params[:user_sort_type].present?
+ case params[:user_sort_type]
+ when '0'
+ @offset ||= @user_pages.reverse_offset
+ unless @offset == 0
+ @users_statuses = scope.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @user_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @users_statuses = scope.offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 0
+ # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
+ # @projects = @projects[@offset, @limit]
+ when '1'
+ @offset ||= @user_pages.reverse_offset
+ unless @offset == 0
+ @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @user_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 1
+ #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
+ #@users = @users[@offset, @limit]
+ when '2'
+ @offset ||= @user_pages.reverse_offset
+ unless @offset == 0
+ @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @user_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 2
+ #@users = @users[@offset, @limit]
+ end
+
+ else
+ @offset ||= @user_pages.reverse_offset
+ unless @offset == 0
+ @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @user_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
+ end
+ @s_type = 1
+ # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
+ # @projects = @projects[@offset, @limit]
+ end
+
+ @users = []
+ @users_statuses.each do |obj|
+ @users << User.find_by_id("#{obj.user_id}")
+ end
+
+
+ respond_to do |format|
+ format.html {
+ @groups = Group.all.sort
+ render :layout => @user_base_tag
+ }
+ format.api
+ end
+ end
+
+ def search
+ sort_init 'login', 'asc'
+ sort_update %w(login firstname lastname mail admin created_on last_login_on)
+
+ case params[:format]
+ when 'xml', 'json'
+ @offset, @limit = api_offset_and_limit({:limit => 15})
+ else
+ @limit = 15#per_page_option
+ end
+
+ @status = params[:status] || 1
+ has = {
+ "show_changesets" => true
+ }
+ scope = User.logged.status(@status)
+ scope = scope.like(params[:name]) if params[:name].present?
+ @user_count = scope.count
+ @user_pages = Paginator.new @user_count, @limit, params['page']
+ @user_base_tag = params[:id]?'base_users':'base'
+ @offset ||= @user_pages.reverse_offset
+ unless @offset == 0
+ @users = scope.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @user_count % @limit
+ if limit == 0
+ limit = @limit
+ end
+ @users = scope.offset(@offset).limit(limit).all.reverse
+ end
+
respond_to do |format|
format.html {
@groups = Group.all.sort
@@ -172,6 +281,7 @@ class UsersController < ApplicationController
format.api
end
end
+
### modified by fq
def show
@@ -215,18 +325,48 @@ class UsersController < ApplicationController
# @activity_pages = Paginator.new @activity_count, @limit, params['page']
# @offset ||= @activity_pages.offset
# @events_by_day_ = @events.slice(@offset,@limit)
- if @user == User.current
+ case params[:type]
+ when "1"
+ if @user == User.current
+ activity = Activity.where('user_id = ?', User.current.id).order('id desc')
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @activity_count = activity.count
+ @activity_pages = Paginator.new @activity_count, @limit, params['page']
+ @offset ||= @activity_pages.offset
+ @activity = activity.offset(@offset).limit(@limit)
+ @state = 1
+ end
+ when "2"
+ message = []
+ if @user == User.current
+ message = JournalsForMessage.reference_message(@user.id)
+ message += Journal.reference_message(@user.id)
+ end
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @activity_count = message.size
+ @info_pages = Paginator.new @activity_count, @limit, params['page']
+ @offset ||= @info_pages.offset
+
+ messages = message.sort {|x,y| y.created_on <=> x.created_on }
+
+ @message = messages[@offset, @limit]
+ @state = 2
+ else
+ if @user == User.current
watcher = User.watched_by(@user)
watcher.push(User.current)
activity = Activity.where('user_id in (?)', watcher).order('id desc')
- else
+ else
activity = Activity.where('user_id = ?', @user.id).order('id desc')
+ end
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @activity_count = activity.count
+ @activity_pages = Paginator.new @activity_count, @limit, params['page']
+ @offset ||= @activity_pages.offset
+ @activity = activity.offset(@offset).limit(@limit)
+ @state = 0
end
- @offset, @limit = api_offset_and_limit({:limit => 10})
- @activity_count = activity.count
- @activity_pages = Paginator.new @activity_count, @limit, params['page']
- @offset ||= @activity_pages.offset
- @activity = activity.offset(@offset).limit(@limit)
+
#Modified by nie
unless User.current.admin?
@@ -249,10 +389,10 @@ class UsersController < ApplicationController
def info
message = []
- if @user == User.current
-
+ if @user == User.current
message = JournalsForMessage.reference_message(@user.id)
- message += Journal.reference_message(@user.id) end
+ message += Journal.reference_message(@user.id)
+ end
@offset, @limit = api_offset_and_limit({:limit => 10})
@info_count = message.size
@info_pages = Paginator.new @info_count, @limit, params['page']
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index fa212a682..b06b8cbb3 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -14,10 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
class WatchersController < ApplicationController
before_filter :require_login, :find_watchables, :only => [:watch, :unwatch]
-
def watch
set_watcher(@watchables, User.current, true)
end
@@ -25,6 +23,41 @@ class WatchersController < ApplicationController
def unwatch
set_watcher(@watchables, User.current, false)
end
+
+ def join
+ if User.current.logged?
+ course = Project.find(params[:object_id])
+ if params[:course_password] == '123'
+ members = []
+ members << Member.new(:role_ids => [5], :user_id => User.current.id)
+ course.members << members
+
+ StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
+ else
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+
+ def unjoin
+ if User.current.logged?
+
+ @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id)
+ @member.first.destroy
+
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
+ joined.each do |join|
+ join.delete
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
before_filter :find_project, :authorize, :only => [:new, :create, :append, :destroy, :autocomplete_for_user]
accept_api_auth :create, :destroy
@@ -86,7 +119,7 @@ class WatchersController < ApplicationController
end
rescue
render_404
- end
+ end
def find_watchables
klass = Object.const_get(params[:object_type].camelcase) rescue nil
@@ -100,7 +133,27 @@ class WatchersController < ApplicationController
def set_watcher(watchables, user, watching)
watchables.each do |watchable|
watchable.set_watcher(user, watching)
- @user = watchable # added by william
+ # @user = watchable # added by william
+ if watching
+ # 修改 user和project的状态
+ if watchable.instance_of?(User)
+ #写user_statuses表
+ UserStatus.find_by_user_id(watchable.id).update_watchers_count(1)
+ elsif watchable.instance_of?(Project)
+ #写project_statuese表
+ ProjectStatus.find_by_project_id(watchable.id).update_watchers_count(1)
+ end
+ else
+ # 修改 user和project的状态
+ if watchable.instance_of?(User)
+ #写user_statuses表
+ UserStatus.find_by_user_id(watchable.id).update_watchers_count(-1)
+ elsif watchable.instance_of?(Project)
+ #写project_statuese表 :project_status
+ ProjectStatus.find_by_project_id(watchable.id).update_watchers_count(-1)
+ end
+ end
+
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index ed14686b0..9a31927ce 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -6,7 +6,7 @@ class WordsController < ApplicationController
if params[:new_form][:user_message].size>0
unless params[:user_id].nil?
if params[:reference_content]
- message = params[:reference_content] + params[:new_form][:user_message]
+ message = params[:new_form][:user_message] + "\n" + params[:reference_content]
else
message = params[:new_form][:user_message]
end
@@ -37,7 +37,9 @@ class WordsController < ApplicationController
end
def destroy
- JournalsForMessage.delete_message(params[:object_id])
+ if User.current.admin? || User.current.id == @user.id
+ JournalsForMessage.delete_message(params[:object_id])
+ end
@jours = @user.journals_for_messages.reverse
@limit = 10
@feedback_count = @jours.count
@@ -71,6 +73,10 @@ class WordsController < ApplicationController
text = text.to_s.strip.gsub(%r{((.|\s)*?) }m, '[...]')
@content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
+
+ # @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
+ # @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
+
@id = user.id
rescue ActiveRecord::RecordNotFound
render_404
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e99ff4eee..5204788cf 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -219,7 +219,8 @@ module ApplicationHelper
if projects.any?
ancestors = []
original_project = @project
- projects.sort_by(&:lft).each do |project|
+ #modified by nie
+ projects.each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb
index 71f73ff39..89dbdd85f 100644
--- a/app/helpers/bids_helper.rb
+++ b/app/helpers/bids_helper.rb
@@ -34,7 +34,22 @@ module BidsHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_bids_by_tag(tag_name)
- Bid.tagged_with(tag_name)
+ Bid.tagged_with(tag_name).order('updated_on desc')
+ end
+
+ def sort_bid(state)
+ content = ''.html_safe
+ case state
+ when 0
+ content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1')))
+ content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0'), :class=>"selected"), :class=>"selected")
+
+ when 1
+ content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0')))
+ end
+ content = content_tag('ul', content)
+ content_tag('div', content, :class => "tabs")
end
end
\ No newline at end of file
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index aa58eb575..b0b507dd4 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -33,7 +33,7 @@ module GroupsHelper
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
- links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
+ links = pagination_links_full(principal_pages, principal_count, :per_page_links => false){|text, parameters, options|
link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
}
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 4ecc33690..f5847abbc 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -377,7 +377,7 @@ module IssuesHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_issues_by_tag(tag_name)
- Issue.tagged_with(tag_name)
+ Issue.tagged_with(tag_name).order('updated_on desc')
end
end
diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb
index 80bfd65b3..788bd0765 100644
--- a/app/helpers/journals_helper.rb
+++ b/app/helpers/journals_helper.rb
@@ -24,17 +24,17 @@ module JournalsHelper
destroyable = User.current.logged? && ((journal.user == User.current) || (issue.author_id == User.current.id) || (User.current.admin == 1))
links = []
if !journal.notes.blank?
- links << link_to(image_tag('comment.png'),
+ links << link_to(l(:button_quote),
{:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal},
:remote => true,
:method => 'post',
:title => l(:button_quote)) if options[:reply_links]
- links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
+ links << link_to_in_place_notes_editor(l(:button_edit), "journal-#{journal.id}-notes",
{ :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
:title => l(:button_edit)) if editable
#Added by young
if destroyable
- links << link_to(image_tag('delete.png'), { :controller => 'journals', :action => 'destroy', :id => journal, :format => 'js' },
+ links << link_to(l(:button_delete), { :controller => 'journals', :action => 'destroy', :id => journal, :format => 'js' },
:title => l(:button_delete))
end
end
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index aa6b9d436..915e02627 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -21,7 +21,7 @@ module MembersHelper
def render_principals_for_new_members(project)
scope = Principal.active.sorted.not_member_of(project).like(params[:q])
principal_count = scope.count
- principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']#by young
+ principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals')
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index cc7a29960..416f2d87c 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -29,7 +29,7 @@ module ProjectsHelper
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
- {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
+ # {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
@@ -38,17 +38,44 @@ module ProjectsHelper
end
+ def sort_project(state)
+ content = ''.html_safe
+ case state
+ when 0
+
+ content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1')))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2')))
+ content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'), :class=>"selected"), :class=>"selected")
+ when 1
+
+ content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2')))
+ content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0')))
+ when 2
+ content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1')))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0')))
+ end
+ content = content_tag('ul', content)
+ content_tag('div', content, :class => "tabs")
+ end
+
+
#Added by young
def course_settings_tabs
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'},
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
- {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}
+ # {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
+ {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
end
#Ended by young
+
+
+
def parent_project_select_tag(project)
selected = project.parent
# retrieve the requested parent project
@@ -67,7 +94,7 @@ module ProjectsHelper
def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project|
#Modified by young
- if project.project_type
+ if (project.project_type==1)
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")+"(#{l(:label_course)}) ".html_safe
else
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
@@ -103,7 +130,7 @@ module ProjectsHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_projects_by_tag(tag_name)
- Project.tagged_with(tag_name)
+ Project.tagged_with(tag_name).order('updated_on desc')
end
end
diff --git a/app/helpers/teachers_helper.rb b/app/helpers/teachers_helper.rb
new file mode 100644
index 000000000..1015c8c9f
--- /dev/null
+++ b/app/helpers/teachers_helper.rb
@@ -0,0 +1,2 @@
+module TeachersHelper
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 8a2ab765f..32c4b6142 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -58,9 +58,58 @@ module UsersHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_users_by_tag(tag_name)
- User.tagged_with(tag_name)
+ User.tagged_with(tag_name).order('updated_on desc')
end
# added by fq
+ #
+
+ def show_activity(state)
+ content = ''.html_safe
+ case state
+ when 0
+ s = content_tag('span', l(:label_user_all_activity), :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
+ content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
+ when 1
+ s = content_tag('span', l(:label_user_activity_myself), :class => "current-page")
+ content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
+ content << content_tag('li', s, :class => "current-page")
+ content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
+ when 2
+ s = content_tag('span', l(:label_user_all_respond), :class => "current-page")
+ content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
+ content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
+ content << content_tag('li', s, :class => "current-page")
+ end
+ content_tag('div', content, :class => "pagination")
+ end
+# added by huang
+def sort_user(state)
+ content = ''.html_safe
+ case state
+ when 0
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1')))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2')))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'), :class=>"selected"), :class=>"selected")
+ when 1
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2')))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0')))
+ when 2
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1')))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0')))
+ end
+ content = content_tag('ul', content)
+ content_tag('div', content, :class => "tabs")
+ end
+#end
end
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 052c3fd25..a97deaec2 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -45,6 +45,20 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method, :class => css
end
+
+ def join_in_course(course, user)
+ return '' unless user && user.logged?
+ joined = user.join_in?(course)
+ text = joined ? '退出课程' : '加入课程'
+ url_t = join_path(:object_id => course.id)
+ url_f = try_join_path(:object_id => course.id)
+ method = joined ? 'delete' : 'post'
+ if joined
+ link_to text, url_t, :remote => true, :method => method, :id => 'join', :confirm => l(:text_are_you_sure)
+ else
+ link_to text, url_f, :remote => true, :method => method, :id => 'join'
+ end
+ end
# Returns the css class used to identify watch links for a given +object+
def watcher_css(objects)
diff --git a/app/models/bid.rb b/app/models/bid.rb
index 25e7743f8..c79f8fd10 100644
--- a/app/models/bid.rb
+++ b/app/models/bid.rb
@@ -9,13 +9,15 @@ class Bid < ActiveRecord::Base
has_many :projects, :through => :biding_projects
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ has_many :homework_for_courses, :dependent => :destroy
+ has_many :courses, :through => :homework_for_courses, :source => :project
NAME_LENGTH_LIMIT = 60
DESCRIPTION_LENGTH_LIMIT = 250
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
- validates_presence_of :author_id, :name, :deadline, :budget
+ validates_presence_of :author_id, :name, :deadline
# validates_presence_of :deadline, :message => 'test'
# validates_format_of :deadline, :with =>
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
@@ -54,6 +56,10 @@ class Bid < ActiveRecord::Base
'description',
'budget',
'deadline'
+
+ # safe_attributes 'name',
+ # 'description',
+ # 'deadline'
def add_jour(user, notes, reference_user_id = 0)
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index b46f7a312..e3e7ac705 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -23,6 +23,11 @@ class Changeset < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# end
+ #Added by nie
+ has_one :project_status, :dependent => :destroy
+ has_one :users_status
+ #end
+
has_and_belongs_to_many :issues
has_and_belongs_to_many :parents,
:class_name => "Changeset",
diff --git a/app/models/course.rb b/app/models/course.rb
index 9f25f5c05..be335ec4f 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -1,15 +1,16 @@
class Course < ActiveRecord::Base
include Redmine::SafeAttributes
- attr_accessible :code, :extra, :name, :state, :tea_id, :time
- belongs_to :project, :class_name => 'Project', :foreign_key => :tea_id
+ attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location
+ belongs_to :project, :class_name => 'Project', :foreign_key => :extra
has_many :bid
- validates_presence_of :code, :time
+ validates_presence_of :code, :time, :location, :name
safe_attributes 'extra',
'time',
'name',
'extra',
- 'code'
-
+ 'code',
+ 'location'
+
end
diff --git a/app/models/homework_for_course.rb b/app/models/homework_for_course.rb
new file mode 100644
index 000000000..7a440449a
--- /dev/null
+++ b/app/models/homework_for_course.rb
@@ -0,0 +1,8 @@
+class HomeworkForCourse < ActiveRecord::Base
+ attr_accessible :bid_id, :project_id
+
+ belongs_to :bid
+ belongs_to :project
+
+
+end
diff --git a/app/models/project.rb b/app/models/project.rb
index 48ca45746..4e0e4549c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -53,13 +53,20 @@ class Project < ActiveRecord::Base
has_many :changesets, :through => :repository
# added by fq
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
+ has_many :homework_for_courses, :dependent => :destroy
+ has_many :homeworks, :through => :homework_for_courses, :source => :bid
+ has_many :students_for_courses, :dependent => :destroy
+ has_many :student, :through => :students_for_courses, :source => :user
+
# end
#ADDED BY NIE
- has_many :project_infos, :dependent => :destroy
+ has_many :project_infos, :dependent => :destroy
+ has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
#end
+
has_one :wiki, :dependent => :destroy
##added by xianbo
- has_one :course, :dependent => :destroy
+ has_one :course, :dependent => :destroy ,:order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
accepts_nested_attributes_for :course
##end
# Custom field for the project issues
@@ -85,10 +92,10 @@ class Project < ActiveRecord::Base
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
:author => nil
############################added by william
- acts_as_taggable
- scope :by_join_date, order("created_at DESC")
+ acts_as_taggable
+ scope :by_join_date, order("created_on DESC")
###################added by liuping 关注
- acts_as_watchable
+ acts_as_watchable
attr_protected :status
@@ -689,6 +696,7 @@ class Project < ActiveRecord::Base
'project_type'
+
safe_attributes 'enabled_module_names',
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
diff --git a/app/models/project_status.rb b/app/models/project_status.rb
new file mode 100644
index 000000000..02eeb30c8
--- /dev/null
+++ b/app/models/project_status.rb
@@ -0,0 +1,21 @@
+class ProjectStatus < ActiveRecord::Base
+ attr_accessible :changesets_count, :watchers_count, :project_id
+ belongs_to :projects
+ belongs_to :watchers
+ belongs_to :changesets
+ validates_presence_of :project_id
+ validates_uniqueness_of :project_id
+
+ scope :visible, lambda {|*args| nil }
+ # 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
+ # 负责这个表的聂同学 是在新建用户时就新建了该表的记录
+ # 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
+ # 删除用户时 此表创建人员未作相应删除动作
+ def update_watchers_count(num)
+ if self.watchers_count >= 0
+ self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
+ end
+ end
+
+
+end
diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb
new file mode 100644
index 000000000..597d74da6
--- /dev/null
+++ b/app/models/students_for_course.rb
@@ -0,0 +1,10 @@
+class StudentsForCourse < ActiveRecord::Base
+ attr_accessible :course_id, :student_id
+
+ belongs_to :course, :class_name => 'Project', :foreign_key => :course_id
+ belongs_to :student, :class_name => 'User', :foreign_key => :student_id
+
+ validates_presence_of :course_id, :student_id
+ validates_uniqueness_of :student_id, :scope => :course_id
+
+end
diff --git a/app/models/teacher.rb b/app/models/teacher.rb
new file mode 100644
index 000000000..cf57a1be8
--- /dev/null
+++ b/app/models/teacher.rb
@@ -0,0 +1,13 @@
+class Teacher < ActiveRecord::Base
+ attr_accessible :course_code, :couurse_time, :location, :tea_name
+ include Redmine::SafeAttributes
+
+ belongs_to :project
+
+ safe_attributes'tea_name',
+ 'location',
+ 'couurse_time',
+ 'course_code',
+ 'extra'
+
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 8497918e7..7185041ae 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -82,12 +82,16 @@ class User < Principal
has_many :bids, :foreign_key => 'author_id', :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
- has_many :journal_replies
- has_many :activities
+ has_many :journal_replies, :dependent => :destroy
+ has_many :activities, :dependent => :destroy
+ has_many :students_for_courses, :dependent => :destroy
+ has_many :courses, :through => :students_for_courses, :source => :project
+ has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
#####
######added by nie
has_many :project_infos, :dependent => :destroy
+ has_one :user_status, :dependent => :destroy
#####
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
@@ -98,10 +102,10 @@ class User < Principal
acts_as_customizable
############################added by william
acts_as_taggable
- scope :by_join_date, order("created_at DESC")
+ scope :by_join_date, order("created_on DESC")
############################# added by liuping 关注
- acts_as_watchable
- has_one :user_extensions
+ acts_as_watchable
+ has_one :user_extensions,:dependent => :destroy
## end
attr_accessor :password, :password_confirmation
@@ -128,6 +132,9 @@ class User < Principal
before_create :set_mail_notification
before_save :update_hashed_password
before_destroy :remove_references_before_destroy
+ # added by fq
+ after_create :act_as_activity
+ # end
scope :in_group, lambda {|group|
group_id = group.is_a?(Group) ? group.id : group.to_i
@@ -145,6 +152,17 @@ class User < Principal
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true)
end
+ ### fq
+ def join_in?(course)
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id)
+ if joined.size > 0
+ true
+ else
+ false
+ end
+ end
+ ## end
+
def count_new_jour
count = self.new_jours.count
end
@@ -200,7 +218,7 @@ class User < Principal
user = find_by_login(login)
if user
# user is already in local database
- return nil unless user.active?
+ #return nil unless user.active?
return nil unless user.check_password?(password)
else
# user is not yet registered, try to authenticate with available sources
@@ -668,6 +686,10 @@ class User < Principal
end
private
+
+ def act_as_activity
+ self.acts << Activity.new(:user_id => self.id)
+ end
# Removes references that are not handled by associations
# Things that are not deleted are reassociated with the anonymous user
diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb
index 47578e66f..11df8958d 100644
--- a/app/models/user_extensions.rb
+++ b/app/models/user_extensions.rb
@@ -1,6 +1,6 @@
class UserExtensions < ActiveRecord::Base
belongs_to :user
- attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
+ attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity
#this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil,
gender=nil,location=nil,occupation=nil,work_experience=nil,zip_code=nil)
diff --git a/app/models/user_status.rb b/app/models/user_status.rb
new file mode 100644
index 000000000..f7815b62e
--- /dev/null
+++ b/app/models/user_status.rb
@@ -0,0 +1,20 @@
+class UserStatus < ActiveRecord::Base
+ attr_accessible :changesets_count, :user_id, :watchers_count
+ belongs_to :users
+ belongs_to :watchers
+ belongs_to :changesets
+ validates_presence_of :user_id
+ validates_uniqueness_of :user_id
+
+ scope :visible, lambda {|*args| nil }
+ # 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
+ # 负责这个表的聂同学 是在新建用户时就新建了该表的记录
+ # 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
+ # 删除用户时 此表创建人员未作相应删除动作
+ def update_watchers_count(num)
+ if self.watchers_count >= 0
+ self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
+ end
+ end
+
+end
diff --git a/app/models/watcher.rb b/app/models/watcher.rb
index 1cea711b7..853e0cf6b 100644
--- a/app/models/watcher.rb
+++ b/app/models/watcher.rb
@@ -18,6 +18,10 @@
class Watcher < ActiveRecord::Base
belongs_to :watchable, :polymorphic => true
belongs_to :user
+ #Added by nie
+ has_one :project_status
+ has_one :users_status
+ #end
validates_presence_of :user
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb
index 05a9f61f7..4ee1fcfc2 100644
--- a/app/views/account/login.html.erb
+++ b/app/views/account/login.html.erb
@@ -26,13 +26,15 @@
-
- <% if Setting.lost_password? %>
+
+
+ <% if Setting.lost_password? %>
<%= link_to l(:label_password_lost), lost_password_path %>
- <% end %>
-
-
-
+ <% end %>
+
+
+
+
diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb
index 8264a4891..292cf9a74 100644
--- a/app/views/account/register.html.erb
+++ b/app/views/account/register.html.erb
@@ -1,4 +1,4 @@
-<%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>
+<%=l(:label_register)%> <%=link_to l(:label_loginkk), signin_url if Setting.openid? %>
<%= labelled_form_for @user, :url => register_path do |f| %>
<%= error_messages_for 'user' %>
@@ -20,14 +20,21 @@
<%="#{l(:label_mail_attention)} "%>
<%= f.select :language, lang_options_for_select %>
+
+
+<%= l(:label_identity) %><%= select_tag 'identity', "#{l(:label_teacher)} #{l(:label_student)} #{l(:label_other)} ".html_safe %>
+
+
<% if Setting.openid? %>
<%= f.text_field :identity_url %>
<% end %>
+
<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
<%= custom_field_tag_with_label :user, value %>
<% end %>
+
<%= submit_tag l(:button_submit) %>
<% end %>
diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb
index 30dd92ed5..40760e12f 100644
--- a/app/views/bids/_bid_show.html.erb
+++ b/app/views/bids/_bid_show.html.erb
@@ -13,19 +13,25 @@
-
-<% if bid.reward_type.nil? or bid.reward_type == 1%>
+
+ <% if bid.reward_type.nil? or bid.reward_type == 1%>
<%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%>
<% elsif bid.reward_type == 2%>
<%= l(:label_bids_reward_method) %><%= bid.budget%>
<% else %>
- <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= bid.budget%><%= l(:label_bids_credit_number) %>
+ <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %>
<% end %>
-(<%= link_to bid.biding_projects.count, project_for_bid_path(bid)%>)<%= l(:label_biding_project) %>
-(<%= link_to bid.commit, respond_path(bid)%>)<%= l(:label_responses) %>
-(<%= link_to bid.watcher_users.count, respond_path(bid)%>)<%= l(:label_followers) %>
-
-
+
+
+
+
+
+ <%= l(:label_x_biding_project, :count => bid.biding_projects.count) %>(<%=link_to bid.biding_projects.count, project_for_bid_path(bid) %> )
+ <%= l(:label_x_responses, :count => bid.commit) %>(<%=link_to bid.commit, respond_path(bid) %> )
+ <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%=link_to bid.watcher_users.count, respond_path(bid) %> )
+
+
+
<%= format_time bid.created_on %>
diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb
index 494511e54..aac579d7b 100644
--- a/app/views/bids/_history.html.erb
+++ b/app/views/bids/_history.html.erb
@@ -1,7 +1,7 @@
- <%=l(:label_user_response)%>
+ <%=l(:label_user_response)%>
@@ -11,14 +11,14 @@
<% if journals.size >0 %>
-<% remove_allowed = (User.current.id == journals.first.jour_id) %>
+
<% for journal in journals%>
<%= link_to image_tag(url_to_avatar(journal.user), :class => "avatar"), user_path(journal.user), :class => "avatar" %>
- <%=link_to journal.user, user_path(journal.user)%> <%= l(:label_respond_requirement) %> <%= link_to "##{journal.indice}", respond_path(bid), :class => "journal-link" %>
+ <%=link_to journal.user, user_path(journal.user)%> <%= l(:label_respond_requirement) %>
<%= textilizable journal.notes%>
@@ -26,17 +26,18 @@
<%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %>
<% if @user==User.current|| User.current.admin? %>
- <%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
+ <%= link_to(l(:label_bid_respond_quote), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
:method => 'post', :title => l(:button_quote))%>
- <%= link_to(image_tag('delete.png'), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
- :remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) if remove_allowed || journal.user_id == User.current.id %>
+ <%= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
+ :remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% else %>
- <%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
+ <%= link_to(l(:label_bid_respond_quote), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
:method => 'post', :title => l(:button_quote))%>
<% end %>
+
<% end %>
<% end %>
diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb
index d3bac2d07..bfe86c75c 100644
--- a/app/views/bids/_project_list.html.erb
+++ b/app/views/bids/_project_list.html.erb
@@ -1,7 +1,7 @@
<%= render_flash_messages %>
- <%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
+ <%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
<% if User.current.logged? %>
@@ -20,17 +20,17 @@
<%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %>
-
-
+
+
@@ -40,7 +40,7 @@
<%= l(:label_bidding_user) %><%= link_to(b_project.user.name, user_path(b_project.user)) %>
- <%= l(:label_bidding_reason) %><%= b_project.description %>
+ <%= l(:label_bidding_reason) %><%= b_project.description %>
diff --git a/app/views/bids/index.html.erb b/app/views/bids/index.html.erb
index 32ab5e1b1..f5234a840 100644
--- a/app/views/bids/index.html.erb
+++ b/app/views/bids/index.html.erb
@@ -28,6 +28,21 @@
<% end %>
+<%= sort_bid(@s_state)%>
+
+
+
<%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb
index 06b38307b..d3b526982 100644
--- a/app/views/bids/show.html.erb
+++ b/app/views/bids/show.html.erb
@@ -5,6 +5,14 @@
<%= link_to(@bid.author.name, user_path(@bid.author))%>:<%= @bid.name %>
+
+
+
+ <%= render :partial => "/praise_tread/praise_tread",
+ :locals => {:obj => @bid,:show_flag => true,:user_id =>User.current.id}%>
+
+
+
<% if @bid.reward_type.nil? or @bid.reward_type == 1%>
@@ -12,7 +20,7 @@
<% elsif @bid.reward_type == 2%>
<%= l(:label_bids_reward_method) %><%= @bid.budget%>
<% else %>
- <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= @bid.budget%><%= l(:label_bids_credit_number) %>
+ <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= @bid.budget%> <%= l(:label_bids_credit_number) %>
<% end %>
@@ -23,7 +31,7 @@
- <%= @bid.description %>
+ <%= @bid.description %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index e83ddc879..001ae9596 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -1,4 +1,4 @@
-
+
<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
diff --git a/app/views/git_usage/ch_usage.html.erb b/app/views/git_usage/ch_usage.html.erb
index f7b622c44..f2937be17 100644
--- a/app/views/git_usage/ch_usage.html.erb
+++ b/app/views/git_usage/ch_usage.html.erb
@@ -1,3 +1,4 @@
+
@@ -49,6 +50,21 @@ body table tr td p span4 {
body table tr td p span4 {
font-weight: bold;
}
+body table tr td span5 {
+ color: #F00;
+}
+body table tr td span5 {
+ font-weight: bold;
+}
+body table tr td p span6 {
+ color: #33F;
+ font-weight: bold;
+}
+body table tr td span6 {
+ color: #33F;
+ font-weight: bold;
+ font-size: 24px;
+}
@@ -66,7 +82,8 @@ body table tr td p span4 {
@@ -126,7 +143,8 @@ body table tr td p span4 {
在桌面上点击鼠标右键,选择TortoiseGit的Settings进行设置
- Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到)。
+ Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到, 其中的name和email要和forge.trustie.net上的登陆名和密码保持一致
+ ,方便代码贡献统计 )。
接着可以定制上下文菜单:
@@ -265,11 +283,59 @@ body table tr td p span4 {
+
+
+
+ 1、安装
+
+
+ 如果你用的是Linux,你可以用你的本地包管理系统(native package management system)来安装。
+
+
+ $ yum install git-core
+ 在redhat等系统下用yum
+ $apt-get install git-core
+ 在debian,ubuntu等系统下用apt-get
+
+
+
+
+
+
+
+ 2、配置
+
+
+ $git config --global user.name “your_name”
+ $git config --global user.email “your_email”
+ Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到,
+ 其中的name和email要和forge.trustie.net上的登陆名和密码保持一致
+,方便代码贡献统计 )。
+
+
+
+
+ 3、代码提交方法
+
+
+ cd file1
+ $ git add file1
+ $ git init
+ $ git commit -a
+ $ git remote add [name] [版本库里给的URL(去掉http)]
+ $ git push [name] master
+ 输入password后即可上传。
+
+
——Trustie团队
diff --git a/app/views/git_usage/en_usage.html.erb b/app/views/git_usage/en_usage.html.erb
index d312a86c0..ce202c792 100644
--- a/app/views/git_usage/en_usage.html.erb
+++ b/app/views/git_usage/en_usage.html.erb
@@ -30,10 +30,10 @@ body p {
body table tr td p {
color: #333;
font-family: "Comic Sans MS", cursive;
+ font-weight: normal;
}
body table tr td table tr td span1 {
color: #09c;
- font-weight: bold;
}
body table tr td span1 {
color: #09c;
@@ -45,6 +45,22 @@ span3 {
span4 {
color: #F00;
}
+body table tr td p span5 {
+ color: #F00;
+}
+body table tr td p span5 {
+ font-weight: bold;
+}
+body table tr td table tr td span6 {
+ color: #33F;
+ font-weight: bold;
+ font-size: 24px;
+}
+body table tr td span6 {
+ color: #33F;
+ font-weight: bold;
+ font-size: 24px;
+}
@@ -67,6 +83,11 @@ span4 {
+
1. Installation
@@ -122,7 +143,8 @@ span4 {
Right-click on the desktop and select the "Settings" in the "TortoiseGit"
- User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository).
+ User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository, the name and email must be the same with login name and email you registed in the forge.trustie.net
+ ).
Then you can customize the "Context Menu":
Please check the "Clone ","Sync " and "Commit " options in the "Context Menu ",
check the "Import Svn Ignore ", "Show Reflog ", "Browse References ", "Stash Apply " and "Submodule Sync " in the "Set Extend Menu Item ".
@@ -256,11 +278,56 @@ span4 {
+
+
+
+ 1.Installation
+
+
+ If you are useing Linux, you can install git through native package management system.
+ $ yum install git-core
+ if you are using redhat, you should type "yum".
+ $apt-get install git-core
+ if you are using debian or ubuntu, you should type "apt-get".
+
+
+
+ 2. Configuration
+
+
+ $git config --global user.name “your_name”M
+ $git config --global user.email “your_email”
+ User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository,
+ the name and email must be the same with login name and email you registed in the forge.trustie.net
+).
+
+
+
+
+
+
+ 3. How to commit
+
+
+ cd file1
+ $ git add file1
+ $ git init
+ $ git commit -a
+ $ git remote add [name] [The URL which we give you in our website(with out http)]
+ $ git push [name] master
+ The last step is enter your password.
+
+
+
—— By Trustie Team
diff --git a/app/views/issues/_history.html.erb b/app/views/issues/_history.html.erb
index ba1dfa032..0c584e287 100644
--- a/app/views/issues/_history.html.erb
+++ b/app/views/issues/_history.html.erb
@@ -1,7 +1,9 @@
<% reply_links = authorize_for('issues', 'edit') -%>
<% for journal in journals %>
-
+
+
+
<%= link_to image_tag(url_to_avatar(journal.user), :class => "avatar"), user_path(journal.user), :class => "avatar" %>
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index 50dc818ef..59d43ef56 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -1,6 +1,6 @@
<%= l(:field_issue) %>
-
+
<%= link_to l(:label_issue_new), { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }, :class => 'icon icon-add' %>
diff --git a/app/views/issues/update_form.js.erb b/app/views/issues/update_form.js.erb
index 46fc9722e..615bbfcb3 100644
--- a/app/views/issues/update_form.js.erb
+++ b/app/views/issues/update_form.js.erb
@@ -1,5 +1,5 @@
$('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>');
-
+$(.splitcontent).style("display", "block")
<% if User.current.allowed_to?(:log_time, @issue.project) %>
$('#log_time').show();
<% else %>
diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb
index 9be9065cc..5ee9c8072 100644
--- a/app/views/layouts/_base_header.html.erb
+++ b/app/views/layouts/_base_header.html.erb
@@ -5,14 +5,15 @@
<%= render_menu :account_menu -%>
-
+ <%= content_tag('div', "#{link_to(l(:label_layouts_feedback)+'(' + User.current.count_new_jour.to_s + ')', feedback_path(User.current))}".html_safe, :id => 'loggedas') if User.current.logged? %>
<%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
-
+
+
+
diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb
index 2acb18d37..03717da65 100644
--- a/app/views/layouts/base_bids.html.erb
+++ b/app/views/layouts/base_bids.html.erb
@@ -53,7 +53,7 @@
<% elsif @bid.reward_type == 2%>
<%= l(:label_bids_reward_method) %><%= @bid.budget%>
<% else %>
- <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= @bid.budget%><%= l(:label_bids_credit_number) %>
+ <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= @bid.budget%> <%= l(:label_bids_credit_number) %>
<% end %>
@@ -62,7 +62,9 @@
- <%= l(:label_followers) %> (<%= link_to @bid.watcher_users.count, home_path %>) <%= l(:label_bidding_project) %>(<%= link_to @bid.biding_projects.count, project_for_bid_path(@bid) %>) <%=l(:label_responses)%>(<%= link_to @bid.commit, respond_path(@bid)%>)
+ <%= link_to l(:label_followers)+"("+@bid.watcher_users.count.to_s+")", respond_path(@bid) %>
+ <%= link_to l(:label_bidding_project)+"("+@bid.biding_projects.count.to_s+")", project_for_bid_path(@bid) %>
+ <%= link_to l(:label_responses)+"("+@bid.commit.to_s+")", respond_path(@bid)%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 80c619eb0..e9976f4a0 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -36,6 +36,7 @@
<%= textilizable @project.name %>
+ <%= join_in_course(@project, User.current)%>
@@ -52,18 +53,37 @@
<% files_count += version.attachments.count %>
<% end %>
- <%=link_to "#{@project.members.count}", project_member_path(@project) %>
+ <%=link_to "#{@project.members.count}", project_member_path(@project) ,:course =>'1'%>
<%=link_to "#{@project.issues.count}", project_issues_path(@project) %>
<%=link_to files_count, project_files_path(@project) %>
- <%= l(:label_course_student) %>
- <%= l(:label_homework) %>
+ <%= " 成员" %>
+ <%= "缺陷" %>
<%= l(:label_course_data) %>
+
+
+
+
+
+ 教师名称:
+
+
+ 所在单位:
+
+
+ 课程学分:
+
+
+ 课程学时:
+
+
+
+
-
-
教师名称:<%= @course.name%>
-
所在单位:并行与分布重点实验室
-
课程学分:<%=@course.code%>
-
课程学时:<%=@course.time%>
-
XXXX:XXXXXXXX
-
+
+
- <%= link_to(l(:label_overview), project_path(@project))%>
+ <%= link_to(l(:label_overview), project_path(@project))%>
<%= link_to(l(:label_homework), {:controller => 'projects', :action => 'homework'})%>
- <%= link_to(l(:label_repository), { :controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1 })%>
- <%= link_to(l(:label_settings),{:controller => 'projects', :action => 'settings', :id => @project, :course => 1})%>
+
<%= link_to(l(:label_course_file), project_file_path(@project))%>
+
<%= link_to "课程通知", {:controller => 'news', :action => 'index'} %>
+
+
<%= link_to(l(:label_settings),{:controller => 'projects', :action => 'settings', :id => @project})%>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index c0cd755a8..404a20fa1 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -34,7 +34,7 @@
<%= link_to image_tag(url_to_avatar(@project), :class => 'avatar2') %>
- <%= textilizable @project.name %>
+ <%= @project.name %>
<% unless User.current.member_of? @project %>
@@ -45,7 +45,7 @@
-
+
@@ -56,12 +56,16 @@
<% end %>
<%=link_to "#{@project.members.count}", project_member_path(@project) %>
+ <%=link_to @project.watcher_users.count, :controller=>"projects", :action=>"watcherlist" %>
<%=link_to "#{@project.issues.count}", project_issues_path(@project) %>
- <%=link_to files_count, project_files_path(@project) %>
+
+
- <%= l(:label_member) %>
- <%= l(:label_project_issues) %>
- <%= l(:label_attachment) %>
+ <%= l(:label_member) %>
+ <%= l(:label_user_watchered) %>
+ <%= l(:label_project_issues) %>
+
+
@@ -79,7 +83,7 @@
<%= textilizable @project.description %>
- <%= l(:label_create_time) %>: <%= @project.created_on %>
+ <%= l(:label_create_time) %>: <%= format_time(@project.created_on) %>
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb
index 635120f85..8641e3138 100644
--- a/app/views/layouts/base_users.html.erb
+++ b/app/views/layouts/base_users.html.erb
@@ -47,24 +47,24 @@
- <%= l(:label_user_watcher) %> (<%=link_to User.watched_by(@user.id).count ,:controller=>"users", :action=>"user_watchlist"%> )
+ <%=link_to l(:label_user_watcher)+"("+User.watched_by(@user.id).count.to_s+")" ,:controller=>"users", :action=>"user_watchlist"%>
- <%= l(:label_user_fans) %> (<%=link_to @user.watcher_users(@user.id).count, :controller=>"users", :action=>"user_fanslist" %> )
+ <%=link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users(@user.id).count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>
-
+
- <%= l(:label_user_joinin) %>
+ <%= l(:label_user_joinin) %>
- <%= l(:label_user_login) %>
+ <%= l(:label_user_login) %>
- <%= l(:label_user_mail) %>
+ <%= l(:label_user_mail) %>
@@ -75,8 +75,10 @@
-