Merge branch 'szzh' into develop

dev_repository_hjq v20150327
sw 10 years ago
commit ef6526b4a7

@ -23,7 +23,7 @@ gem 'ruby-ole'
#gem 'email_verifier', path: 'lib/email_verifier'
gem 'rufus-scheduler'
#gem 'dalli', path: 'lib/dalli-2.7.2'
gem 'rails_kindeditor'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
group :development do
gem 'grape-swagger'
#gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
@ -32,7 +32,7 @@ group :development do
if RUBY_VERSION >= '2.0.0'
gem 'pry-byebug'
else
gem 'pry-debugger'
# gem 'pry-debugger'
end
gem 'pry-stack_explorer'
gem 'better_errors', '~> 1.1.0'

@ -181,6 +181,7 @@ class BidsController < ApplicationController
end
end
#将某个企业外包需求选为作业,目前此功能已放弃
def create_fork
@homework = Bid.new
@homework.name = params[:bid][:name]
@ -215,6 +216,7 @@ class BidsController < ApplicationController
end
end
#有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认
def show
@user = @bid.author
@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@ -250,40 +252,31 @@ class BidsController < ApplicationController
else
@state = 1
end
respond_to do |format|
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
# TO_DO
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
end
end
def unjoin_in_contest
joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id)
joined.each do |join|
join.delete
end
respond_to do |format|
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
end
end
def new_join
# added by fq
end
# added by bai 增加了参与者和竞赛设置
def show_participator
render :layout => 'base_contest'
end
#配置竞赛
def settings
if @bid.author.id == User.current.id
if @bid.reward_type == 2
@ -296,7 +289,7 @@ class BidsController < ApplicationController
end
#end
# 显示课程
# 显示课程作业,但是好像已经废弃
def show_course
bids = Bid.where('parent_id = ?', @bid.id)
@courses = []
@ -459,9 +452,7 @@ class BidsController < ApplicationController
def show_courseEx
if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
# flash[:notice] = ""
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
@user = @bid.author
@bidding_project = @bid.biding_projects.all
@ -858,7 +849,7 @@ class BidsController < ApplicationController
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.proportion = params[:bid][:proportion]
@bid.evaluation_num = params[:bid][:evaluation_num]
@bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation]
params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0
@bid.reward_type = 3
@bid.deadline = params[:bid][:deadline]
@bid.budget = 0

@ -66,6 +66,7 @@ class BoardsController < ApplicationController
'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
@topic_count = @board.topics.count
if @project
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@topics = @board.topics.
reorder("#{Message.table_name}.sticky DESC").
@ -75,6 +76,18 @@ class BoardsController < ApplicationController
order(sort_clause).
preload(:author, {:last_reply => :author}).
all
elsif @course
board_topics = @board.topics.
reorder("#{Message.table_name}.sticky DESC").
includes(:last_reply).
# limit(@topic_pages.per_page).
# offset(@topic_pages.offset).
order(sort_clause).
preload(:author, {:last_reply => :author}).
all
@topics = paginateHelper board_topics,10
end
@message = Message.new(:board => @board)
#modify by nwb
if @project

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
# added by fq
class ForumsController < ApplicationController
layout "users_base"
include ApplicationHelper
# GET /forums
# GET /forums.json
before_filter :find_forum_if_available
@ -63,6 +63,9 @@ class ForumsController < ApplicationController
respond_to do |format|
if @memo.save
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@memo.id,1
#end
format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
@ -163,6 +166,13 @@ class ForumsController < ApplicationController
@forum = Forum.new(params[:forum])
@forum.creator_id = User.current.id
if @forum.save
# Time 2015-03-24 17:07:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,2
#end
respond_to do |format|
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }

@ -59,6 +59,20 @@ class MemosController < ApplicationController
@memo.content = @quote + @memo.content
respond_to do |format|
if @memo.save
# Time 2015-03-24 14:47:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo
if !params[:asset_id].nil?
ids = params[:asset_id].split(',')
ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i)
asset.owner_id = @memo.id
asset.owner_type = 1
asset.save
end
end
#end
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else

@ -44,6 +44,26 @@ class MessagesController < ApplicationController
end
@reply_count = @topic.children.count
# @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
# @replies = @topic.children.
# includes(:author, :attachments, {:board => :project}).
# reorder("#{Message.table_name}.created_on DESC").
# limit(@reply_pages.per_page).
# offset(@reply_pages.offset).
# all
@reply = Message.new(:subject => "RE: #{@message.subject}")
if @course
messages_replies = @topic.children.
includes(:author, :attachments, {:board => :project}).
reorder("#{Message.table_name}.created_on DESC").
#limit(@reply_pages.per_page).
#offset(@reply_pages.offset).
all
@replies = paginateHelper messages_replies,10
@reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => "base_courses"#by young
else
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children.
includes(:author, :attachments, {:board => :project}).
@ -53,9 +73,6 @@ class MessagesController < ApplicationController
all
@reply = Message.new(:subject => "RE: #{@message.subject}")
if @course
render :action => "show", :layout => "base_courses"#by young
else
render :action => "show", :layout => "base_projects"#by young
end
end
@ -76,6 +93,13 @@ class MessagesController < ApplicationController
layout_file = @project ? 'base_projects' : 'base_courses'
render :action => 'new', :layout => layout_file
end
else
respond_to do |format|
format.html {
layout_file = @project ? 'base_projects' : 'base_courses'
render :layout => layout_file
}
end
end
end

@ -70,13 +70,13 @@ class NewsController < ApplicationController
scope = @course ? @course.news.course_visible : News.course_visible
@news_count = scope.count
@news_pages = Paginator.new @news_count, @limit, params['page']
@offset ||= @news_pages.offset
@newss = scope.all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC",
:offset => @offset,
:limit => @limit)
#@news_pages = Paginator.new @news_count, @limit, params['page']
#@offset ||= scope_page.offset
scope_order = scope.all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC")
# :offset => @offset,
# :limit => @limit)
@newss = paginateHelper scope_order,10
respond_to do |format|
format.html {
@news = News.new

@ -340,7 +340,7 @@ class ProjectsController < ApplicationController
@is_zhuce =false
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:notice_registed_success, :value => email)
flash[:error] = l(:notice_registed_error, :value => email)
@is_zhuce = true
end
respond_to do |format|

@ -248,6 +248,8 @@ class TagsController < ApplicationController
@obj = OpenSourceProject.find_by_id(@obj_id)
when '9'
@obj = Course.find_by_id(@obj_id)
when '10'
@obj = Attachment.find_by_id(@obj_id)
else
@obj = nil
end
@ -315,6 +317,14 @@ class TagsController < ApplicationController
when '8'
@obj = OpenSourceProject.find_by_id(obj_id)
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
when '10'
@obj = Attachment.find_by_id(obj_id)
# modifed by Long Jun
# this is used to find the attachments that came from the same project and tagged with the same tag.
#@result = get_attachments_by_project_tag(selected_tags, @obj)
@result = get_attachments_by_tag(selected_tags)
@obj_pages, @attachments_results, @results_count = for_pagination(@result)
when '9' then
@obj = Course.find_by_id(obj_id)
@obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags))
@ -381,6 +391,8 @@ class TagsController < ApplicationController
return 'OpenSourceProject'
when '9'
return 'Course'
when '10'
return 'Attachment'
else
render_error :message => e.message
return

@ -33,6 +33,35 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
# Time 2015-03-24 15:27:29
# Author lizanle
# Description 从硬盘上删除对应的资源文件
def delete_kindeditor_assets_from_disk owner_id,owner_type
assets = Kindeditor::Asset.where(["owner_id = ? and owner_type = ?",owner_id,owner_type])
if !assets.nil? && !assets.blank?
assets.all.each do |asset|
next if asset.nil?
filepath = File.join(Rails.root,"public","files","uploads",
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
asset[:asset].to_s)
File.delete(filepath) if File.exist?filepath
end
end
end
# Time 2015-03-24 16:38:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo
def update_kindeditor_assets_owner ids,owner_id,owner_type
ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i)
asset.owner_id = owner_id
asset.owner_type = owner_type
asset.save
end
end
# Added by young
# Define the course menu's link class
# 不是数组的转化成数组然后判断当前menu_item是否在给定的列表
@ -95,6 +124,20 @@ module ApplicationHelper
end
end
#重载上面方法,增加样式显示
def link_to_user_header user,canShowRealName=false,options={}
if user.is_a?(User)
if canShowRealName
name = h(user.realname(options[:format]))
else
name = h(user.name(options[:format]))
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class]
else
h(user.to_s)
end
end
# Displays a link to +issue+ with its subject.
# Examples:
#
@ -256,7 +299,7 @@ module ApplicationHelper
onclick = "$('##{id}').slideToggle(); "
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
onclick << "return false;"
link_to(name, "#", :onclick => onclick)
link_to(name, "#", :onclick => onclick,:class => options[:class])
end
def image_to_function(name, function, html_options = {})
@ -1622,6 +1665,17 @@ module ApplicationHelper
@public_forum = Forum.find(1)
end
#获取用户未过期的课程
def get_user_course user
courses_doing = []
user.courses.each do |course|
if !course_endTime_timeout?(course)
courses_doing.push course
end
end
courses_doing
end
private
def wiki_helper
@ -1847,7 +1901,7 @@ module ApplicationHelper
def render_dynamic_nav
home_link = link_to l(:field_homepage), {:controller => 'welcome', :action => 'index'}
home_link = "<li>" << home_link << "</li>"
home_link = "<li class = 'topnav_a fl'>" << home_link << "</li>"
# bootstrap_render_dynamic_nav
content_tag :ul, (home_link.html_safe+bootstrap_render_dynamic_nav)
end
@ -1888,7 +1942,7 @@ module ApplicationHelper
content_li = ''
nav_list.collect do |nav_item|
content_li << content_tag(:li, nav_item)
content_li << content_tag(:li, nav_item, :class => 'topnav_a fl')
end
content_li.html_safe
end

@ -35,6 +35,16 @@ module AttachmentsHelper
end
end
def link_to_attachments_course(container, options = {})
options.assert_valid_keys(:author, :thumbnails)
if container.attachments.any?
options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
render :partial => 'attachments/course_file_links',
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
end
end
def attach_delete(project)
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
true

@ -25,6 +25,40 @@ module CoursesHelper
# searchTeacherAndAssistant(project).count
end
#课程模块需要展示的模块
def course_model
@nav_dispaly_course_all_label = 1
@nav_dispaly_forum_label = 1
@nav_dispaly_course_label = nil
@nav_dispaly_store_all_label = 1
end
#生成课程老师成员链接
def course_teacher_link teacher_num
if User.current.member_of_course?(@course)
link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue'
else
content_tag 'span',teacher_num, :class => 'info_foot_num c_blue'
end
end
#生成课程学生列表连接
def course_student_link student_num
if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course))
link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue'
else
content_tag 'span',student_num, :class => 'info_foot_num c_blue'
end
end
def course_poll_count
Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}").count
end
def course_feedback_count
@course.journals_for_messages.where('m_parent_id IS NULL').count
end
# 返回学生数量即roles表中定义的Reporter
#def studentCount project
# searchStudent(project).count
@ -624,4 +658,82 @@ module CoursesHelper
return activities
end
#获取某个课程的动态数
def course_activity_count course
course_activity_count=Hash.new
course_activity_count[course.id]=0
count = get_course_activity([course],course_activity_count)[course.id]
count.nil? ? 0 : count
end
#重启、关闭课程按钮
def set_course_time course
id = "finish_course_#{course.id}"
linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js)
desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed)
link_to "<span class='pr_close'></span>#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a"
end
#加入课程、退出课程按钮
def join_in_course_header(course, user, options=[])
if user.logged?
joined = user.member_of_course? course
text = joined ? ("<em class='pr_arrow'></em>".html_safe + l(:label_course_exit_student)) : ("<em class='pr_add'></em>".html_safe + l(:label_course_join_student))
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'
if joined
link = "<span class='pr_join_span mr5' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" + link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
else
link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") + "<span class='pr_join_span mr5' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>".html_safe
end
else
link = "<span class='pr_join_span mr5' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" +
"<span class='pr_join_span mr5' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>"
end
link.html_safe
end
def bid_anonymous_comment bid
if bid.open_anonymous_evaluation == 1
if bid.homeworks.count >= 2
case bid.comment_status
when 0
link = link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit'
when 1
link = link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit'
when 2
link = "<span class='fr pr_join_span mr10' title='匿评结束'>匿评结束</span>".html_safe
end
else
link = "<span class='fr mr10 pr_join_span ' title='学生提交作业数大于2时才可以启动匿评'>启动匿评</span>".html_safe
end
else
link = "<span class='fr mr10 pr_join_span ' title='未开启匿评作业不可以启动匿评'>启动匿评</span>".html_safe
end
link
end
def student_new_homework bid
user_homework = cur_user_homework_for_bid bid
if user_homework && user_homework.empty?
link_to l(:label_commit_homework), new_exercise_book_path(bid),:class => 'fr mr10 work_edit'
else
"<span class='fr mr10 pr_join_span '>作业已交</span>".html_safe
end
end
def student_anonymous_comment bid
if bid.open_anonymous_evaluation == 1
case bid.comment_status
when 0
"<span class='fr mr10 pr_join_span '>未开启匿评</span>".html_safe
when 1
"<span class='fr mr10 pr_join_span '>正在匿评中</span>".html_safe
when 2
"<span class='fr mr10 pr_join_span '>匿评已结束</span>".html_safe
end
else
"<span class='fr mr10 pr_join_span '>未启用匿评</span>".html_safe
end
end
end

@ -87,7 +87,10 @@ module FilesHelper
def visable_attachemnts attachments
result = []
attachments.each do |attachment|
if attachment.is_public? || (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
if attachment.is_public? ||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))||
attachment.author_id == User.current.id
result << attachment
end
end

@ -20,6 +20,8 @@ module TagsHelper
@obj= Contest.find_by_id(obj_id)
when '9'
@obj= Course.find_by_id(obj_id)
when '10'
@obj = Attachment.find_by_id(obj_id)
else
raise Exception, '[TagsHelper] ===> tag type unknow.'
end

@ -46,6 +46,26 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method, :class => css
end
def watcher_link_with_id(objects, user, options=[])
return '' unless user && user.logged?
objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid)))
css = options[:class]
text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
url = watch_path(
:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css,:id=>options[:id]
end
############## added by linchun
def new_watcher_link(objects, user, options=[])
return '' unless user && user.logged?

@ -1,5 +1,7 @@
class Forum < ActiveRecord::Base
include Redmine::SafeAttributes
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy
has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL"
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
@ -15,7 +17,7 @@ class Forum < ActiveRecord::Base
validates_length_of :name, maximum: 50
#validates_length_of :description, maximum: 255
validates :name, :uniqueness => true
after_destroy :delete_kindeditor_assets
acts_as_taggable
scope :by_join_date, order("created_at DESC")
#after_create :send_email
@ -47,5 +49,11 @@ class Forum < ActiveRecord::Base
["id = ?", forum_id])
end
# Time 2015-03-26 15:50:54
# Author lizanle
# Description 删除论坛后删除对应的资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,2
end
end

@ -125,7 +125,7 @@ class Mailer < ActionMailer::Base
end
# 公共讨论区发帖、回帖添加邮件发送信息
def forum_message_added(memo)
@memo = memo
redmine_headers 'Memo' => memo.id
@ -134,9 +134,11 @@ class Mailer < ActionMailer::Base
@forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id)
@issue_author_url = url_for(user_activities_url(@author))
recipients ||= []
if @forum.author.mail_notification != 'day' && @forum.author.mail_notification != 'week'
#将帖子创建者邮箱地址加入数组
if @forum.creator.mail_notification != 'day' && @forum.creator.mail_notification != 'week'
recipients << @forum.creator.mail
end
#回复人邮箱地址加入数组
if @author.mail_notification != 'day' && @author.mail_notification != 'week'
recipients << @author.mail
end

@ -1,7 +1,9 @@
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ApplicationHelper
belongs_to :forum
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
validates_presence_of :author_id, :forum_id, :subject,:content
# 若是主题帖,则内容可以是空
@ -42,9 +44,9 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
after_create :add_author_as_watcher, :reset_counters! #, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分
after_create :add_author_as_watcher, :reset_counters!, :sendmail
# after_update :update_memos_forum
after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
@ -170,4 +172,10 @@ class Memo < ActiveRecord::Base
update_replay_for_memo(User.current,1)
end
# Time 2015-03-26 15:20:24
# Author lizanle
# Description 从硬盘上删除资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,1
end
end

@ -239,6 +239,8 @@ class CoursesService
course.time = params[:time]
course.term = params[:term]
course.class_period = params[:class_period]
params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0
params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0
if course.save
if params[:course][:is_public] == '0'
course_status = CourseStatus.find_by_course_id(course.id)

@ -0,0 +1,72 @@
<div class="attachments" style="font-weight:normal;">
<% is_float ||= false %>
<% for attachment in attachments %>
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%if is_float%>
<div style="max-width:55%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
<% end%>
<span title="<%= attachment.filename%>" id = "attachment_">
<% if options[:length] %>
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%>
<% else %>
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%>
<% end %>
</span>
<%if is_float%>
</div>
<% end%>
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments',
:action => 'show',
:id => attachment,
:filename => attachment.filename%>
<% end %>
<span title="<%= attachment.description%>">
<%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %>
</span>
<span class="size">(
<%= number_to_human_size attachment.filesize %>)
</span>
<% if options[:deletable] %>
<% if attachment.container_type == 'HomeworkAttach' %>
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete delete-homework-icon',
:remote => true,
:title => l(:button_delete) %>
<% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
#:remote => true,
#:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %>
<% end %>
<% end %>
<% if options[:wrap] %>
<br/>
&nbsp;
<% end %>
<% if options[:author] %>
<span class="author" title="<%= attachment.author%>">
<%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>,
<%= format_time(attachment.created_on) %>
</span>
<% end %>
</p>
<% end %>
<% if defined?(thumbnails) && thumbnails %>
<% images = attachments.select(&:thumbnailable?) %>
<% if images.any? %>
<div class="thumbnails">
<% images.each do |attachment| %>
<div><%= thumbnail_tag(attachment) %></div>
<% end %>
</div>
<% end %>
<% end %>
</div>

@ -38,7 +38,7 @@
<span class="add_attachment">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()" %>
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',
@ -56,7 +56,7 @@
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all)
} %>
<span id="upload_file_count"><%= l(:label_no_file_uploaded)%></span>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

@ -9,7 +9,7 @@
<% if options[:length] %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%>
<% else %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true, :length => 32 -%>
<% end %>
</span>
<%if is_float%>
@ -26,9 +26,7 @@
<span title="<%= attachment.description%>">
<%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %>
</span>
<span class="size">(
<%= number_to_human_size attachment.filesize %>)
</span>
<span class="size">(<%= number_to_human_size attachment.filesize , :precision => 0 %>)</span>
<% if options[:deletable] %>
<% if attachment.container_type == 'HomeworkAttach' %>
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},

@ -0,0 +1,59 @@
<div class="fl">
<span id="attachments_fields" class="attachments_fields">
<% if defined?(container) && container && container.saved_attachments %>
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
</span>
<% project = project %>
<span class="add_attachment" style="font-weight:normal;">
<%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js',:project =>project),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all)
} %>
<span id="upload_file_count">
<%= l(:label_no_file_uploaded)%>
</span>
(<%= l(:label_max_size) %>:
<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>
</div>

@ -0,0 +1,27 @@
<a href="javascript:void(0)" class="upimg fl">
<%= image_tag(url_to_avatar(source), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
</a>
<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "upbtn fl" %>
<a href="javascript:void(0)" class="upbtn fl">上传图片</a>
<%= file_field_tag 'avatar[image]',
:id => nil,
:class => 'upload_file ',
:size => "1",
:multiple => false,
:onchange => 'addInputAvatar(this);',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:file_type => Redmine::Configuration['pic_types'].to_s,
:type_support_message => l(:error_pic_type),
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
:source_id => source.id.to_s
} %>
<!--</span>-->
<% content_for :header_tags do %>
<%= javascript_include_tag 'avatars' %>
<% end %>
<div class="cl"></div>

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

Loading…
Cancel
Save