commit
79d162ecca
@ -1,463 +1,463 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module IssuesHelper
|
module IssuesHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def issue_list(issues, &block)
|
def issue_list(issues, &block)
|
||||||
ancestors = []
|
ancestors = []
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
|
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
end
|
end
|
||||||
yield issue, ancestors.size
|
yield issue, ancestors.size
|
||||||
ancestors << issue unless issue.leaf?
|
ancestors << issue unless issue.leaf?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders a HTML/CSS tooltip
|
# Renders a HTML/CSS tooltip
|
||||||
#
|
#
|
||||||
# To use, a trigger div is needed. This is a div with the class of "tooltip"
|
# To use, a trigger div is needed. This is a div with the class of "tooltip"
|
||||||
# that contains this method wrapped in a span with the class of "tip"
|
# that contains this method wrapped in a span with the class of "tip"
|
||||||
#
|
#
|
||||||
# <div class="tooltip"><%= link_to_issue(issue) %>
|
# <div class="tooltip"><%= link_to_issue(issue) %>
|
||||||
# <span class="tip"><%= render_issue_tooltip(issue) %></span>
|
# <span class="tip"><%= render_issue_tooltip(issue) %></span>
|
||||||
# </div>
|
# </div>
|
||||||
#
|
#
|
||||||
def render_issue_tooltip(issue)
|
def render_issue_tooltip(issue)
|
||||||
@cached_label_status ||= l(:field_status)
|
@cached_label_status ||= l(:field_status)
|
||||||
@cached_label_start_date ||= l(:field_start_date)
|
@cached_label_start_date ||= l(:field_start_date)
|
||||||
@cached_label_due_date ||= l(:field_due_date)
|
@cached_label_due_date ||= l(:field_due_date)
|
||||||
@cached_label_assigned_to ||= l(:field_assigned_to)
|
@cached_label_assigned_to ||= l(:field_assigned_to)
|
||||||
@cached_label_priority ||= l(:field_priority)
|
@cached_label_priority ||= l(:field_priority)
|
||||||
@cached_label_project ||= l(:field_project)
|
@cached_label_project ||= l(:field_project)
|
||||||
|
|
||||||
link_to_issue(issue) + "<br /><br />".html_safe +
|
link_to_issue(issue) + "<br /><br />".html_safe +
|
||||||
"<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
|
"<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
|
"<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
|
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
|
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
|
"<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
|
"<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_heading(issue)
|
def issue_heading(issue)
|
||||||
#h("#{issue.tracker} ##{issue.id}")
|
#h("#{issue.tracker} ##{issue.id}")
|
||||||
# h("#{issue.tracker} #{issue.source_from}")
|
# h("#{issue.tracker} #{issue.source_from}")
|
||||||
s = ''
|
s = ''
|
||||||
s << link_to(@issue.project.name, project_issues_path(@issue.project), :class => "pro_page_top")
|
s << link_to(@issue.project.name, project_issues_path(@issue.project), :class => "pro_page_top")
|
||||||
s << " > "
|
s << " > "
|
||||||
s << link_to("#" + @issue.project_index, project_issues_path(@issue.project), :class => "pro_page_top")
|
s << link_to("#" + @issue.project_index, project_issues_path(@issue.project), :class => "pro_page_top")
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
#获取跟踪类型及样式
|
#获取跟踪类型及样式
|
||||||
def get_issue_type(value)
|
def get_issue_type(value)
|
||||||
issuetype = []
|
issuetype = []
|
||||||
if value == "缺陷" || value == 1
|
if value == "缺陷" || value == 1
|
||||||
issuetype << "issues fl"
|
issuetype << "issues fl"
|
||||||
issuetype << "缺陷"
|
issuetype << "缺陷"
|
||||||
elsif value == "任务" || value == 4
|
elsif value == "任务" || value == 4
|
||||||
issuetype << "duty fl"
|
issuetype << "duty fl"
|
||||||
issuetype << "任务"
|
issuetype << "任务"
|
||||||
elsif value == "支持" || value == 3
|
elsif value == "支持" || value == 3
|
||||||
issuetype << "support fl"
|
issuetype << "support fl"
|
||||||
issuetype << "支持"
|
issuetype << "支持"
|
||||||
elsif value == "功能" || value == 2
|
elsif value == "功能" || value == 2
|
||||||
issuetype << "function fl"
|
issuetype << "issues-function fl"
|
||||||
issuetype << "功能"
|
issuetype << "功能"
|
||||||
else
|
else
|
||||||
issuetype << "weekly fl"
|
issuetype << "weekly fl"
|
||||||
issuetype << "周报"
|
issuetype << "周报"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取优先级样式 value值1 2 低
|
# 获取优先级样式 value值1 2 低
|
||||||
def get_issue_priority(value)
|
def get_issue_priority(value)
|
||||||
issuetype = []
|
issuetype = []
|
||||||
if value == "紧急" || value == 4
|
if value == "紧急" || value == 4
|
||||||
issuetype << "red_btn_cir ml10"
|
issuetype << "red_btn_cir ml10"
|
||||||
issuetype << "紧急"
|
issuetype << "紧急"
|
||||||
elsif value == "正常" || value == 2
|
elsif value == "正常" || value == 2
|
||||||
issuetype << "green_btn_cir ml10"
|
issuetype << "green_btn_cir ml10"
|
||||||
issuetype << "正常"
|
issuetype << "正常"
|
||||||
elsif value == "高" || value == 3
|
elsif value == "高" || value == 3
|
||||||
issuetype << "orange_btn_cir ml10"
|
issuetype << "orange_btn_cir ml10"
|
||||||
issuetype << "高"
|
issuetype << "高"
|
||||||
elsif value == "低" || value == 1
|
elsif value == "低" || value == 1
|
||||||
issuetype << "bgreen_btn_cir ml10"
|
issuetype << "bgreen_btn_cir ml10"
|
||||||
issuetype << "低"
|
issuetype << "低"
|
||||||
else
|
else
|
||||||
issuetype << "red_btn_cir ml10"
|
issuetype << "red_btn_cir ml10"
|
||||||
issuetype << "立刻"
|
issuetype << "立刻"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def principals_options_for_isuue_list(project)
|
def principals_options_for_isuue_list(project)
|
||||||
if User.current.member_of?(project)
|
if User.current.member_of?(project)
|
||||||
project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0])
|
project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0])
|
||||||
else
|
else
|
||||||
project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["指派给", 0])
|
project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["指派给", 0])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_issue_subject_with_tree(issue)
|
def render_issue_subject_with_tree(issue)
|
||||||
s = ''
|
s = ''
|
||||||
ancestors = issue.root? ? [] : issue.ancestors.visible.all
|
ancestors = issue.root? ? [] : issue.ancestors.visible.all
|
||||||
ancestors.each do |ancestor|
|
ancestors.each do |ancestor|
|
||||||
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
|
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
|
||||||
end
|
end
|
||||||
s << '<div style="word-wrap: break-word; word-break: normal;">'
|
s << '<div style="word-wrap: break-word; word-break: normal;">'
|
||||||
subject = h(issue.subject)
|
subject = h(issue.subject)
|
||||||
if issue.is_private?
|
if issue.is_private?
|
||||||
subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
|
subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
|
||||||
end
|
end
|
||||||
s << content_tag('h3', subject)
|
s << content_tag('h3', subject)
|
||||||
s << '</div>' * (ancestors.size + 1)
|
s << '</div>' * (ancestors.size + 1)
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_descendants_tree(issue)
|
def render_descendants_tree(issue)
|
||||||
s = '<form><table class="list issues">'
|
s = '<form><table class="list issues">'
|
||||||
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
|
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
|
||||||
css = "issue issue-#{child.id} hascontextmenu"
|
css = "issue issue-#{child.id} hascontextmenu"
|
||||||
css << " idnt idnt-#{level}" if level > 0
|
css << " idnt idnt-#{level}" if level > 0
|
||||||
s << content_tag('tr',
|
s << content_tag('tr',
|
||||||
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
|
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
|
||||||
content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') +
|
content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') +
|
||||||
content_tag('td', h(child.status)) +
|
content_tag('td', h(child.status)) +
|
||||||
content_tag('td', link_to_user(child.assigned_to)) +
|
content_tag('td', link_to_user(child.assigned_to)) +
|
||||||
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
|
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
|
||||||
:class => css)
|
:class => css)
|
||||||
end
|
end
|
||||||
s << '</table></form>'
|
s << '</table></form>'
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a link for adding a new subtask to the given issue
|
# Returns a link for adding a new subtask to the given issue
|
||||||
def link_to_new_subtask(issue)
|
def link_to_new_subtask(issue)
|
||||||
attrs = {
|
attrs = {
|
||||||
:tracker_id => issue.tracker,
|
:tracker_id => issue.tracker,
|
||||||
:parent_issue_id => issue
|
:parent_issue_id => issue
|
||||||
}
|
}
|
||||||
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
|
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
|
||||||
end
|
end
|
||||||
|
|
||||||
class IssueFieldsRows
|
class IssueFieldsRows
|
||||||
include ActionView::Helpers::TagHelper
|
include ActionView::Helpers::TagHelper
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@left = []
|
@left = []
|
||||||
@right = []
|
@right = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def left(*args)
|
def left(*args)
|
||||||
args.any? ? @left << cells(*args) : @left
|
args.any? ? @left << cells(*args) : @left
|
||||||
end
|
end
|
||||||
|
|
||||||
def right(*args)
|
def right(*args)
|
||||||
args.any? ? @right << cells(*args) : @right
|
args.any? ? @right << cells(*args) : @right
|
||||||
end
|
end
|
||||||
|
|
||||||
def size
|
def size
|
||||||
@left.size > @right.size ? @left.size : @right.size
|
@left.size > @right.size ? @left.size : @right.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_html
|
def to_html
|
||||||
html = ''.html_safe
|
html = ''.html_safe
|
||||||
blank = content_tag('th', '') + content_tag('td', '')
|
blank = content_tag('th', '') + content_tag('td', '')
|
||||||
size.times do |i|
|
size.times do |i|
|
||||||
left = @left[i] || blank
|
left = @left[i] || blank
|
||||||
right = @right[i] || blank
|
right = @right[i] || blank
|
||||||
html << content_tag('tr', left + right)
|
html << content_tag('tr', left + right)
|
||||||
end
|
end
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
def cells(label, text, options={})
|
def cells(label, text, options={})
|
||||||
content_tag('th', "#{label}:", options) + content_tag('td', text, options)
|
content_tag('th', "#{label}:", options) + content_tag('td', text, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_fields_rows
|
def issue_fields_rows
|
||||||
r = IssueFieldsRows.new
|
r = IssueFieldsRows.new
|
||||||
yield r
|
yield r
|
||||||
r.to_html
|
r.to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_custom_fields_rows(issue)
|
def render_custom_fields_rows(issue)
|
||||||
return if issue.custom_field_values.empty?
|
return if issue.custom_field_values.empty?
|
||||||
ordered_values = []
|
ordered_values = []
|
||||||
half = (issue.custom_field_values.size / 2.0).ceil
|
half = (issue.custom_field_values.size / 2.0).ceil
|
||||||
half.times do |i|
|
half.times do |i|
|
||||||
ordered_values << issue.custom_field_values[i]
|
ordered_values << issue.custom_field_values[i]
|
||||||
ordered_values << issue.custom_field_values[i + half]
|
ordered_values << issue.custom_field_values[i + half]
|
||||||
end
|
end
|
||||||
s = "<tr>\n"
|
s = "<tr>\n"
|
||||||
n = 0
|
n = 0
|
||||||
ordered_values.compact.each do |value|
|
ordered_values.compact.each do |value|
|
||||||
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
|
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
|
||||||
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
|
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
|
||||||
n += 1
|
n += 1
|
||||||
end
|
end
|
||||||
s << "</tr>\n"
|
s << "</tr>\n"
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def issues_destroy_confirmation_message(issues)
|
def issues_destroy_confirmation_message(issues)
|
||||||
issues = [issues] unless issues.is_a?(Array)
|
issues = [issues] unless issues.is_a?(Array)
|
||||||
message = l(:text_issues_destroy_confirmation)
|
message = l(:text_issues_destroy_confirmation)
|
||||||
descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
|
descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
|
||||||
if descendant_count > 0
|
if descendant_count > 0
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
next if issue.root?
|
next if issue.root?
|
||||||
issues.each do |other_issue|
|
issues.each do |other_issue|
|
||||||
descendant_count -= 1 if issue.is_descendant_of?(other_issue)
|
descendant_count -= 1 if issue.is_descendant_of?(other_issue)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if descendant_count > 0
|
if descendant_count > 0
|
||||||
message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
|
message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
def sidebar_queries
|
def sidebar_queries
|
||||||
unless @sidebar_queries
|
unless @sidebar_queries
|
||||||
@sidebar_queries = IssueQuery.visible.all(
|
@sidebar_queries = IssueQuery.visible.all(
|
||||||
:order => "#{Query.table_name}.name ASC",
|
:order => "#{Query.table_name}.name ASC",
|
||||||
# Project specific queries and global queries
|
# Project specific queries and global queries
|
||||||
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@sidebar_queries
|
@sidebar_queries
|
||||||
end
|
end
|
||||||
|
|
||||||
def query_links(title, queries)
|
def query_links(title, queries)
|
||||||
# links to #index on issues/show
|
# links to #index on issues/show
|
||||||
url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
|
url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
|
||||||
|
|
||||||
content_tag('h3', h(title)) +
|
content_tag('h3', h(title)) +
|
||||||
queries.collect {|query|
|
queries.collect {|query|
|
||||||
css = 'query'
|
css = 'query'
|
||||||
css << ' selected' if query == @query
|
css << ' selected' if query == @query
|
||||||
link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
|
link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
|
||||||
}.join('<br />').html_safe
|
}.join('<br />').html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_sidebar_queries
|
def render_sidebar_queries
|
||||||
out = ''.html_safe
|
out = ''.html_safe
|
||||||
queries = sidebar_queries.select {|q| !q.is_public?}
|
queries = sidebar_queries.select {|q| !q.is_public?}
|
||||||
out << query_links(l(:label_my_queries), queries) if queries.any?
|
out << query_links(l(:label_my_queries), queries) if queries.any?
|
||||||
queries = sidebar_queries.select {|q| q.is_public?}
|
queries = sidebar_queries.select {|q| q.is_public?}
|
||||||
out << query_links(l(:label_query_plural), queries) if queries.any?
|
out << query_links(l(:label_query_plural), queries) if queries.any?
|
||||||
out
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the textual representation of a journal details
|
# Returns the textual representation of a journal details
|
||||||
# as an array of strings
|
# as an array of strings
|
||||||
def details_to_strings(details, no_html=false, options={})
|
def details_to_strings(details, no_html=false, options={})
|
||||||
options[:only_path] = (options[:only_path] == false ? false : true)
|
options[:only_path] = (options[:only_path] == false ? false : true)
|
||||||
options[:token] = options[:token] if options[:token]
|
options[:token] = options[:token] if options[:token]
|
||||||
strings = []
|
strings = []
|
||||||
values_by_field = {}
|
values_by_field = {}
|
||||||
details.each do |detail|
|
details.each do |detail|
|
||||||
|
|
||||||
if detail.property == 'cf'
|
if detail.property == 'cf'
|
||||||
field_id = detail.prop_key
|
field_id = detail.prop_key
|
||||||
field = CustomField.find_by_id(field_id)
|
field = CustomField.find_by_id(field_id)
|
||||||
if field && field.multiple?
|
if field && field.multiple?
|
||||||
values_by_field[field_id] ||= {:added => [], :deleted => []}
|
values_by_field[field_id] ||= {:added => [], :deleted => []}
|
||||||
if detail.old_value
|
if detail.old_value
|
||||||
values_by_field[field_id][:deleted] << detail.old_value
|
values_by_field[field_id][:deleted] << detail.old_value
|
||||||
end
|
end
|
||||||
if detail.value
|
if detail.value
|
||||||
values_by_field[field_id][:added] << detail.value
|
values_by_field[field_id][:added] << detail.value
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
strings << show_detail(detail, no_html, options)
|
strings << show_detail(detail, no_html, options)
|
||||||
|
|
||||||
end
|
end
|
||||||
values_by_field.each do |field_id, changes|
|
values_by_field.each do |field_id, changes|
|
||||||
detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
|
detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
|
||||||
if changes[:added].any?
|
if changes[:added].any?
|
||||||
detail.value = changes[:added]
|
detail.value = changes[:added]
|
||||||
strings << show_detail(detail, no_html, options)
|
strings << show_detail(detail, no_html, options)
|
||||||
elsif changes[:deleted].any?
|
elsif changes[:deleted].any?
|
||||||
detail.old_value = changes[:deleted]
|
detail.old_value = changes[:deleted]
|
||||||
strings << show_detail(detail, no_html, options)
|
strings << show_detail(detail, no_html, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
strings
|
strings
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the textual representation of a single journal detail
|
# Returns the textual representation of a single journal detail
|
||||||
def show_detail(detail, no_html=false, options={})
|
def show_detail(detail, no_html=false, options={})
|
||||||
multiple = false
|
multiple = false
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr'
|
when 'attr'
|
||||||
field = detail.prop_key.to_s.gsub(/\_id$/, "")
|
field = detail.prop_key.to_s.gsub(/\_id$/, "")
|
||||||
label = l(("field_" + field).to_sym)
|
label = l(("field_" + field).to_sym)
|
||||||
case detail.prop_key
|
case detail.prop_key
|
||||||
when 'due_date', 'start_date'
|
when 'due_date', 'start_date'
|
||||||
value = format_date(detail.value.to_date) if detail.value
|
value = format_date(detail.value.to_date) if detail.value
|
||||||
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
||||||
|
|
||||||
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
|
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
|
||||||
'priority_id', 'category_id', 'fixed_version_id'
|
'priority_id', 'category_id', 'fixed_version_id'
|
||||||
value = find_name_by_reflection(field, detail.value)
|
value = find_name_by_reflection(field, detail.value)
|
||||||
old_value = find_name_by_reflection(field, detail.old_value)
|
old_value = find_name_by_reflection(field, detail.old_value)
|
||||||
|
|
||||||
when 'estimated_hours'
|
when 'estimated_hours'
|
||||||
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
|
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
|
||||||
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
|
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
|
||||||
|
|
||||||
when 'parent_id'
|
when 'parent_id'
|
||||||
label = l(:field_parent_issue)
|
label = l(:field_parent_issue)
|
||||||
value = "##{detail.value}" unless detail.value.blank?
|
value = "##{detail.value}" unless detail.value.blank?
|
||||||
old_value = "##{detail.old_value}" unless detail.old_value.blank?
|
old_value = "##{detail.old_value}" unless detail.old_value.blank?
|
||||||
|
|
||||||
when 'is_private'
|
when 'is_private'
|
||||||
value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
|
value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
|
||||||
old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
|
old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
|
||||||
end
|
end
|
||||||
when 'cf'
|
when 'cf'
|
||||||
custom_field = CustomField.find_by_id(detail.prop_key)
|
custom_field = CustomField.find_by_id(detail.prop_key)
|
||||||
if custom_field
|
if custom_field
|
||||||
multiple = custom_field.multiple?
|
multiple = custom_field.multiple?
|
||||||
label = custom_field.name
|
label = custom_field.name
|
||||||
value = format_value(detail.value, custom_field.field_format) if detail.value
|
value = format_value(detail.value, custom_field.field_format) if detail.value
|
||||||
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
||||||
end
|
end
|
||||||
when 'attachment'
|
when 'attachment'
|
||||||
label = l(:label_attachment)
|
label = l(:label_attachment)
|
||||||
end
|
end
|
||||||
call_hook(:helper_issues_show_detail_after_setting,
|
call_hook(:helper_issues_show_detail_after_setting,
|
||||||
{:detail => detail, :label => label, :value => value, :old_value => old_value })
|
{:detail => detail, :label => label, :value => value, :old_value => old_value })
|
||||||
|
|
||||||
label ||= detail.prop_key
|
label ||= detail.prop_key
|
||||||
value ||= detail.value
|
value ||= detail.value
|
||||||
old_value ||= detail.old_value
|
old_value ||= detail.old_value
|
||||||
|
|
||||||
unless no_html
|
unless no_html
|
||||||
label = content_tag('strong', label)
|
label = content_tag('strong', label)
|
||||||
old_value = content_tag("i", h(old_value)) if detail.old_value
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||||
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
||||||
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||||
# Link to the attachment if it has not been removed
|
# Link to the attachment if it has not been removed
|
||||||
if options[:token].nil?
|
if options[:token].nil?
|
||||||
value = atta.filename
|
value = atta.filename
|
||||||
else
|
else
|
||||||
value = atta.filename
|
value = atta.filename
|
||||||
end
|
end
|
||||||
# 放大镜搜索功能
|
# 放大镜搜索功能
|
||||||
# if options[:only_path] != false && atta.is_text?
|
# if options[:only_path] != false && atta.is_text?
|
||||||
# value += link_to(
|
# value += link_to(
|
||||||
# image_tag('magnifier.png'),
|
# image_tag('magnifier.png'),
|
||||||
# :controller => 'attachments', :action => 'show',
|
# :controller => 'attachments', :action => 'show',
|
||||||
# :id => atta, :filename => atta.filename
|
# :id => atta, :filename => atta.filename
|
||||||
# )
|
# )
|
||||||
# end
|
# end
|
||||||
else
|
else
|
||||||
value = content_tag("i", h(value)) if value
|
value = content_tag("i", h(value)) if value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# 缺陷更新结果在消息中显示样式
|
# 缺陷更新结果在消息中显示样式
|
||||||
if no_html == "message"
|
if no_html == "message"
|
||||||
label = content_tag(:span, label, :class => "issue_update_message")
|
label = content_tag(:span, label, :class => "issue_update_message")
|
||||||
old_value = content_tag("span", h(old_value)) if detail.old_value
|
old_value = content_tag("span", h(old_value)) if detail.old_value
|
||||||
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
||||||
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||||
# Link to the attachment if it has not been removed
|
# Link to the attachment if it has not been removed
|
||||||
if options[:token].nil?
|
if options[:token].nil?
|
||||||
value = atta.filename
|
value = atta.filename
|
||||||
else
|
else
|
||||||
value = atta.filename
|
value = atta.filename
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
value = content_tag(:span, h(value), :class => "issue_update_message_value") if value
|
value = content_tag(:span, h(value), :class => "issue_update_message_value") if value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if detail.property == 'attr' && detail.prop_key == 'description'
|
if detail.property == 'attr' && detail.prop_key == 'description'
|
||||||
s = l(:text_journal_changed_no_detail, :label => label)
|
s = l(:text_journal_changed_no_detail, :label => label)
|
||||||
unless no_html
|
unless no_html
|
||||||
diff_link = link_to l(:label_diff),
|
diff_link = link_to l(:label_diff),
|
||||||
{:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
{:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
||||||
:detail_id => detail.id, :only_path => options[:only_path]},
|
:detail_id => detail.id, :only_path => options[:only_path]},
|
||||||
:title => l(:label_view_diff)
|
:title => l(:label_view_diff)
|
||||||
s << " (#{ diff_link })"
|
s << " (#{ diff_link })"
|
||||||
end
|
end
|
||||||
s.html_safe
|
s.html_safe
|
||||||
elsif detail.value.present?
|
elsif detail.value.present?
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr', 'cf'
|
when 'attr', 'cf'
|
||||||
if detail.old_value.present?
|
if detail.old_value.present?
|
||||||
l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
|
l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
|
||||||
elsif multiple
|
elsif multiple
|
||||||
l(:text_journal_added, :label => label, :value => value).html_safe
|
l(:text_journal_added, :label => label, :value => value).html_safe
|
||||||
else
|
else
|
||||||
l(:text_journal_set_to, :label => label, :value => value).html_safe
|
l(:text_journal_set_to, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
when 'attachment'
|
when 'attachment'
|
||||||
l(:text_journal_added, :label => label, :value => value).html_safe
|
l(:text_journal_added, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
l(:text_journal_deleted, :label => label, :old => old_value).html_safe
|
l(:text_journal_deleted, :label => label, :old => old_value).html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find the name of an associated record stored in the field attribute
|
# Find the name of an associated record stored in the field attribute
|
||||||
def find_name_by_reflection(field, id)
|
def find_name_by_reflection(field, id)
|
||||||
unless id.present?
|
unless id.present?
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
association = Issue.reflect_on_association(field.to_sym)
|
association = Issue.reflect_on_association(field.to_sym)
|
||||||
if association
|
if association
|
||||||
record = association.class_name.constantize.find_by_id(id)
|
record = association.class_name.constantize.find_by_id(id)
|
||||||
if record
|
if record
|
||||||
record.name.force_encoding('UTF-8') if record.name.respond_to?(:force_encoding)
|
record.name.force_encoding('UTF-8') if record.name.respond_to?(:force_encoding)
|
||||||
return record.name
|
return record.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders issue children recursively
|
# Renders issue children recursively
|
||||||
def render_api_issue_children(issue, api)
|
def render_api_issue_children(issue, api)
|
||||||
return if issue.leaf?
|
return if issue.leaf?
|
||||||
api.array :children do
|
api.array :children do
|
||||||
issue.children.each do |child|
|
issue.children.each do |child|
|
||||||
api.issue(:id => child.id) do
|
api.issue(:id => child.id) do
|
||||||
api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
|
api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
|
||||||
api.subject child.subject
|
api.subject child.subject
|
||||||
render_api_issue_children(child, api)
|
render_api_issue_children(child, api)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# this method is used to get all projects that tagged one tag
|
# this method is used to get all projects that tagged one tag
|
||||||
# added by william
|
# added by william
|
||||||
def get_issues_by_tag(tag_name)
|
def get_issues_by_tag(tag_name)
|
||||||
Issue.tagged_with(tag_name).order('updated_on desc')
|
Issue.tagged_with(tag_name).order('updated_on desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
class Forward < ActiveRecord::Base
|
||||||
|
validates_presence_of :from_id, :from_type, :to_id, :to_type
|
||||||
|
belongs_to :from, :polymorphic => true
|
||||||
|
end
|
@ -0,0 +1,7 @@
|
|||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li><%= link_to '用户', {:action => 'latest_login_users'}, class: "#{current_page?(latest_login_users_path)? 'selected' : nil }" %></li>
|
||||||
|
<li><%= link_to '老师', {:action => 'latest_login_teachers'}, class: "#{current_page?(latest_login_teachers_path)? 'selected' : nil }" %></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
@ -0,0 +1,84 @@
|
|||||||
|
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
|
||||||
|
<h3>
|
||||||
|
<%=l(:label_latest_login_user_list)%>
|
||||||
|
</h3>
|
||||||
|
<%= render 'tab_users' %>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
最近登录老师列表
|
||||||
|
</h3>
|
||||||
|
<%= form_tag({}, :method => :get) do %>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_filter_plural) %>
|
||||||
|
</legend>
|
||||||
|
<label style="float:left">开始日期:</label>
|
||||||
|
<%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
|
||||||
|
<%= calendar_for('startdate')%><span style="float: left "> </span>
|
||||||
|
<label style="float:left">结束日期:</label>
|
||||||
|
<%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
|
||||||
|
<%= calendar_for('enddate')%>
|
||||||
|
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
|
||||||
|
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_teachers'}, :class => 'icon icon-reload' %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="autoscroll">
|
||||||
|
<table class="list" style="width: 100%;table-layout: fixed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 30px;">
|
||||||
|
序号
|
||||||
|
</th>
|
||||||
|
<th style="width: 70px;">
|
||||||
|
登录时间
|
||||||
|
</th>
|
||||||
|
<th style="width: 30px;">
|
||||||
|
用户id
|
||||||
|
</th>
|
||||||
|
<th style="width: 50px;">
|
||||||
|
用户姓名
|
||||||
|
</th>
|
||||||
|
<th style="width: 50px;">
|
||||||
|
用户登录名
|
||||||
|
</th>
|
||||||
|
<th style="width: 50px;">
|
||||||
|
用户身份
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @count=@page * 30 %>
|
||||||
|
<% for teacher in @teachers do %>
|
||||||
|
<tr>
|
||||||
|
<% @count +=1 %>
|
||||||
|
<td align="center">
|
||||||
|
<%=@count %>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<%=format_time(teacher.last_login_on) %>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<%=teacher.id %>
|
||||||
|
</td>
|
||||||
|
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if teacher.try(:realname) == ' '%><%= teacher.login%><% else %><%=teacher.try(:realname) %><% end %>'>
|
||||||
|
<% if teacher.try(:realname) == ' '%>
|
||||||
|
<%= link_to(teacher.login, user_path(teacher)) %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to(teacher.try(:realname), user_path(teacher)) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<%=link_to(teacher.login, user_path(teacher)) %>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
老师
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="pagination">
|
||||||
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||||
|
</div>
|
@ -0,0 +1,55 @@
|
|||||||
|
<script src="/javascripts/i18n/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
|
||||||
|
<span class="uploadText mb10" style="margin-top: -20px;">发布设置</span>
|
||||||
|
<!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose"></a></div>-->
|
||||||
|
<%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
|
||||||
|
<div class="mb10">
|
||||||
|
<label class="fl c_dark f14" style="margin-top: 4px;">延迟发布:</label>
|
||||||
|
<div class="calendar_div fl">
|
||||||
|
<input type="text" name="publish_time" id="attachment_publish_time" placeholder="发布日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%=@file.publish_time %>">
|
||||||
|
<%#= calendar_for('attachment_publish_time')%>
|
||||||
|
</div>
|
||||||
|
<span class="fl c_red" style="margin-top: 4px;" id="publish_time_notice"></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<!--<div class="mt15"> <span class="f14 fontGrey3 mr10">延迟发布:</span>
|
||||||
|
<input type="text" name="" placeholder="请输入0-50数值" class="markInput" />
|
||||||
|
</div>-->
|
||||||
|
<div>
|
||||||
|
<div class="courseSendSubmit"><a href="javascript:void(0);" onclick="submit_republish_file()" class="sendSourceText" id="submit_file">确定</a></div>
|
||||||
|
<div class="courseSendCancel"><a href="javascript:void(0);" onclick="hideModal()" class="sendSourceText linkGrey6">取消</a></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<script>
|
||||||
|
function regex_publish_time()
|
||||||
|
{
|
||||||
|
var myDate = new Date();
|
||||||
|
if($.trim($("#attachment_publish_time").val()) == "")
|
||||||
|
{
|
||||||
|
$("#publish_time_notice").text("发布日期不能为空");
|
||||||
|
return false;
|
||||||
|
} else{
|
||||||
|
var publish_time = Date.parse($("#attachment_publish_time").val());
|
||||||
|
if(Date.parse(formate_date(myDate)) > publish_time)
|
||||||
|
{
|
||||||
|
$("#publish_time_notice").text("发布日期不能小于当前日期");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#publish_time_notice").text("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function submit_republish_file()
|
||||||
|
{
|
||||||
|
if(regex_publish_time()) {
|
||||||
|
$('#submit_file').parent().parent().submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(function(){
|
||||||
|
var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
|
||||||
|
$('#attachment_publish_time').datepicker(datepickerOptions);
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,77 @@
|
|||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<div class="resources mt10"><!--资源库内容开始--->
|
||||||
|
<div class="homepagePostBrief">
|
||||||
|
<div class="homepagePostPortrait">
|
||||||
|
<%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
|
||||||
|
</div>
|
||||||
|
<div class="homepagePostDes">
|
||||||
|
<div class="homepagePostTitle break_word mt-4">
|
||||||
|
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||||
|
download_named_attachment_path(file.id, file.filename),
|
||||||
|
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
|
||||||
|
<%= file_preview_eye(file, class: 'preview') %>
|
||||||
|
<span id="image_private_<%= file.id%>">
|
||||||
|
<% if file.is_public? == false%>
|
||||||
|
<span class="img_private ml5">私有</span>
|
||||||
|
<%end %>
|
||||||
|
</span>
|
||||||
|
<% if file.is_publish == 0 %>
|
||||||
|
<span class="grey_homework_btn_cir ml5"><%=file.publish_time %> 0点发布</span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="mt5">
|
||||||
|
<span class="fontGrey2 mr15 fl">上传时间:<%= format_time(file.created_on)%></span>
|
||||||
|
<% if file.tag_list.length > 0%>
|
||||||
|
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
|
||||||
|
<% end %>
|
||||||
|
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
|
||||||
|
<p class="fl ml15 fontGrey2">下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="tag_h">
|
||||||
|
<!-- container_type = 1 代表是课程里的资源 -->
|
||||||
|
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||||
|
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||||
|
</div>
|
||||||
|
<div class="homepagePostSetting">
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li class="homepagePostSettingIcon">
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
|
||||||
|
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
|
||||||
|
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
|
||||||
|
<ul class="homepagePostSettiongText">
|
||||||
|
|
||||||
|
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
|
||||||
|
<li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li>
|
||||||
|
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
|
||||||
|
<% if @course.is_public? %>
|
||||||
|
<li>
|
||||||
|
<span id="is_public_<%= file.id %>">
|
||||||
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<%end%>
|
||||||
|
<li>
|
||||||
|
<%= link_to( '删除资源', attachment_path(file),
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<%else%>
|
||||||
|
<ul class="resourceSendO">
|
||||||
|
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,6 @@
|
|||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/hidden_file',:locals => {:course => @course,:course_attachment_type => 1}) %>');
|
||||||
|
showModal('ajax-modal', '311px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal()' style='margin-left: 280px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
|
||||||
|
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||||
|
$('#ajax-modal').parent().addClass("popbox_polls");
|
@ -0,0 +1,2 @@
|
|||||||
|
hideModal();
|
||||||
|
$("#resource_detail_<%=@file.id %>").html("<%= escape_javascript(render :partial=>'files/resource_detail',:locals => {:file => @file}) %>")
|
@ -1,2 +1,3 @@
|
|||||||
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
|
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
|
||||||
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
|
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
|
||||||
|
$("#attachment_count").html("<%= @result.count %>");
|
@ -0,0 +1,6 @@
|
|||||||
|
$("#ajax-modal").html("<%=escape_javascript(render :partial => 'alert_open_student_works') %>");
|
||||||
|
showModal('ajax-modal', '500px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||||
|
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||||
|
$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9");
|
@ -0,0 +1,7 @@
|
|||||||
|
<% if @user_activity_id.to_i == -1 %>
|
||||||
|
$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>");
|
||||||
|
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
|
||||||
|
<% else %>
|
||||||
|
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>");
|
||||||
|
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
|
||||||
|
<% end %>
|
@ -1,7 +1,7 @@
|
|||||||
<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id),
|
<%= form_tag( url_for(:controller => 'users', :action => 'resource_search', :id => user.id),
|
||||||
:remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
|
:remote => true , :method => 'get', :class => 'resourcesSearchloadBox mt10', :id => 'resource_search_form') do %>
|
||||||
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" />
|
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" />
|
||||||
<%= hidden_field_tag(:type,type.nil? ? 1 : type) %>
|
<%= hidden_field_tag(:type,type.nil? ? 1 : type) %>
|
||||||
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
|
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %>
|
||||||
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
||||||
<% end %>
|
<% end %>
|
@ -1,27 +1,28 @@
|
|||||||
|
|
||||||
<% if attachments.nil? || attachments.empty? %>
|
<% if attachments.nil? || attachments.empty? %>
|
||||||
<!--<p class="nodata">-->
|
<!--<p class="nodata">-->
|
||||||
<!--<%#= l(:label_no_data) %>-->
|
<!--<%#= l(:label_no_data) %>-->
|
||||||
<!--</p>-->
|
<!--</p>-->
|
||||||
<% else %>
|
<% else %>
|
||||||
<% attachments.each do |attach| %>
|
<% attachments.each do |attach| %>
|
||||||
<ul class="resourcesList" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
|
<ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
|
||||||
<li class="resourcesListCheckbox fl">
|
<li class="resource-list-checkbox fl">
|
||||||
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
||||||
|
<!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />-->
|
||||||
</li>
|
</li>
|
||||||
<li class="resourcesListName fl">
|
<li class="resource-list-name fl hidden">
|
||||||
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
|
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack' %>
|
||||||
<%= link_to truncate(attach.filename,:length=>30), download_named_attachment_path(attach.id, attach.filename),
|
|
||||||
:title => attach.filename,:class=>'resourcesBlack'%>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
|
<li class="resource-list-time fr"><%= format_date(attach.created_on) %></li>
|
||||||
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
|
<li style="display: none"><%= attach.id %></li>
|
||||||
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
|
<li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
|
||||||
<li style="display: none"><%= attach.author_id %></li>
|
<li style="display: none"><%= attach.author_id %></li>
|
||||||
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
|
<li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li>
|
||||||
|
<li style="display: none"><%= attach.id %></li>
|
||||||
|
<li class="resource-list-size fr"><%= number_to_human_size(attach.filesize) %></li>
|
||||||
|
<li style="display: none"><%= attach.id %></li>
|
||||||
|
<li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li>
|
||||||
<li style="display: none"><%= attach.id %></li>
|
<li style="display: none"><%= attach.id %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="resourcesListDashLine"></ul>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
class MoveDomainToSecdomain < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
Secdomain.transaction do
|
||||||
|
#将组织中的子域名迁移至secdomains表
|
||||||
|
Organization.where("domain is not null").each do |org|
|
||||||
|
Secdomain.create(sub_type: 2, subname: org.domain, pid: org.id)
|
||||||
|
end
|
||||||
|
#remove_column :organizations, :domain
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
class RemoveDomainFromOrganizations < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :organizations, :domain
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class AddPublishToAttachmentHistories < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :attachment_histories, :is_publish, :integer, :default => 1
|
||||||
|
add_column :attachment_histories, :publish_time, :date
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,15 @@
|
|||||||
|
class CreateForwards < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
create_table :forwards do|t|
|
||||||
|
t.integer :from_id
|
||||||
|
t.string :from_type
|
||||||
|
t.integer :to_id
|
||||||
|
t.string :to_type
|
||||||
|
t.timestamp :created_at
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :forwards
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,38 @@
|
|||||||
|
class UpdateOneStudentScore < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
student_work_score = StudentWorksScore.where("user_id = 11688 AND student_work_id = 34414").first
|
||||||
|
student_work_score.score = 100
|
||||||
|
student_work_score.save
|
||||||
|
student_works = StudentWork.where("user_id = 6456")
|
||||||
|
student_works.each do |work|
|
||||||
|
unless work.student_works_scores.empty?
|
||||||
|
if work.student_works_scores.where(:reviewer_role => 2).empty?
|
||||||
|
work.teaching_asistant_score = nil
|
||||||
|
else
|
||||||
|
work.teaching_asistant_score = work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
|
||||||
|
end
|
||||||
|
if work.student_works_scores.where(:reviewer_role => 3).empty?
|
||||||
|
work.student_score = nil
|
||||||
|
else
|
||||||
|
work.student_score = work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if work.teaching_asistant_score.nil?
|
||||||
|
work.final_score = work.student_score
|
||||||
|
elsif work.student_score.nil?
|
||||||
|
work.final_score = work.teaching_asistant_score
|
||||||
|
else
|
||||||
|
homework = HomeworkCommon.find work.homework_common_id
|
||||||
|
ta_proportion = homework.homework_detail_manual.ta_proportion
|
||||||
|
final_ta_score = BigDecimal.new("#{work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||||
|
final_s_score = BigDecimal.new("#{work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||||
|
final_score = final_ta_score + final_s_score
|
||||||
|
work.final_score = format("%.2f",final_score.to_f)
|
||||||
|
end
|
||||||
|
work.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddIsOpenToHomewrokCommon < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :homework_commons, :is_open, :integer, :default => 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue