修改contests_controller.rb,contest.rb, contest_project.rb,contests_helper.rb,

attachments_helper.rb, application_helper.rb.
主要修改内容: 书写规范, for循环用 each 代替, if 语句的合并, unless 转换成if,
		函数名称拼写错误。

Signed-off-by: alan <547533434@qq.com>
alan_competition
alan 11 years ago
parent 02c72c68ca
commit 70b079041c

File diff suppressed because it is too large Load Diff

@ -33,8 +33,8 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
#Added by young
#Define the course menu's link class
# Added by young
# Define the course menu's link class
# 不是数组的转化成数组然后判断当前menu_item是否在给定的列表
# REVIEW: 目测menu的机制貌似不是很需要转换再说
def link_class(label)

@ -22,6 +22,9 @@ module AttachmentsHelper
# Options:
# :author -- author names are not displayed if set to false
# :thumbails -- display thumbnails if enabled in settings
include Redmine::Pagination
def link_to_attachments(container, options = {})
options.assert_valid_keys(:author, :thumbnails)
@ -171,7 +174,9 @@ module AttachmentsHelper
s.html_safe
end
def private_filter resultSet
# Modified by Longjun
# 有参数的方法要加()
def private_filter(resultSet)
result = resultSet.to_a.dup
# modify by nwb
@ -190,8 +195,12 @@ module AttachmentsHelper
result
end
include Redmine::Pagination
def paginateHelper obj, pre_size=10
# Modified by Longjun
# include 应放在class/model 的开始处
# include Redmine::Pagination
# end
def paginateHelper (obj, pre_size=10)
@obj_count = obj.count
@obj_pages = Paginator.new @obj_count, pre_size, params['page']
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation

@ -43,16 +43,16 @@ module ContestsHelper
def sort_contest_enterprise(state, project_type)
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type)))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise")
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type)))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise")
end
#end
@ -100,7 +100,10 @@ module ContestsHelper
def count_contest_project
contests = Contest.find(:id)
@projects = []
for contest in contests
# Modified by alan
# for contest in contests
contests.each do |contest|
# end alan
@projects += contest.contesting_projects
end
@projects.count
@ -109,7 +112,10 @@ module ContestsHelper
def count_contest_softapplication
contests = Contest.find(:id)
@softapplications = []
for contest in contests
# Modified by alan
# for contest in contests
contests.each do |contest|
# end alan
@softapplications += contest.contesting_softapplications
end
@projects.count
@ -119,19 +125,29 @@ module ContestsHelper
def count_contest_user
contests = Contest.find(:id)
@users = []
for contest in contests
for project in contest.projects
# Modified by alan
# for contest in contests
contests.each do |contest|
contest.projects.each do |project|
@users += project.users
end
end
# end alan
@users.count
end
def count_contest_softapplication_user
contests = Contest.find(:id)
@users = []
for contest in contests
for project in contest.softapplications
# Modified by alan
# for contest in contests
contests.each do |contest|
contest.projects.each do |softapplications|
# for project in contest.softapplications
@users += softapplication.users
end
end

@ -44,7 +44,7 @@ module ProjectsHelper
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
@ -70,19 +70,19 @@ module ProjectsHelper
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id)))
when 1
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected")
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id)))
when 2
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id)))
#gcm
when 3
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id)))
@ -101,7 +101,7 @@ module ProjectsHelper
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
@ -142,7 +142,7 @@ module ProjectsHelper
# end
#Added by young
# 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, :project_type => 1},
@ -151,7 +151,7 @@ module ProjectsHelper
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
end
#Ended by young
# Ended by young
@ -174,20 +174,37 @@ module ProjectsHelper
def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project|
#Modified by young
if (project.try(:project_type) == Project::ProjectType_course )
unless project.is_public == 1
s = "<span class='private_project'>#{l(:lable_private)}</span>".html_safe
if project.try(:project_type) == Project::ProjectType_course
# modified by longjun
# never use unless and else
# unless project.is_public == 1
if project.is_public != 1
s = "<span class='private_project'>#{l(:lable_private)}</span>".html_safe
else
s = "".html_safe
end
s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe
# end longjun
# modified by Longjun
s += link_to_project(project, {},
:class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe
# end longjun
else
unless project.is_public
# modified by longjun
# unless project.is_public
if !project.is_public
# end longjun
s = "<span class='private_project'>#{l(:lable_private)}</span>".html_safe
else
s = "".html_safe
end
s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
# modified by longjun
s += link_to_project(project, {},
:class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
# end longjun
end
#Ended by young
if project.description.present?
@ -254,9 +271,14 @@ module ProjectsHelper
def is_manager?(user_id,project_id)
@result = false
@user_id = ProjectInfo.find_by_project_id(project_id)
if @user_id == user.id
@result = true
end
# modified by longjun
# if @user_id == user.id
# @result = true
# end
@result = true if @user_id = user.id
# end longjun
return @result
end
@ -341,9 +363,9 @@ module ProjectsHelper
return true if (project.nil? && project.course_extra.nil?)
courses_year = project.course_extra.time
current_year = Time.now.year
if(courses_year >= current_year)
if courses_year >= current_year
return false
elsif( (courses_year < current_year) && (Time.now.month < 3) )
elsif (courses_year < current_year) && (Time.now.month < 3)
return false
else
return true

@ -72,11 +72,14 @@ class Contest < ActiveRecord::Base
end
end
def self.creat_contests(budget, deadline, name, description=nil)
self.create(:author_id => User.current.id, :budget => budget,
:deadline => deadline, :name => name, :description => description, :commit => 0)
end
# modified by longjun
# 这个函数没有用到
# def self.creat_contests(budget, deadline, name, description=nil)
# self.create(:author_id => User.current.id, :budget => budget,
# :deadline => deadline, :name => name, :description => description, :commit => 0)
# end
# end longjun
def update_contests(budget, deadline, name, description=nil)
if(User.current.id == self.author_id)
self.name = name

@ -14,7 +14,7 @@ class ContestingProject < ActiveRecord::Base
validate :validate_project
validates_uniqueness_of :contest_id, :scope => :project_id
def self.cerate_contesting(contest_id, project_id, description = nil)
def self.create_contesting(contest_id, project_id, description = nil)
self.create(:user_id => User.current.id, :contest_id => contest_id,
:project_id => project_id, :description => description)
end

@ -30,7 +30,18 @@
<% if User.current.logged? %>
<table border="0" width="525px" align="center" >
<tr>
<td><%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%></td>
<!-- modified by longjun 修改格式 -->
<td>
<%= f.text_area 'message',
:rows => 3,
:cols => 65,
:placeholder => l(:label_my_respond),
:style => "resize: none;",
:class => 'noline'
%>
</td>
<!-- end longjun -->
</tr>
</table>
@ -39,8 +50,23 @@
<!-- modified by bai -->
<table border="0" width="525px" align="center">
<tr>
<td align="right"> <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "contest_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%>
<%= submit_tag l(:button_clear_meassge), :name => nil, :onclick => "clearMessage('contest_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> </td>
<!-- modified by longjun 修改格式 -->
<td align="right">
<%= submit_tag l(:button_leave_meassge),
:name => nil ,
:class => "contest_btn",
:onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -31px'"
%>
<%= submit_tag l(:button_clear_meassge),
:name => nil,
:onclick => "clearMessage('contest_message_message');",
:type => 'button', :class => "bid_btn",
:onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -31px'"
%>
</td>
<!-- end longjun -->
</tr>
</table>
<!-- end -->

Loading…
Cancel
Save