|
|
@ -81,7 +81,7 @@ module ApplicationHelper
|
|
|
|
def authorize_for(controller, action)
|
|
|
|
def authorize_for(controller, action)
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @project)
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# add by nwb
|
|
|
|
# add by nwb
|
|
|
|
def authorize_for_course(controller, action)
|
|
|
|
def authorize_for_course(controller, action)
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @course)
|
|
|
|
User.current.allowed_to?({:controller => controller, :action => action}, @course)
|
|
|
@ -128,6 +128,15 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def link_to_isuue_user(user, options={})
|
|
|
|
|
|
|
|
if user.is_a?(User)
|
|
|
|
|
|
|
|
name = h(user.name(options[:format]))
|
|
|
|
|
|
|
|
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "pro_info_p"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
h(user.to_s)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def link_to_settings_user(user, options={})
|
|
|
|
def link_to_settings_user(user, options={})
|
|
|
|
if user.is_a?(User)
|
|
|
|
if user.is_a?(User)
|
|
|
|
name = h(user.name(options[:format]))
|
|
|
|
name = h(user.name(options[:format]))
|
|
|
@ -201,7 +210,7 @@ module ApplicationHelper
|
|
|
|
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
|
|
|
|
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
|
|
|
|
html_options = options.slice!(:only_path)
|
|
|
|
html_options = options.slice!(:only_path)
|
|
|
|
url = send(route_method, attachment, attachment.filename, options)
|
|
|
|
url = send(route_method, attachment, attachment.filename, options)
|
|
|
|
url << "?token=#{token}" unless token.nil?
|
|
|
|
url << "?token=#{token}" unless token.nil?
|
|
|
|
link_to text, url, html_options
|
|
|
|
link_to text, url, html_options
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -226,18 +235,18 @@ module ApplicationHelper
|
|
|
|
h(text),
|
|
|
|
h(text),
|
|
|
|
{:controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev},
|
|
|
|
{:controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev},
|
|
|
|
:title => l(:label_revision_id, format_revision(revision))
|
|
|
|
:title => l(:label_revision_id, format_revision(revision))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Generates a link to a message
|
|
|
|
# Generates a link to a message
|
|
|
|
def link_to_message(message, options={}, html_options = nil)
|
|
|
|
def link_to_message(message, options={}, html_options = nil)
|
|
|
|
link_to(
|
|
|
|
link_to(
|
|
|
|
truncate(message.subject, :length => 60),
|
|
|
|
truncate(message.subject, :length => 60),
|
|
|
|
board_message_path(message.board_id, message.parent_id || message.id, {
|
|
|
|
board_message_path(message.board_id, message.parent_id || message.id, {
|
|
|
|
:r => (message.parent_id && message.id),
|
|
|
|
:r => (message.parent_id && message.id),
|
|
|
|
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
|
|
|
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
|
|
|
}.merge(options)),
|
|
|
|
}.merge(options)),
|
|
|
|
html_options
|
|
|
|
html_options
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -289,8 +298,8 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
|
|
def thumbnail_tag(attachment)
|
|
|
|
def thumbnail_tag(attachment)
|
|
|
|
link_to image_tag(thumbnail_path(attachment)),
|
|
|
|
link_to image_tag(thumbnail_path(attachment)),
|
|
|
|
named_attachment_path(attachment, attachment.filename),
|
|
|
|
named_attachment_path(attachment, attachment.filename),
|
|
|
|
:title => attachment.filename
|
|
|
|
:title => attachment.filename
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 图片缩略图链接
|
|
|
|
# 图片缩略图链接
|
|
|
@ -318,9 +327,9 @@ module ApplicationHelper
|
|
|
|
def image_to_function(name, function, html_options = {})
|
|
|
|
def image_to_function(name, function, html_options = {})
|
|
|
|
html_options.symbolize_keys!
|
|
|
|
html_options.symbolize_keys!
|
|
|
|
tag(:input, html_options.merge({
|
|
|
|
tag(:input, html_options.merge({
|
|
|
|
:type => "image", :src => image_path(name),
|
|
|
|
:type => "image", :src => image_path(name),
|
|
|
|
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
|
|
|
|
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def format_activity_title(text)
|
|
|
|
def format_activity_title(text)
|
|
|
@ -354,7 +363,7 @@ module ApplicationHelper
|
|
|
|
# The given collection may be a subset of the whole project tree
|
|
|
|
# The given collection may be a subset of the whole project tree
|
|
|
|
# (eg. some intermediate nodes are private and can not be seen)
|
|
|
|
# (eg. some intermediate nodes are private and can not be seen)
|
|
|
|
#Modified by nie.
|
|
|
|
#Modified by nie.
|
|
|
|
def render_project_nested_lists(projects)
|
|
|
|
def render_project_nested_lists(projects)
|
|
|
|
s = ''
|
|
|
|
s = ''
|
|
|
|
if projects.any?
|
|
|
|
if projects.any?
|
|
|
|
ancestors = []
|
|
|
|
ancestors = []
|
|
|
@ -383,9 +392,9 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
|
|
if project.try(:project_type) == Project::ProjectType_project
|
|
|
|
if project.try(:project_type) == Project::ProjectType_project
|
|
|
|
unless User.current.member_of?(@project)
|
|
|
|
unless User.current.member_of?(@project)
|
|
|
|
s << "<span style = 'float: right;'>"
|
|
|
|
s << "<span style = 'float: right;'>"
|
|
|
|
s << watcher_link(@project, User.current)#, ['whiteButton'])
|
|
|
|
s << watcher_link(@project, User.current)#, ['whiteButton'])
|
|
|
|
s << "</span>"
|
|
|
|
s << "</span>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
s << (render :partial => 'projects/project', :locals => {:project => project}).to_s
|
|
|
|
s << (render :partial => 'projects/project', :locals => {:project => project}).to_s
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -398,7 +407,7 @@ module ApplicationHelper
|
|
|
|
@project = original_project
|
|
|
|
@project = original_project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
s.html_safe
|
|
|
|
s.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def render_course_nested_lists(courses)
|
|
|
|
def render_course_nested_lists(courses)
|
|
|
|
s = ''
|
|
|
|
s = ''
|
|
|
@ -433,7 +442,7 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#added by young
|
|
|
|
#added by young
|
|
|
|
def render_project_nested_lists_new(projects)
|
|
|
|
def render_project_nested_lists_new(projects)
|
|
|
|
s = ''
|
|
|
|
s = ''
|
|
|
|
if projects.any?
|
|
|
|
if projects.any?
|
|
|
@ -462,7 +471,7 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
s.html_safe
|
|
|
|
s.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
def render_page_hierarchy(pages, node=nil, options={})
|
|
|
|
def render_page_hierarchy(pages, node=nil, options={})
|
|
|
|
content = ''
|
|
|
|
content = ''
|
|
|
|
if pages[node]
|
|
|
|
if pages[node]
|
|
|
@ -511,8 +520,8 @@ module ApplicationHelper
|
|
|
|
projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq
|
|
|
|
projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq
|
|
|
|
if projects.any?
|
|
|
|
if projects.any?
|
|
|
|
options =
|
|
|
|
options =
|
|
|
|
("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
|
|
|
("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
|
|
|
'<option value="" disabled="disabled">---</option>').html_safe
|
|
|
|
'<option value="" disabled="disabled">---</option>').html_safe
|
|
|
|
|
|
|
|
|
|
|
|
options << project_tree_options_for_select(projects, :selected => @project) do |p|
|
|
|
|
options << project_tree_options_for_select(projects, :selected => @project) do |p|
|
|
|
|
{ :value => project_path(:id => p, :jump => current_menu_item) }
|
|
|
|
{ :value => project_path(:id => p, :jump => current_menu_item) }
|
|
|
@ -702,15 +711,15 @@ module ApplicationHelper
|
|
|
|
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)),
|
|
|
|
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)),
|
|
|
|
url.merge({"#{name}[move_to]" => 'highest'}),
|
|
|
|
url.merge({"#{name}[move_to]" => 'highest'}),
|
|
|
|
:method => method, :title => l(:label_sort_highest)) +
|
|
|
|
:method => method, :title => l(:label_sort_highest)) +
|
|
|
|
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)),
|
|
|
|
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)),
|
|
|
|
url.merge({"#{name}[move_to]" => 'higher'}),
|
|
|
|
url.merge({"#{name}[move_to]" => 'higher'}),
|
|
|
|
:method => method, :title => l(:label_sort_higher)) +
|
|
|
|
:method => method, :title => l(:label_sort_higher)) +
|
|
|
|
link_to(image_tag('1downarrow.png', :alt => l(:label_sort_lower)),
|
|
|
|
link_to(image_tag('1downarrow.png', :alt => l(:label_sort_lower)),
|
|
|
|
url.merge({"#{name}[move_to]" => 'lower'}),
|
|
|
|
url.merge({"#{name}[move_to]" => 'lower'}),
|
|
|
|
:method => method, :title => l(:label_sort_lower)) +
|
|
|
|
:method => method, :title => l(:label_sort_lower)) +
|
|
|
|
link_to(image_tag('2downarrow.png', :alt => l(:label_sort_lowest)),
|
|
|
|
link_to(image_tag('2downarrow.png', :alt => l(:label_sort_lowest)),
|
|
|
|
url.merge({"#{name}[move_to]" => 'lowest'}),
|
|
|
|
url.merge({"#{name}[move_to]" => 'lowest'}),
|
|
|
|
:method => method, :title => l(:label_sort_lowest))
|
|
|
|
:method => method, :title => l(:label_sort_lowest))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def breadcrumb(*args)
|
|
|
|
def breadcrumb(*args)
|
|
|
@ -794,15 +803,15 @@ module ApplicationHelper
|
|
|
|
def textilizable(*args)
|
|
|
|
def textilizable(*args)
|
|
|
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
|
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
|
|
case args.size
|
|
|
|
case args.size
|
|
|
|
when 1
|
|
|
|
when 1
|
|
|
|
obj = options[:object]
|
|
|
|
obj = options[:object]
|
|
|
|
text = args.shift
|
|
|
|
text = args.shift
|
|
|
|
when 2
|
|
|
|
when 2
|
|
|
|
obj = args.shift
|
|
|
|
obj = args.shift
|
|
|
|
attr = args.shift
|
|
|
|
attr = args.shift
|
|
|
|
text = obj.send(attr).to_s
|
|
|
|
text = obj.send(attr).to_s
|
|
|
|
else
|
|
|
|
else
|
|
|
|
raise ArgumentError, 'invalid arguments to textilizable'
|
|
|
|
raise ArgumentError, 'invalid arguments to textilizable'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return '' if text.blank?
|
|
|
|
return '' if text.blank?
|
|
|
|
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
|
|
|
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
|
|
@ -958,18 +967,18 @@ module ApplicationHelper
|
|
|
|
# check if page exists
|
|
|
|
# check if page exists
|
|
|
|
wiki_page = link_project.wiki.find_page(page)
|
|
|
|
wiki_page = link_project.wiki.find_page(page)
|
|
|
|
url = if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && obj.page == wiki_page
|
|
|
|
url = if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && obj.page == wiki_page
|
|
|
|
"##{anchor}"
|
|
|
|
"##{anchor}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
case options[:wiki_links]
|
|
|
|
case options[:wiki_links]
|
|
|
|
when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
|
|
|
|
when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
|
|
|
|
when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export
|
|
|
|
when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export
|
|
|
|
else
|
|
|
|
else
|
|
|
|
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
|
|
|
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
|
|
|
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
|
|
|
|
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
|
|
|
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
|
|
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
|
|
|
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent)
|
|
|
|
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
|
|
|
link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# project or wiki doesn't exist
|
|
|
|
# project or wiki doesn't exist
|
|
|
@ -1044,110 +1053,110 @@ module ApplicationHelper
|
|
|
|
# project.changesets.visible raises an SQL error because of a double join on repositories
|
|
|
|
# project.changesets.visible raises an SQL error because of a double join on repositories
|
|
|
|
if repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(repository.id, identifier))
|
|
|
|
if repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(repository.id, identifier))
|
|
|
|
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
|
|
|
|
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
|
|
|
|
:class => 'changeset',
|
|
|
|
:class => 'changeset',
|
|
|
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
|
|
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif sep == '#'
|
|
|
|
elsif sep == '#'
|
|
|
|
oid = identifier.to_i
|
|
|
|
oid = identifier.to_i
|
|
|
|
case prefix
|
|
|
|
case prefix
|
|
|
|
when nil
|
|
|
|
when nil
|
|
|
|
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
|
|
|
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
|
|
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
|
|
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
|
|
|
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
|
|
|
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
|
|
|
:class => issue.css_classes,
|
|
|
|
:class => issue.css_classes,
|
|
|
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
|
|
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'document'
|
|
|
|
when 'document'
|
|
|
|
if document = Document.visible.find_by_id(oid)
|
|
|
|
if document = Document.visible.find_by_id(oid)
|
|
|
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
|
|
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
|
|
|
:class => 'document'
|
|
|
|
:class => 'document'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'version'
|
|
|
|
when 'version'
|
|
|
|
if version = Version.visible.find_by_id(oid)
|
|
|
|
if version = Version.visible.find_by_id(oid)
|
|
|
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
|
|
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
|
|
|
:class => 'version'
|
|
|
|
:class => 'version'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'message'
|
|
|
|
when 'message'
|
|
|
|
if message = Message.visible.find_by_id(oid, :include => :parent)
|
|
|
|
if message = Message.visible.find_by_id(oid, :include => :parent)
|
|
|
|
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
|
|
|
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'forum'
|
|
|
|
when 'forum'
|
|
|
|
if board = Board.visible.find_by_id(oid)
|
|
|
|
if board = Board.visible.find_by_id(oid)
|
|
|
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
|
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
|
|
:class => 'board'
|
|
|
|
:class => 'board'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'news'
|
|
|
|
when 'news'
|
|
|
|
if news = News.visible.find_by_id(oid)
|
|
|
|
if news = News.visible.find_by_id(oid)
|
|
|
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
|
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
|
|
:class => 'news'
|
|
|
|
:class => 'news'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when 'project'
|
|
|
|
when 'project'
|
|
|
|
if p = Project.visible.find_by_id(oid)
|
|
|
|
if p = Project.visible.find_by_id(oid)
|
|
|
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
|
|
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif sep == ':'
|
|
|
|
elsif sep == ':'
|
|
|
|
# removes the double quotes if any
|
|
|
|
# removes the double quotes if any
|
|
|
|
name = identifier.gsub(%r{^"(.*)"$}, "\\1")
|
|
|
|
name = identifier.gsub(%r{^"(.*)"$}, "\\1")
|
|
|
|
case prefix
|
|
|
|
case prefix
|
|
|
|
when 'document'
|
|
|
|
when 'document'
|
|
|
|
if project && document = project.documents.visible.find_by_title(name)
|
|
|
|
if project && document = project.documents.visible.find_by_title(name)
|
|
|
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
|
|
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
|
|
|
:class => 'document'
|
|
|
|
:class => 'document'
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'version'
|
|
|
|
|
|
|
|
if project && version = project.versions.visible.find_by_name(name)
|
|
|
|
|
|
|
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
|
|
|
|
|
|
|
:class => 'version'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'forum'
|
|
|
|
|
|
|
|
if project && board = project.boards.visible.find_by_name(name)
|
|
|
|
|
|
|
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
|
|
|
|
|
|
:class => 'board'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'news'
|
|
|
|
|
|
|
|
if project && news = project.news.visible.find_by_title(name)
|
|
|
|
|
|
|
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
|
|
|
|
|
|
:class => 'news'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'commit', 'source', 'export'
|
|
|
|
|
|
|
|
if project
|
|
|
|
|
|
|
|
repository = nil
|
|
|
|
|
|
|
|
if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$}
|
|
|
|
|
|
|
|
repo_prefix, repo_identifier, name = $1, $2, $3
|
|
|
|
|
|
|
|
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
repository = project.repository
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if prefix == 'commit'
|
|
|
|
when 'version'
|
|
|
|
if repository && (changeset = Changeset.visible.where("repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%").first)
|
|
|
|
if project && version = project.versions.visible.find_by_name(name)
|
|
|
|
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
|
|
|
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
|
|
|
:class => 'changeset',
|
|
|
|
:class => 'version'
|
|
|
|
:title => truncate_single_line(changeset.comments, :length => 100)
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'forum'
|
|
|
|
|
|
|
|
if project && board = project.boards.visible.find_by_name(name)
|
|
|
|
|
|
|
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
|
|
|
|
|
|
:class => 'board'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'news'
|
|
|
|
|
|
|
|
if project && news = project.news.visible.find_by_title(name)
|
|
|
|
|
|
|
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
|
|
|
|
|
|
:class => 'news'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'commit', 'source', 'export'
|
|
|
|
|
|
|
|
if project
|
|
|
|
|
|
|
|
repository = nil
|
|
|
|
|
|
|
|
if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$}
|
|
|
|
|
|
|
|
repo_prefix, repo_identifier, name = $1, $2, $3
|
|
|
|
|
|
|
|
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
repository = project.repository
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if prefix == 'commit'
|
|
|
|
if repository && User.current.allowed_to?(:browse_repository, project)
|
|
|
|
if repository && (changeset = Changeset.visible.where("repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%").first)
|
|
|
|
name =~ %r{^[/\\]*(.*?)(@([^/\\@]+?))?(#(L\d+))?$}
|
|
|
|
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
|
|
|
|
path, rev, anchor = $1, $3, $5
|
|
|
|
:class => 'changeset',
|
|
|
|
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => (prefix == 'export' ? 'raw' : 'entry'), :id => project, :repository_id => repository.identifier_param,
|
|
|
|
:title => truncate_single_line(changeset.comments, :length => 100)
|
|
|
|
:path => to_path_param(path),
|
|
|
|
end
|
|
|
|
:rev => rev,
|
|
|
|
else
|
|
|
|
:anchor => anchor},
|
|
|
|
if repository && User.current.allowed_to?(:browse_repository, project)
|
|
|
|
:class => (prefix == 'export' ? 'source download' : 'source')
|
|
|
|
name =~ %r{^[/\\]*(.*?)(@([^/\\@]+?))?(#(L\d+))?$}
|
|
|
|
|
|
|
|
path, rev, anchor = $1, $3, $5
|
|
|
|
|
|
|
|
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => (prefix == 'export' ? 'raw' : 'entry'), :id => project, :repository_id => repository.identifier_param,
|
|
|
|
|
|
|
|
:path => to_path_param(path),
|
|
|
|
|
|
|
|
:rev => rev,
|
|
|
|
|
|
|
|
:anchor => anchor},
|
|
|
|
|
|
|
|
:class => (prefix == 'export' ? 'source download' : 'source')
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
repo_prefix = nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'attachment'
|
|
|
|
|
|
|
|
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
|
|
|
|
|
|
|
if attachments && attachment = Attachment.latest_attach(attachments, name)
|
|
|
|
|
|
|
|
link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'project'
|
|
|
|
|
|
|
|
if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
|
|
|
|
|
|
|
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
repo_prefix = nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'attachment'
|
|
|
|
|
|
|
|
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
|
|
|
|
|
|
|
if attachments && attachment = Attachment.latest_attach(attachments, name)
|
|
|
|
|
|
|
|
link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when 'project'
|
|
|
|
|
|
|
|
if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
|
|
|
|
|
|
|
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1164,9 +1173,9 @@ module ApplicationHelper
|
|
|
|
@current_section += 1
|
|
|
|
@current_section += 1
|
|
|
|
if @current_section > 1
|
|
|
|
if @current_section > 1
|
|
|
|
content_tag('div',
|
|
|
|
content_tag('div',
|
|
|
|
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
|
|
|
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
|
|
|
:class => 'contextual',
|
|
|
|
:class => 'contextual',
|
|
|
|
:title => l(:button_edit_section)) + heading.html_safe
|
|
|
|
:title => l(:button_edit_section)) + heading.html_safe
|
|
|
|
else
|
|
|
|
else
|
|
|
|
heading
|
|
|
|
heading
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1285,10 +1294,10 @@ module ApplicationHelper
|
|
|
|
# Same as Rails' simple_format helper without using paragraphs
|
|
|
|
# Same as Rails' simple_format helper without using paragraphs
|
|
|
|
def simple_format_without_paragraph(text)
|
|
|
|
def simple_format_without_paragraph(text)
|
|
|
|
text.to_s.
|
|
|
|
text.to_s.
|
|
|
|
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
|
|
|
|
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
|
|
|
|
gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
|
|
|
|
gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
|
|
|
|
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />'). # 1 newline -> br
|
|
|
|
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />'). # 1 newline -> br
|
|
|
|
html_safe
|
|
|
|
html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def wiki_simple_format_without_paragraph(text)
|
|
|
|
def wiki_simple_format_without_paragraph(text)
|
|
|
@ -1303,7 +1312,7 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def lang_options_for_select(blank=true)
|
|
|
|
def lang_options_for_select(blank=true)
|
|
|
|
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
|
|
|
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def label_tag_for(name, option_tags = nil, options = {})
|
|
|
|
def label_tag_for(name, option_tags = nil, options = {})
|
|
|
@ -1395,7 +1404,7 @@ module ApplicationHelper
|
|
|
|
:href => "#",
|
|
|
|
:href => "#",
|
|
|
|
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
|
|
|
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
|
|
|
:accesskey => accesskey(:preview)
|
|
|
|
:accesskey => accesskey(:preview)
|
|
|
|
}.merge(options)
|
|
|
|
}.merge(options)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def link_to_function(name, function, html_options={})
|
|
|
|
def link_to_function(name, function, html_options={})
|
|
|
@ -1422,7 +1431,7 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
|
|
def check_all_links(form_name)
|
|
|
|
def check_all_links(form_name)
|
|
|
|
link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + " ".html_safe + " | "+ " ".html_safe +
|
|
|
|
link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + " ".html_safe + " | "+ " ".html_safe +
|
|
|
|
link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
|
|
|
|
link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def progress_bar(pcts, options={})
|
|
|
|
def progress_bar(pcts, options={})
|
|
|
@ -1433,12 +1442,12 @@ module ApplicationHelper
|
|
|
|
width = options[:width] || '100px;'
|
|
|
|
width = options[:width] || '100px;'
|
|
|
|
legend = options[:legend] || ''
|
|
|
|
legend = options[:legend] || ''
|
|
|
|
content_tag('table',
|
|
|
|
content_tag('table',
|
|
|
|
content_tag('tr',
|
|
|
|
content_tag('tr',
|
|
|
|
(pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed') : ''.html_safe) +
|
|
|
|
(pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed') : ''.html_safe) +
|
|
|
|
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
|
|
|
|
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
|
|
|
|
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
|
|
|
|
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
|
|
|
|
), :class => 'progress', :style => "width: #{width};").html_safe +
|
|
|
|
), :class => 'progress', :style => "width: #{width};").html_safe +
|
|
|
|
content_tag('p', legend, :class => 'percent').html_safe
|
|
|
|
content_tag('p', legend, :class => 'percent').html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def checked_image(checked=true)
|
|
|
|
def checked_image(checked=true)
|
|
|
@ -1451,7 +1460,7 @@ module ApplicationHelper
|
|
|
|
unless @context_menu_included
|
|
|
|
unless @context_menu_included
|
|
|
|
content_for :header_tags do
|
|
|
|
content_for :header_tags do
|
|
|
|
javascript_include_tag('context_menu') +
|
|
|
|
javascript_include_tag('context_menu') +
|
|
|
|
stylesheet_link_tag('context_menu')
|
|
|
|
stylesheet_link_tag('context_menu')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if l(:direction) == 'rtl'
|
|
|
|
if l(:direction) == 'rtl'
|
|
|
|
content_for :header_tags do
|
|
|
|
content_for :header_tags do
|
|
|
@ -1710,7 +1719,7 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
s
|
|
|
|
s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_memo
|
|
|
|
def get_memo
|
|
|
|
@new_memo = Memo.new
|
|
|
|
@new_memo = Memo.new
|
|
|
|
#@new_memo.subject = "有什么想说的,尽管来咆哮吧~~"
|
|
|
|
#@new_memo.subject = "有什么想说的,尽管来咆哮吧~~"
|
|
|
@ -1797,11 +1806,11 @@ module ApplicationHelper
|
|
|
|
html << (content_tag "span", l(:label_no_current_watchers))
|
|
|
|
html << (content_tag "span", l(:label_no_current_watchers))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for user in User.watched_by(obj.id)
|
|
|
|
for user in User.watched_by(obj.id)
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
|
|
|
|
count = count + 1
|
|
|
|
count = count + 1
|
|
|
|
if count >= 12
|
|
|
|
if count >= 12
|
|
|
|
break
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1827,13 +1836,13 @@ module ApplicationHelper
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_bid_fans_picture(obj)
|
|
|
|
def show_bid_fans_picture(obj)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
else
|
|
|
|
else
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
@ -1868,7 +1877,7 @@ module ApplicationHelper
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_project(contest)
|
|
|
|
def show_contest_project(contest)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
if contest.projects.where('is_public = 1').count == 0
|
|
|
|
if contest.projects.where('is_public = 1').count == 0
|
|
|
|
html << (content_tag "p", l(:label_no_bid_project), :class => "font_lighter")
|
|
|
|
html << (content_tag "p", l(:label_no_bid_project), :class => "font_lighter")
|
|
|
@ -1880,7 +1889,7 @@ module ApplicationHelper
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_softapplication(contest)
|
|
|
|
def show_contest_softapplication(contest)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
if contest.softapplications.where('is_public = 1').count == 0
|
|
|
|
if contest.softapplications.where('is_public = 1').count == 0
|
|
|
|
html << (content_tag "p", l(:label_no_contest_softapplication), :class => "font_lighter")
|
|
|
|
html << (content_tag "p", l(:label_no_contest_softapplication), :class => "font_lighter")
|
|
|
@ -1892,17 +1901,17 @@ module ApplicationHelper
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_contest_fans_picture(obj)
|
|
|
|
def show_contest_fans_picture(obj)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
if obj.watcher_users.count == 0
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
html << (content_tag "span", l(:label_project_no_follow))
|
|
|
|
else
|
|
|
|
else
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#display fans picture
|
|
|
|
#display fans picture
|
|
|
|
def show_more_fans?(obj)
|
|
|
|
def show_more_fans?(obj)
|
|
|
@ -1919,13 +1928,13 @@ module ApplicationHelper
|
|
|
|
html << (content_tag "span", l(:label_no_current_fans))
|
|
|
|
html << (content_tag "span", l(:label_no_current_fans))
|
|
|
|
else
|
|
|
|
else
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
obj.watcher_users.take(12).each do |user|
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# added by bai
|
|
|
|
# added by bai
|
|
|
|
def show_more_participate?(obj)
|
|
|
|
def show_more_participate?(obj)
|
|
|
|
if obj.join_in_contests.count > 12
|
|
|
|
if obj.join_in_contests.count > 12
|
|
|
|
return true
|
|
|
|
return true
|
|
|
@ -1934,18 +1943,18 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_participate_picture(obj)
|
|
|
|
def show_participate_picture(obj)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
count = 0
|
|
|
|
count = 0
|
|
|
|
if obj.join_in_contests.count == 0
|
|
|
|
if obj.join_in_contests.count == 0
|
|
|
|
html << (content_tag "span", l(:label_no_current_participate))
|
|
|
|
html << (content_tag "span", l(:label_no_current_participate))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for temp in obj.join_in_contests
|
|
|
|
for temp in obj.join_in_contests
|
|
|
|
html << (link_to image_tag(url_to_avatar(temp.user), :class => "avatar"), user_path(temp.user), :class => "avatar", :title => "#{temp.user.name}")
|
|
|
|
html << (link_to image_tag(url_to_avatar(temp.user), :class => "avatar"), user_path(temp.user), :class => "avatar", :title => "#{temp.user.name}")
|
|
|
|
count = count + 1
|
|
|
|
count = count + 1
|
|
|
|
if count >= 12
|
|
|
|
if count >= 12
|
|
|
|
break
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1954,14 +1963,14 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
|
|
# add by huang
|
|
|
|
# add by huang
|
|
|
|
def show_watcher_list(user)
|
|
|
|
def show_watcher_list(user)
|
|
|
|
html = ''
|
|
|
|
html = ''
|
|
|
|
count = 0
|
|
|
|
count = 0
|
|
|
|
for user in User.watched_by(user.id)
|
|
|
|
for user in User.watched_by(user.id)
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
|
|
|
|
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
|
|
|
|
count = count + 1
|
|
|
|
count = count + 1
|
|
|
|
if count >= 12
|
|
|
|
if count >= 12
|
|
|
|
break
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html.html_safe
|
|
|
|
html.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1979,14 +1988,14 @@ module ApplicationHelper
|
|
|
|
return true if bid.nil?
|
|
|
|
return true if bid.nil?
|
|
|
|
|
|
|
|
|
|
|
|
case bid.homework_type
|
|
|
|
case bid.homework_type
|
|
|
|
when Bid::HomeworkFile
|
|
|
|
when Bid::HomeworkFile
|
|
|
|
attaches = HomeworkAttach.where(bid_id: curb)
|
|
|
|
attaches = HomeworkAttach.where(bid_id: curb)
|
|
|
|
attaches.map(&:user_id).include? cur
|
|
|
|
attaches.map(&:user_id).include? cur
|
|
|
|
when Bid::HomeworkProject
|
|
|
|
when Bid::HomeworkProject
|
|
|
|
attaches = BidingProject.where(user_id: User.current, bid_id: bid)
|
|
|
|
attaches = BidingProject.where(user_id: User.current, bid_id: bid)
|
|
|
|
attaches.count > 0 # > 0 则有提交记录
|
|
|
|
attaches.count > 0 # > 0 则有提交记录
|
|
|
|
else
|
|
|
|
else
|
|
|
|
true
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -2048,12 +2057,12 @@ module ApplicationHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# def hadcommittedforcontest(curu)
|
|
|
|
# def hadcommittedforcontest(curu)
|
|
|
|
# message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ")
|
|
|
|
# message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ")
|
|
|
|
# message.each do |createmessage|
|
|
|
|
# message.each do |createmessage|
|
|
|
|
# if createmessage.user_id == curu
|
|
|
|
# if createmessage.user_id == curu
|
|
|
|
# return true
|
|
|
|
# return true
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
def footer_logo(ul_class=nil, li_class=nil)
|
|
|
|
def footer_logo(ul_class=nil, li_class=nil)
|
|
|
@ -2073,63 +2082,63 @@ module ApplicationHelper
|
|
|
|
|
|
|
|
|
|
|
|
def sort_homework_path(bid, sort, direction)
|
|
|
|
def sort_homework_path(bid, sort, direction)
|
|
|
|
case self.action_name
|
|
|
|
case self.action_name
|
|
|
|
when 'show_courseEx'
|
|
|
|
when 'show_courseEx'
|
|
|
|
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: 'asc')
|
|
|
|
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: 'asc')
|
|
|
|
when 'get_not_batch_homework'
|
|
|
|
when 'get_not_batch_homework'
|
|
|
|
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
when 'get_batch_homeworks'
|
|
|
|
when 'get_batch_homeworks'
|
|
|
|
get_batch_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
get_batch_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
when 'get_homeworks'
|
|
|
|
when 'get_homeworks'
|
|
|
|
get_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
get_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
'#'
|
|
|
|
'#'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def anonymous_comment_link(bid, course)
|
|
|
|
def anonymous_comment_link(bid, course)
|
|
|
|
link = case bid.comment_status
|
|
|
|
link = case bid.comment_status
|
|
|
|
when 0
|
|
|
|
when 0
|
|
|
|
confirm_info = "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n"
|
|
|
|
confirm_info = "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n"
|
|
|
|
confirm_info += anonymous_comment_notice(bid,course)
|
|
|
|
confirm_info += anonymous_comment_notice(bid,course)
|
|
|
|
confirm_info += '是否确定开启匿评?'
|
|
|
|
confirm_info += '是否确定开启匿评?'
|
|
|
|
link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
|
|
|
|
link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
|
|
|
|
when 1
|
|
|
|
when 1
|
|
|
|
confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作业列表\n"
|
|
|
|
confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作业列表\n"
|
|
|
|
confirm_info += anonymous_comment_notice(bid,course)
|
|
|
|
confirm_info += anonymous_comment_notice(bid,course)
|
|
|
|
confirm_info += '是否确定关闭匿评?'
|
|
|
|
confirm_info += '是否确定关闭匿评?'
|
|
|
|
link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
|
|
|
|
link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
|
|
|
|
when 2
|
|
|
|
when 2
|
|
|
|
'匿评结束'
|
|
|
|
'匿评结束'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
content_tag('span', link, id: "#{bid.id}_anonymous_comment")
|
|
|
|
content_tag('span', link, id: "#{bid.id}_anonymous_comment")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def anonymous_comment_notice(bid, course)
|
|
|
|
def anonymous_comment_notice(bid, course)
|
|
|
|
case bid.comment_status
|
|
|
|
case bid.comment_status
|
|
|
|
when 0
|
|
|
|
when 0
|
|
|
|
@student_size ||= searchStudent(course).size
|
|
|
|
@student_size ||= searchStudent(course).size
|
|
|
|
@homework_size = bid.homeworks.size
|
|
|
|
@homework_size = bid.homeworks.size
|
|
|
|
percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
|
|
|
|
percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
|
|
|
|
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
|
|
|
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
|
|
|
when 1
|
|
|
|
when 1
|
|
|
|
@homework_evaluations = 0
|
|
|
|
@homework_evaluations = 0
|
|
|
|
bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
|
|
|
|
bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
|
|
|
|
teachers = "("
|
|
|
|
teachers = "("
|
|
|
|
teacher_members = searchTeacherAndAssistant(course)
|
|
|
|
teacher_members = searchTeacherAndAssistant(course)
|
|
|
|
teacher_members.each do |member|
|
|
|
|
teacher_members.each do |member|
|
|
|
|
if member == teacher_members.last
|
|
|
|
if member == teacher_members.last
|
|
|
|
teachers += member.user_id.to_s + ")"
|
|
|
|
teachers += member.user_id.to_s + ")"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
teachers += member.user_id.to_s + ","
|
|
|
|
teachers += member.user_id.to_s + ","
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@has_evaluations = 0
|
|
|
|
@has_evaluations = 0
|
|
|
|
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
|
|
|
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
|
|
|
|
|
|
|
|
|
|
|
percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
|
|
|
|
percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
|
|
|
|
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
|
|
|
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
confirm_info
|
|
|
|
confirm_info
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_technical_title user
|
|
|
|
def get_technical_title user
|
|
|
|