new version

exceptionHandle
huangjingquan 12 years ago
parent 7dbcc1520c
commit 261c3fc337

@ -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'

@ -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.

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

@ -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
@ -181,6 +188,8 @@ class AccountController < ApplicationController
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
@ -271,12 +280,18 @@ class AccountController < ApplicationController
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.
#
# Pass a block for behavior when a user fails to save
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

@ -18,12 +18,50 @@ class BidsController < ApplicationController
@offset ||= @bid_pages.reverse_offset
#@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
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
@ -240,6 +280,32 @@ class BidsController < ApplicationController
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
@jour.each_with_index {|j,i| j.indice = i+1}
@ -252,6 +318,7 @@ class BidsController < ApplicationController
end
end
def back
@jour = @bid.journals_for_messages
@jour.each_with_index {|j,i| j.indice = i+1}

@ -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

@ -51,11 +51,45 @@ class MyController < ApplicationController
@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] : [])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,5 @@
class TeachersController < ApplicationController
def show
end
end

@ -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
@ -155,15 +155,124 @@ class UsersController < ApplicationController
}
# @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
@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']
@offset ||= @user_pages.offset
@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
@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
@ -173,6 +282,7 @@ class UsersController < ApplicationController
end
end
### modified by fq
def show
# has = {
@ -215,6 +325,33 @@ class UsersController < ApplicationController
# @activity_pages = Paginator.new @activity_count, @limit, params['page']
# @offset ||= @activity_pages.offset
# @events_by_day_ = @events.slice(@offset,@limit)
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)
@ -227,6 +364,9 @@ class UsersController < ApplicationController
@activity_pages = Paginator.new @activity_count, @limit, params['page']
@offset ||= @activity_pages.offset
@activity = activity.offset(@offset).limit(@limit)
@state = 0
end
#Modified by nie
unless User.current.admin?
@ -250,9 +390,9 @@ class UsersController < ApplicationController
message = []
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']

@ -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
@ -26,6 +24,41 @@ class WatchersController < ApplicationController
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
@ -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}}

@ -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
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{<pre>((.|\s)*?)</pre>}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

@ -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))

@ -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

@ -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

@ -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

@ -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}")+"<span style='color:#F00;'>(#{l(:label_course)})</span>".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

@ -0,0 +1,2 @@
module TeachersHelper
end

@ -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
# <div class="pagination" >
# <ul>
# <li><%= link_to("所有动态", {:controller => 'users', :action => 'show'}) %></li>
# <li><%= link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}) %></li>
# <li><%= link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}) %></li>
# </ul></div>
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

@ -46,6 +46,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)
objects = Array.wrap(objects)

@ -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}$/
@ -55,6 +57,10 @@ class Bid < ActiveRecord::Base
'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)
end

@ -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",

@ -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

@ -0,0 +1,8 @@
class HomeworkForCourse < ActiveRecord::Base
attr_accessible :bid_id, :project_id
belongs_to :bid
belongs_to :project
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save