Merge branch 'szzh' into develop

gitlab
sw 10 years ago
commit 10997bf331

@ -170,10 +170,26 @@ module Mobile
desc "设置教辅" desc "设置教辅"
params do params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'set_user_as_assitant' do
cs = CoursesService.new
cs.set_as_assitant_teacher params
present :status, 0
end end
post 'set_user_as_assitant' do
desc "删除教辅"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
requires :course_id,type:Integer,desc:'课程id'
end
get 'del_user_as_assitant' do
cs = CoursesService.new
cs.del_assitant_teacher params
present :status, 0
end end
desc "返回单个课程" desc "返回单个课程"
@ -187,7 +203,7 @@ module Mobile
course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user)) course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user))
#course = Course.find(params[:id]) #course = Course.find(params[:id])
present :data, course, with: Mobile::Entities::Course present :data, course, with: Mobile::Entities::Course
present :status, 0 { status: 0}
end end
end end
@ -258,6 +274,13 @@ module Mobile
get ":course_id/members" do get ":course_id/members" do
cs = CoursesService.new cs = CoursesService.new
count = cs.course_members params count = cs.course_members params
# 我如果在学生当中,那么我将放在第一位
count.each do |m|
if m.user.id == current_user.id
count.delete m
count.unshift m
end
end
present :data, count, with: Mobile::Entities::Member present :data, count, with: Mobile::Entities::Member
present :status, 0 present :status, 0
end end
@ -274,6 +297,20 @@ module Mobile
present :data,homeworkscore,with: Mobile::Entities::Homeworkscore present :data,homeworkscore,with: Mobile::Entities::Homeworkscore
present :status,0 present :status,0
end end
desc '发布课程通知'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :title,type:String,desc:'通知标题'
requires :desc,type:String,desc:'通知描述'
end
post ':course_id/create_course_notice' do
cs = CoursesService.new
news = cs.create_course_notice params,current_user
present :data,news,with:Mobile::Entities::News
present :status,0
end
end end
end end
end end

@ -96,6 +96,21 @@ module Mobile
present :status, 0 present :status, 0
end end
desc '创建作业'
params do
requires :token,type:String
requires :work_name,type:String,desc:'作业名称'
requires :work_desc,type:String,desc:'作业描述'
requires :work_deadline,type:String,desc:'截止日期'
requires :is_blind_appr,type:Integer,desc:'是否匿评'
requires :blind_appr_num,type:Integer,desc:'匿评分配数'
requires :course_id,type:Integer,desc: '课程id'
end
post 'create_home_work' do
Homeworks.get_service.create_home_work params,current_user
present :status, 0
end
end end
end end

@ -84,6 +84,8 @@ module Mobile
requires :name, type: String, desc: '用户名关键字' requires :name, type: String, desc: '用户名关键字'
requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱,3 昵称和姓名' requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱,3 昵称和姓名'
optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教' optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教'
optional :course_id,type:Integer,desc: '课程id搜索注册用户不为该课程教师的其他用户'
optional :user_id,type:Integer,desc:'用户id'
end end
get 'search/search_user' do get 'search/search_user' do
us = UsersService.new us = UsersService.new

@ -9,7 +9,7 @@ module Mobile
u[f] u[f]
elsif u.is_a?(::User) elsif u.is_a?(::User)
if u.respond_to?(f) if u.respond_to?(f)
u.send(f) u.send(f) unless u.user_extensions.nil?
else else
case f case f
when :img_url when :img_url
@ -17,9 +17,9 @@ module Mobile
when :gender when :gender
u.nil? || u.user_extensions.nil? || u.user_extensions.gender.nil? ? 0 : u.user_extensions.gender u.nil? || u.user_extensions.nil? || u.user_extensions.gender.nil? ? 0 : u.user_extensions.gender
when :work_unit when :work_unit
get_user_work_unit u get_user_work_unit u unless u.user_extensions.nil?
when :location when :location
get_user_location u get_user_location u unless u.user_extensions.nil?
when :brief_introduction when :brief_introduction
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction
end end

@ -315,7 +315,7 @@ class AccountController < ApplicationController
#根据home_url生产正则表达式 #根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != '' if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != ''
redirect_to user_activities_path(user,host: Setting.user_domain) redirect_to user_activities_path(user,host: Setting.host_user)
else else
if last_login_on == '' if last_login_on == ''
redirect_to my_account_url redirect_to my_account_url
@ -333,7 +333,7 @@ class AccountController < ApplicationController
token = Token.get_or_create_permanent_login_token(user) token = Token.get_or_create_permanent_login_token(user)
cookie_options = { cookie_options = {
:value => token.value, :value => token.value,
:expires => 7.days.from_now, :expires => 1.month.from_now,
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'), :path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false), :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
:httponly => true :httponly => true

@ -852,7 +852,7 @@ class CoursesController < ApplicationController
#验证是否显示课程 #验证是否显示课程
def can_show_course def can_show_course
@first_page = FirstPage.find_by_page_type('project') @first_page = FirstPage.find_by_page_type('project')
if @first_page.show_course == 2 if @first_page.try(:show_course) == 2
render_404 render_404
end end
end end

@ -118,11 +118,11 @@ module ApplicationHelper
end end
#if user.active? || (User.current.admin? && user.logged?) #if user.active? || (User.current.admin? && user.logged?)
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes # link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
#else #else
# name # name
#end #end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
else else
h(user.to_s) h(user.to_s)
end end
@ -131,7 +131,7 @@ module ApplicationHelper
def link_to_isuue_user(user, options={}) def link_to_isuue_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]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "pro_info_p" link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "pro_info_p"
else else
h(user.to_s) h(user.to_s)
end end
@ -140,7 +140,7 @@ module ApplicationHelper
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]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "w90 c_orange fl" link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "w90 c_orange fl"
else else
h(user.to_s) h(user.to_s)
end end
@ -155,7 +155,7 @@ module ApplicationHelper
else else
name = user.login name = user.login
end end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class] link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => options[:class]
else else
h(user.to_s) h(user.to_s)
end end
@ -2076,21 +2076,21 @@ module ApplicationHelper
hidden_non_project = Setting.find_by_name("hidden_non_project") hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = !(hidden_non_project && hidden_non_project.value == "0") visiable = !(hidden_non_project && hidden_non_project.value == "0")
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain} main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.host_course}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.host_name}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.host_contest}
# course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} # course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.host_course}
# courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} # courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
#users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} #users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.host_user}
# contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} # contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'}
forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"} forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"}
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'} stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'} school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.project_domain} project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.host_name}
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} # project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
#@nav_dispaly_project_label #@nav_dispaly_project_label
nav_list = Array.new nav_list = Array.new

@ -11,7 +11,7 @@ module GitlabHelper
PROJECT_PATH_CUT = 40 PROJECT_PATH_CUT = 40
# gitlab版本库所在服务器 # gitlab版本库所在服务器
# 注意REPO_IP_ADDRESS必须以http://开头暂时只支持HTTP协议未支持SSH # 注意REPO_IP_ADDRESS必须以http://开头暂时只支持HTTP协议未支持SSH
#REPO_IP_ADDRESS = "http://" + Setting.repository_domain #REPO_IP_ADDRESS = "http://" + Setting.host_repository
REPO_IP_ADDRESS = "http://192.168.137.100" REPO_IP_ADDRESS = "http://192.168.137.100"
GITLAB_API = "/api/v3" GITLAB_API = "/api/v3"

@ -24,7 +24,7 @@ module RepositoriesHelper
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/" ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
end end
PROJECT_PATH_CUT = 40 PROJECT_PATH_CUT = 40
REPO_IP_ADDRESS = Setting.repository_domain REPO_IP_ADDRESS = Setting.host_repository
def format_revision(revision) def format_revision(revision)
if revision.respond_to? :format_identifier if revision.respond_to? :format_identifier

@ -473,6 +473,47 @@ class CoursesService
result result
end end
# 设置人员为课程教辅
def set_as_assitant_teacher params
members = []
#找到课程
course = Course.find(params[:course_id])
#新建课程人员
member = Member.new(:role_ids =>[7], :user_id => params[:user_id],:course_id=>params[:course_id])
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,course.id)
joined.each do |join|
join.delete
end
member.course_group_id = 0
members << member
course.members << members
#将课程人员设置为教辅
end
def del_assitant_teacher params
member = Member.where("user_id = ? and course_id = ?",params[:user_id],params[:course_id])
member.each do |m|
m.destroy
end
user_admin = CourseInfos.where("user_id = ? and course_id = ?",params[:user_id], params[:course_id])
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:course_id])
joined.each do |join|
join.delete
end
end
def create_course_notice params ,current_user
n = News.new(:course_id =>params[:course_id], :author_id => current_user.id,:title =>params[:title],:description=> params[:desc])
n.save
{:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
end
private private
def searchmember_by_name members, name def searchmember_by_name members, name
#searchPeopleByRoles(project, StudentRoles) #searchPeopleByRoles(project, StudentRoles)
@ -576,4 +617,6 @@ class CoursesService
end end

@ -232,6 +232,29 @@ class HomeworkService
end end
end end
# 发布作业
def create_home_work params,current_user
@bid = Bid.new
@bid.name = params[:work_name]
@bid.description = params[:work_desc]
# @bid.is_evaluation = params[:is_blind_appr]
@bid.evaluation_num = params[:blind_appr_num]
@bid.open_anonymous_evaluation = params[:is_blind_appr]
@bid.reward_type = 3
@bid.deadline = params[:work_deadline]
@bid.budget = 0
@bid.author_id = current_user.id
@bid.commit = 0
@bid.homework_type = 1
# @bid.
if @bid.save
HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id)
unless @bid.watched_by?(current_user)
@bid.add_watcher(current_user)
end
end
end
# 学生匿评列表 # 学生匿评列表
def student_jour_list params def student_jour_list params
@homework = HomeworkAttach.find(params[:homework_id]) @homework = HomeworkAttach.find(params[:homework_id])

@ -211,7 +211,8 @@ class UsersService
search_by = params[:search_by] ? params[:search_by] : "0" search_by = params[:search_by] ? params[:search_by] : "0"
scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present?
else else
scope = scope.like(params[:name],search_by) if params[:name].present? teachers = searchTeacherAndAssistant(Course.find(params[:course_id]))
scope = scope.where("id not in (?)",teachers.map{|t| t.user_id}).like(params[:name],search_by) if params[:name].present?
end end
scope scope
end end

@ -2,26 +2,30 @@
<% if defined?(container) && container && container.saved_attachments %> <% if defined?(container) && container && container.saved_attachments %>
<% if isReply %> <% if isReply %>
<% container.saved_attachments.each_with_index do |attachment, i| %> <% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment"> <span id="attachments_p<%= i %>" class="sub_btn">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span> <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')%> <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>
<% else %> <% else %>
<% container.attachments.each_with_index do |attachment, i| %> <% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment"> <span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> <span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<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') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>
<% end %> <% end %>
@ -56,7 +60,9 @@
:file_count => l(:label_file_count), :file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all) :delete_all_files => l(:text_are_you_sure_all)
} %> } %>
<span id="upload_file_count<%= container.id %>" :class="c_grey"><%= l(:label_no_file_uploaded)%></span> <% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span> </span>

@ -24,7 +24,7 @@
<span class="ispublic-label"><%= l(:field_is_public)%>:</span> <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_checkbox')%> <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> <%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), 'data-containerid'=>"#{container.id}",:method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
@ -41,7 +41,7 @@
// file.click(); // file.click();
// } // }
</script> </script>
<span class="add_attachment"> <span class="add_attachment" data-containerid="<%= container.id %>">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%--> <!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "文件浏览", :type=>"button", :onclick=>"_file#{container.id}.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file#{container.id}.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
@ -60,7 +60,8 @@
:field_is_public => l(:field_is_public), :field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure), :are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count), :file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all) :delete_all_files => l(:text_are_you_sure_all),
:containerid => "#{container.id}"
} %> } %>
<span id="upload_file_count<%=container.id %>" :class="c_grey"><%= l(:label_no_file_uploaded)%></span> <span id="upload_file_count<%=container.id %>" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
@ -124,7 +125,9 @@
:file_count => l(:label_file_count), :file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all) :delete_all_files => l(:text_are_you_sure_all)
} %> } %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span> <% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span> </span>

@ -1,8 +1,26 @@
$('#attachments_<%= j params[:attachment_id] %>').remove(); var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
var count=$('#attachments_fields>span').length; //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
if(count<=0){ var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
$("#upload_file_count").text(<%= l(:label_no_file_uploaded)%>); if(containerid==undefined){
$(".remove_all").remove(); $('#attachments_<%= j params[:attachment_id] %>').remove();
var count=$('#attachments_fields>span').length;
if(count<=0){
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
$(".remove_all").remove();
}else{
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
}
}else{ }else{
$("#upload_file_count").html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件"); $('#attachments_<%= j params[:attachment_id] %>').remove();
var count=$('#attachments_fields'+containerid+'>span').length;
if(count<=0){
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
var remove_all_html_obj = $(".remove_all").filter(function(index){
return $(this).data('containerid')==containerid;
});
remove_all_html_obj.remove();
}else{
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
}
} }
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end

@ -68,6 +68,7 @@
</div> </div>
<p style="display: none" id="project_show_<%= topic.id%>"> <p style="display: none" id="project_show_<%= topic.id%>">
<label id="expend_more_information<%= topic.id%>" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</label> <label id="expend_more_information<%= topic.id%>" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</label>
<span class="g-arr-down"> <span class="g-arr-down">
@ -125,7 +126,7 @@
<div class="Msg_txt"> <div class="Msg_txt">
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
<br/> <br/>
<p class="fl"><%= textAreailizable message,:content,:attachments => message.attachments %></p> <p class="fl break_word"><%= textAreailizable message,:content,:attachments => message.attachments %></p>
<br/> <br/>
<span class=" c_grey fl"><%= format_time(message.created_on) %></span> <span class=" c_grey fl"><%= format_time(message.created_on) %></span>

@ -33,20 +33,21 @@
%> %>
</p> </p>
<p style="margin-left:-10px;padding-right: 20px;"> <p>
<%= f.text_area :description, <%= f.text_area :description,
:rows => 5, :size => 60,
:class => 'wiki-edit', :rows => 4,
:style => "font-size:small;width:490px;margin-left:10px;", :style => "width:490px;",
:maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT,
:placeholder => "#{l(:label_contest_description)}" :placeholder => "#{l(:label_contest_description)}"
%> %>
</p> </p>
<p style="margin-left:-10px;"> <p>
<%= f.text_field :password, <%= f.text_field :password,
:size => 60, :size => 60,
:style => "width:488px;margin-left: 10px;" :rows => 4,
:style => "width:490px;"
%> %>
</p> </p>

@ -187,7 +187,7 @@
<!-- modified by longjun --> <!-- modified by longjun -->
<%= link_to l(:label_create_new_projects), <%= link_to l(:label_create_new_projects),
new_project_path(:course => 0, :project_type => 0, :host => Setting.project_domain), new_project_path(:course => 0, :project_type => 0, :host => Setting.host_name),
:target => '_blank' :target => '_blank'
%> %>
<!-- end longjun --> <!-- end longjun -->

@ -23,6 +23,7 @@
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label> <label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();" value="<%= @course.name%>"> <input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();" value="<%= @course.name%>">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span> <span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
<input type="password" style="top: -100000px;position: fixed;">
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li class="ml45"> <li class="ml45">

@ -1,5 +1,4 @@
<!-- added by fq --> <script>$(function(){$("img").removeAttr("alt");});</script>
<!--display the board-->
<div class="borad-topic-count">共有 <%=link_to @forum.memos.count %> 个贴子</div> <div class="borad-topic-count">共有 <%=link_to @forum.memos.count %> 个贴子</div>
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<% if memos.any? %> <% if memos.any? %>

@ -31,5 +31,5 @@
</div> </div>
<% end -%> <% end -%>
<ul class="wlist"> <ul class="wlist">
<%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => false, :flag => true %> <%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => true, :flag => true %>
</ul> </ul>

@ -46,59 +46,52 @@
<!--属性--> <!--属性-->
<div class="pro_info_box mb10"> <div class="pro_info_box mb10">
<%= issue_fields_rows do |rows| %> <%= issue_fields_rows do |rows| %>
<ul class="fl"> <ul class="fl" >
<li><p class="label03" >&nbsp;状态&nbsp;&nbsp;:&nbsp;</p><p class="pro_info_p"><%= @issue.status.name %></p>
<li><p class="label"><span class="c_red f12">*</span>&nbsp;状态&nbsp;&nbsp;:&nbsp;</p> </li>
<div class="cl"></div>
<p class="pro_info_p"><%= @issue.status.name %></p>
</li>
<div class="cl"></div>
<li><p class="label"><span class="c_red f12">*</span>&nbsp;优先级&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p"><%= @issue.priority.name %></span>
</li>
<div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('assigned_to_id') %> <% unless @issue.disabled_core_fields.include?('assigned_to_id') %>
<li><p class="label">&nbsp;指派给&nbsp;&nbsp;:&nbsp;</p> <li><p class="label03" >&nbsp;指派给&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p"><%= @issue.assigned_to ? link_to_isuue_user(@issue.assigned_to) : "--" %></span>
<span class="pro_info_p"><%= @issue.assigned_to ? link_to_isuue_user(@issue.assigned_to) : "-" %></span> </li>
</li>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('fixed_version_id') %> </ul>
<li><p class="label">&nbsp;目标版本&nbsp;&nbsp;:&nbsp;</p> <ul class="fl" >
<span class="pro_info_p"><%= (@issue.fixed_version ? link_to_version(@issue.fixed_version, :class => "pro_info_p") : "-") %></span> <li><p class="label03" >&nbsp;优先级&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p" style="width:50px;"><%= @issue.priority.name %></span>
</li> </li>
<div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('done_ratio') %>
<li><p class="label03" >&nbsp;% 完成&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p" style="width:50px;"><%= @issue.done_ratio %>%</span>
</li>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<ul class="fl ml90">
<% unless @issue.disabled_core_fields.include?('start_date') %>
<li><p class="label02">&nbsp;开始日期&nbsp;&nbsp;:&nbsp;</p>
<p class="pro_info_p"><%= format_date(@issue.start_date) %></p></li> <ul class="fl " >
<% end %> <% unless @issue.disabled_core_fields.include?('start_date') %>
<div class="cl"></div> <li><p class="label03" style="width:50px;" >&nbsp;开始&nbsp;&nbsp;:&nbsp;</p><p class="pro_info_p"><%= format_date(@issue.start_date) %></p>
<% unless @issue.disabled_core_fields.include?('due_date') %> </li>
<li><p class="label02">&nbsp;计划完成日期&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p"><%= format_date(@issue.due_date) %></span>
</li>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('estimated_hours') %> <% unless @issue.disabled_core_fields.include?('estimated_hours') %>
<li><p class="label03" style="width:50px;">&nbsp;周期&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p"><%= l_hours(@issue.estimated_hours) %></span>
<li><p class="label02">&nbsp;预期时间&nbsp;&nbsp;:&nbsp;</p> </li>
<span class="pro_info_p"><%= l_hours(@issue.estimated_hours) %></span>
</li>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
<% unless @issue.disabled_core_fields.include?('done_ratio') %> </ul>
<li><p class="label02">&nbsp;% 完成&nbsp;&nbsp;:&nbsp;</p> <ul class="fl " >
<span class="pro_info_p"><%= @issue.done_ratio %>%</span> <% unless @issue.disabled_core_fields.include?('due_date') %>
</li> <li><p class="label03" >&nbsp;计划完成&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p" style="width:120px;"><%= format_date(@issue.due_date)? format_date(@issue.due_date) : "--" %></span>
</li>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</ul> <% unless @issue.disabled_core_fields.include?('fixed_version_id') %>
<% end %> <li><p class="label03" >&nbsp;目标版本&nbsp;&nbsp;:&nbsp;</p><span class="pro_info_p" style="width:120px;"><%= (@issue.fixed_version ? link_to_version(@issue.fixed_version, :class => "pro_info_p") : "--") %></span>
</li>
<% end %>
<div class="cl"></div>
</ul>
<% end %><!--pro_info_box end-->
<%#= render_custom_fields_rows(@issue) %> <%#= render_custom_fields_rows(@issue) %>
<%#= call_hook(:view_issues_show_details_bottom, :issue => @issue) %> <%#= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
</div> </div>

@ -169,15 +169,15 @@ function cookieget(n)
<div class="side_center"> <div class="side_center">
<div class="custom_service"> <div class="custom_service">
<% get_memo %> <% get_memo %>
<% if @public_forum %> <% if @public_forum %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %> <%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %> <%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %> <%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %> <%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label> <label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a> <a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="msgserver"> <div class="msgserver">
<a href="http://user.trustie.net/users/34/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>白&nbsp;&nbsp;&nbsp;羽</a> <a href="http://user.trustie.net/users/34/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>白&nbsp;&nbsp;&nbsp;羽</a>

@ -27,13 +27,13 @@
<% end %> <% end %>
<%= render :partial => 'layouts/user_project_list', :locals => {:hasCourse => hasCourse} %> <%= render :partial => 'layouts/user_project_list', :locals => {:hasCourse => hasCourse} %>
<li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> <li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%> <%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li> </li>
</ul> </ul>
</li> </li>
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;"> <li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', <%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')',
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain }, { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user },
{:class => 'my-message'} if User.current.logged?%> {:class => 'my-message'} if User.current.logged?%>
</li> </li>
</ul> </ul>

@ -67,17 +67,17 @@ end
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%=User.current%> <b class="caret"></b></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%=User.current%> <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain }, {:class => 'my-message'} if User.current.logged? -%> <%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user }, {:class => 'my-message'} if User.current.logged? -%>
</li> </li>
<li> <li>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.host_course} %>
</li> </li>
<li> <li>
<%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %> <%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li> <li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%> <%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li> </li>
</ul> </ul>
</li> </li>

@ -18,15 +18,15 @@
<% if User.current.logged? -%> <% if User.current.logged? -%>
<li id="current_user_li"> <li id="current_user_li">
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.user_domain}, :class => "uses_name"%> <%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, :class => "uses_name"%>
<ul id="user_sub_menu" style="right: 0px;display: none;"> <ul id="user_sub_menu" style="right: 0px;display: none;">
<% unless User.current.projects.empty? %> <% unless User.current.projects.empty? %>
<li id="my_projects_li"> <li id="my_projects_li">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain}, :class => "parent" %> <%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name}, :class => "parent" %>
<ul id="my_projects_ul"> <ul id="my_projects_ul">
<% User.current.projects.each do |project| %> <% User.current.projects.each do |project| %>
<li title="<%=project.name%>"> <li title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %> <%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
@ -49,7 +49,7 @@
<% end %> <% end %>
<% end %> <% end %>
<li> <li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%> <%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li> </li>
</ul> </ul>
</li> </li>

@ -1,10 +1,10 @@
<% if User.current.projects.count>0 %> <% if User.current.projects.count>0 %>
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> <li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %> <%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
<ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;"> <ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;">
<% User.current.projects.each do |project| %> <% User.current.projects.each do |project| %>
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>"> <li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %> <%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

@ -52,7 +52,7 @@
<a href="javascript:void(0)" onclick="submitSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" > <a href="javascript:void(0)" onclick="submitSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >
<%= l(:label_search)%> <%= l(:label_search)%>
</a> </a>
<br /> <div class="cl"></div>
<span id="project_name_span" style="float: left"></span> <span id="project_name_span" style="float: left"></span>
<% end %> <% end %>
</div> </div>

@ -190,16 +190,16 @@
<% unless @user.user_extensions.nil? %> <% unless @user.user_extensions.nil? %>
<% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %> <% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %>
<tr> <tr>
<% unless @user.user_extensions.school.nil? %>
<td style=" float: right" width="70px"> <td style=" float: right" width="70px">
<span style="float: right"><%= l(:field_occupation) %></span> <span style="float: right"><%= l(:field_occupation) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<% unless @user.user_extensions.school.nil? %>
<a href="http://course.trustie.net/?school_id=<%= @user.user_extensions.school.id%>"><%= @user.user_extensions.school.name %></a> <a href="http://course.trustie.net/?school_id=<%= @user.user_extensions.school.id%>"><%= @user.user_extensions.school.name %></a>
<% end %>
</td> </td>
<% end %>
</tr> </tr>
<% elsif @user.user_extensions.identity == 3 %> <% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation.empty? %>
<tr> <tr>
<td style=" float: right" width="70px"> <td style=" float: right" width="70px">
<span style="float: right"> <%= l(:field_occupation) %></span> <span style="float: right"> <%= l(:field_occupation) %></span>

@ -18,9 +18,6 @@
} }
}) })
}); });
</script>
<script type="text/javascript">
function get_school(value){ function get_school(value){
var prefix = ''; var prefix = '';
if(location.href.indexOf('ros') >= 0) if(location.href.indexOf('ros') >= 0)
@ -36,14 +33,9 @@
} }
}) })
} }
</script>
<script type="text/javascript">
function test(id){ function test(id){
location.href = encodeURI('http://<%= Setting.host_course %>/?school_id='+id); location.href = encodeURI('http://<%= Setting.host_course %>/?school_id='+id);
} }
</script>
<script type="text/javascript">
function ssearch(){ function ssearch(){
//alert($("#key_word").val()); //alert($("#key_word").val());
var value = $("#key_word").val(); var value = $("#key_word").val();

@ -34,7 +34,7 @@
<% memberships = user.memberships.all(:conditions => cond) %> <% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_contribute_to, :count => memberships.count) %> <%= l(:label_x_contribute_to, :count => memberships.count) %>
<% for member in memberships %> <% for member in memberships %>
<%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.project_domain } %><%= (memberships.last == member) ? '' : '' %> <%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.host_name } %><%= (memberships.last == member) ? '' : '' %>
<% end %> <% end %>
<p> <p>
<%# unless user.memberships.empty? %> <%# unless user.memberships.empty? %>
@ -45,7 +45,7 @@
<%= "" unless user_courses.empty? %> <%= "" unless user_courses.empty? %>
<% for course in user_courses %> <% for course in user_courses %>
<%# if course.name != nil %> <%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %> <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %> <%# end %>
<% end %> <% end %>
<%# end %> <%# end %>

@ -32,7 +32,7 @@
<%= l(:label_x_course_contribute_to, :count => user_courses.count) %> <%= l(:label_x_course_contribute_to, :count => user_courses.count) %>
<%= "" unless user_courses.empty? %> <%= "" unless user_courses.empty? %>
<% for course in user_courses %> <% for course in user_courses %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %> <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<% end %> <% end %>
</p> </p>
</td> </td>

@ -38,7 +38,7 @@
<%= "" unless user_courses.empty? %> <%= "" unless user_courses.empty? %>
<% for course in user_courses %> <% for course in user_courses %>
<%# if course.name != nil %> <%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %> <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %> <%# end %>
<% end %> <% end %>
<%# end %> <%# end %>

@ -254,16 +254,6 @@ tags_max_length:
tags_show_search_results: tags_show_search_results:
format: int format: int
default: 5 default: 5
user_domain:
default: user.trustie.net
project_domain:
default: forge.trustie.net
contest_domain:
default: contest.trustie.net
course_domain:
default: course.trustie.net
repository_domain:
default: repository.trustie.net
please_chose: please_chose:
default: 请选择 default: 请选择
hidden_non_project: hidden_non_project:

@ -0,0 +1,8 @@
class AddHostConfigToSettings < ActiveRecord::Migration
def change
Setting.create(name: 'host_course', value: 'course.trustie.net')
Setting.create(name: 'host_contest', value: 'contest.trustie.net')
Setting.create(name: 'host_user', value: 'user.trustie.net')
Setting.create(name: 'host_repository', value: 'repository.trustie.net')
end
end

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150505025537) do ActiveRecord::Schema.define(:version => 20150514133640) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -541,6 +541,7 @@ ActiveRecord::Schema.define(:version => 20150505025537) do
t.integer "is_teacher_score", :default => 0 t.integer "is_teacher_score", :default => 0
end end
add_index "homework_attaches", ["bid_id"], :name => "bid_id"
add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id"
create_table "homework_evaluations", :force => true do |t| create_table "homework_evaluations", :force => true do |t|
@ -555,7 +556,9 @@ ActiveRecord::Schema.define(:version => 20150505025537) do
t.integer "bid_id" t.integer "bid_id"
end end
add_index "homework_for_courses", ["bid_id"], :name => "bid_id"
add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id"
add_index "homework_for_courses", ["course_id"], :name => "course_id"
add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id"
create_table "homework_users", :force => true do |t| create_table "homework_users", :force => true do |t|
@ -659,16 +662,6 @@ ActiveRecord::Schema.define(:version => 20150505025537) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t| create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id" t.integer "journal_id"
t.integer "user_id" t.integer "user_id"
@ -1170,12 +1163,14 @@ ActiveRecord::Schema.define(:version => 20150505025537) do
create_table "students_for_courses", :force => true do |t| create_table "students_for_courses", :force => true do |t|
t.integer "student_id" t.integer "student_id"
t.integer "course_id" t.integer "course_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "student_idCopy"
end end
add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id"
add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id"
add_index "students_for_courses", ["student_id"], :name => "student_id"
create_table "taggings", :force => true do |t| create_table "taggings", :force => true do |t|
t.integer "tag_id" t.integer "tag_id"

@ -267,7 +267,7 @@ Redmine::AccessControl.map do |map|
end end
#by young #by young
Redmine::MenuManager.map :top_menu do |menu| Redmine::MenuManager.map :top_menu do |menu|
menu.push :home, {:host => Setting.user_domain} menu.push :home, {:host => Setting.host_user}
menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1} menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1}
menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit
menu.push :software_user, {:controller => 'users', :action => 'index'} menu.push :software_user, {:controller => 'users', :action => 'index'}
@ -336,7 +336,7 @@ end
########fq ########fq
Redmine::MenuManager.map :bid_menu do |menu| Redmine::MenuManager.map :bid_menu do |menu|
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.project_domain }, :caption => :label_bidding_project menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.host_name }, :caption => :label_bidding_project
# menu.push :result, { :controller => 'bids', :action => 'show_results' }, # menu.push :result, { :controller => 'bids', :action => 'show_results' },
# :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p }
end end
@ -422,7 +422,7 @@ Redmine::MenuManager.map :course_menu do |menu|
end end
Redmine::MenuManager.map :user_menu do |menu| Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_course, {:controller => 'users', :action => 'user_courses'}, menu.push :user_course, {:controller => 'users', :action => 'user_courses'},
:if => Proc.new {|u| if User.current == u || User.current.admin? :if => Proc.new {|u| if User.current == u || User.current.admin?
membership = u.coursememberships.all membership = u.coursememberships.all
@ -432,7 +432,7 @@ Redmine::MenuManager.map :user_menu do |menu|
FirstPage.find_by_page_type('project').show_course != 2 && membership && membership.count > 0 FirstPage.find_by_page_type('project').show_course != 2 && membership && membership.count > 0
} }
#menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang #menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang
menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.project_domain}, menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.host_name},
:if => Proc.new {|u| if User.current.admin? :if => Proc.new {|u| if User.current.admin?
memberships = u.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first memberships = u.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first
else else
@ -443,24 +443,24 @@ Redmine::MenuManager.map :user_menu do |menu|
memberships || watch_projects memberships || watch_projects
} }
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end end
Redmine::MenuManager.map :user_enterprise_menu do |menu| Redmine::MenuManager.map :user_enterprise_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end end
Redmine::MenuManager.map :user_menu_self do |menu| Redmine::MenuManager.map :user_menu_self do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.project_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_name }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.user_domain} menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.host_user}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end end
#end #end

@ -1,10 +1,10 @@
/* Redmine - project management software /* Redmine - project management software
Copyright (C) 2006-2013 Jean-Philippe Lang */ Copyright (C) 2006-2013 Jean-Philippe Lang */
function postUpMsg(attachmentId) function postUpMsg(attachmentId)
{ {
$.ajax({ $.ajax({
url: '/attachments/renderTag', url: '/attachments/renderTag',
type: "GET", type: "GET",
data: { data: {
attachmentId: attachmentId attachmentId: attachmentId
@ -25,39 +25,39 @@ function reload(fileSpan) {
function addFile_board(inputEl, file, eagerUpload, id) { function addFile_board(inputEl, file, eagerUpload, id) {
var attachments_frame = '#attachments_fields' + id; var attachments_frame = '#attachments_fields' + id;
if ($(attachments_frame).children().length < 30) { if ($(attachments_frame).children().length < 30) {
deleteallfiles = $(inputEl).data('deleteAllFiles'); deleteallfiles = $(inputEl).data('deleteAllFiles');
var attachmentId = addFile.nextAttachmentId++; var attachmentId = addFile.nextAttachmentId++;
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
fileSpan.append( fileSpan.append(
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload), $('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload),
$('<span >'+$(inputEl).data('fieldIsPublic')+':</span>').attr({ 'class': 'ispublic-label' }) , $('<span >'+$(inputEl).data('fieldIsPublic')+':</span>').attr({ 'class': 'ispublic-label' }) ,
$('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), $('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){ $('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-containerid':id }).click(function(){
if(confirm($(inputEl).data('areYouSure'))){ if(confirm($(inputEl).data('areYouSure'))){
removeFile(); removeFile();
if(!eagerUpload){ if(!eagerUpload){
(function(e){ (function(e){
reload(e); reload(e);
})(fileSpan); })(fileSpan);
}
} }
}
}).toggle(!eagerUpload), }).toggle(!eagerUpload),
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) $('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo(attachments_frame); ).appendTo(attachments_frame);
if(eagerUpload) { if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl); ajaxUpload(file, attachmentId, fileSpan, inputEl);
}
return attachmentId;
} }
return attachmentId; return null;
}
return null;
} }
function addFile(inputEl, file, eagerUpload) { function addFile(inputEl, file, eagerUpload) {
@ -99,132 +99,166 @@ addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl) { function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
function onLoadstart(e) { function onLoadstart(e) {
fileSpan.removeClass('ajax-waiting'); fileSpan.removeClass('ajax-waiting');
fileSpan.addClass('ajax-loading'); fileSpan.addClass('ajax-loading');
$('input:submit', $(this).parents('form')).attr('disabled', 'disabled'); $('input:submit', $(this).parents('form')).attr('disabled', 'disabled');
}
function onProgress(e) {
if(e.lengthComputable) {
this.progressbar( 'value', e.loaded * 100 / e.total );
} }
}
function onProgress(e) {
function actualUpload(file, attachmentId, fileSpan, inputEl) { if(e.lengthComputable) {
this.progressbar( 'value', e.loaded * 100 / e.total );
ajaxUpload.uploading++;
uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, {
loadstartEventHandler: onLoadstart.bind(progressSpan),
progressEventHandler: onProgress.bind(progressSpan)
})
.done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
if($("#network_issue"))
{
$("#network_issue").show();
}
}).always(function() {
ajaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
$('input:submit', form).removeAttr('disabled');
} }
form.dequeue('upload'); }
});
function actualUpload(file, attachmentId, fileSpan, inputEl) {
ajaxUpload.uploading++;
uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, {
loadstartEventHandler: onLoadstart.bind(progressSpan),
progressEventHandler: onProgress.bind(progressSpan)
})
.done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
if($("#network_issue"))
{
$("#network_issue").show();
}
}).always(function() {
ajaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
$('input:submit', form).removeAttr('disabled');
}
form.dequeue('upload');
});
//gcm files count and add delete_all link //gcm files count and add delete_all link
var count=$('#attachments_fields>span').length; //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount')); var containerid=$(inputEl).data('containerid');
if(count>=1){ if(containerid==undefined){
var add_attachs=$('.add_attachment'); var count=$('#attachments_fields>span').length;
var delete_all=$('.remove_all'); $('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
if(delete_all.length<1){ if(count>=1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"})); var add_attachs=$('.add_attachment');
} var delete_all=$('.remove_all');
} if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"}));
}
}
}else{
var count=$('#attachments_fields'+containerid+'>span').length;
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
if(count>=1){
var add_attachs=$('.add_attachment').filter(function(index){
return $(this).data('containerid')==containerid;
});
var delete_all=$('.remove_all').filter(function(index){
return $(this).data('containerid')==containerid;
});
if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({
"href":"javascript:void(0)",
'class': 'remove_all',
'data-containerid': containerid,
"onclick": "removeAll('"+containerid+"')"
}));
}
}
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
}
//gcm //gcm
} }
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename')); var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename'));
progressSpan.progressbar(); progressSpan.progressbar();
fileSpan.addClass('ajax-waiting'); fileSpan.addClass('ajax-waiting');
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
actualUpload(file, attachmentId, fileSpan, inputEl); actualUpload(file, attachmentId, fileSpan, inputEl);
else else
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
} }
ajaxUpload.uploading = 0; ajaxUpload.uploading = 0;
function removeFile() { function removeFile() {
$(this).parent('span').remove(); $(this).parent('span').remove();
return false; return false;
} }
//gcm delete all file //gcm delete all file
function removeAll(){ //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
if(confirm(deleteallfiles)){ function removeAll(containerid){
$(".remove-upload").removeAttr("data-confirm"); if(confirm(deleteallfiles)){
$(".remove-upload").click(); if(containerid==undefined){
} $(".remove-upload").removeAttr("data-confirm");
$(".remove-upload").click();
}else{
var arr = $(".remove-upload").filter(function(){
return $(this).data('containerid')==containerid;
});
arr.removeAttr("data-confirm");
arr.click();
}
}
// return false; // return false;
} }
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
//gcm //gcm
function uploadBlob(blob, uploadUrl, attachmentId, options) { function uploadBlob(blob, uploadUrl, attachmentId, options) {
var actualOptions = $.extend({ var actualOptions = $.extend({
loadstartEventHandler: $.noop, loadstartEventHandler: $.noop,
progressEventHandler: $.noop progressEventHandler: $.noop
}, options); }, options);
if(uploadUrl.indexOf('?') > 0){ if(uploadUrl.indexOf('?') > 0){
uploadUrl = uploadUrl + '&attachment_id=' + attachmentId; uploadUrl = uploadUrl + '&attachment_id=' + attachmentId;
}else{ }else{
uploadUrl = uploadUrl + '?attachment_id=' + attachmentId; uploadUrl = uploadUrl + '?attachment_id=' + attachmentId;
} }
if (blob instanceof window.File) { if (blob instanceof window.File) {
uploadUrl += '&filename=' + encodeURIComponent(blob.name); uploadUrl += '&filename=' + encodeURIComponent(blob.name);
} }
return $.ajax(uploadUrl, { return $.ajax(uploadUrl, {
type: 'POST', type: 'POST',
contentType: 'application/octet-stream', contentType: 'application/octet-stream',
beforeSend: function(jqXhr) { beforeSend: function(jqXhr) {
jqXhr.setRequestHeader('Accept', 'application/js'); jqXhr.setRequestHeader('Accept', 'application/js');
}, },
xhr: function() { xhr: function() {
var xhr = $.ajaxSettings.xhr(); var xhr = $.ajaxSettings.xhr();
xhr.upload.onloadstart = actualOptions.loadstartEventHandler; xhr.upload.onloadstart = actualOptions.loadstartEventHandler;
xhr.upload.onprogress = actualOptions.progressEventHandler; xhr.upload.onprogress = actualOptions.progressEventHandler;
return xhr; return xhr;
}, },
data: blob, data: blob,
cache: false, cache: false,
processData: false processData: false
}); });
} }
function addInputFiles(inputEl) { function addInputFiles(inputEl) {
// var clearedFileInput = $(inputEl).clone().val(''); // var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) { if (inputEl.files) {
// upload files using ajax // upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl); uploadAndAttachFiles(inputEl.files, inputEl);
// $(inputEl).remove(); // $(inputEl).remove();
} else { } else {
// browser not supporting the file API, upload on form submission // browser not supporting the file API, upload on form submission
var attachmentId; var attachmentId;
@ -260,18 +294,18 @@ function addInputFiles_board(inputEl, id) {
} }
function uploadAndAttachFiles(files, inputEl) { function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size'); var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
var sizeExceeded = false; var sizeExceeded = false;
$.each(files, function() { $.each(files, function() {
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
}); });
if (sizeExceeded) { if (sizeExceeded) {
window.alert(maxFileSizeExceeded); window.alert(maxFileSizeExceeded);
} else { } else {
$.each(files, function() {addFile(inputEl, this, true);}); $.each(files, function() {addFile(inputEl, this, true);});
} }
} }
function uploadAndAttachFiles_board(files, inputEl, id) { function uploadAndAttachFiles_board(files, inputEl, id) {
@ -290,37 +324,63 @@ function uploadAndAttachFiles_board(files, inputEl, id) {
} }
function handleFileDropEvent(e) { function handleFileDropEvent(e) {
$(this).removeClass('fileover'); $(this).removeClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
if ($.inArray('Files', e.dataTransfer.types) > -1) { if ($.inArray('Files', e.dataTransfer.types) > -1) {
uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector')); uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector'));
} }
} }
function dragOverHandler(e) { function dragOverHandler(e) {
$(this).addClass('fileover'); $(this).addClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
} }
function dragOutHandler(e) { function dragOutHandler(e) {
$(this).removeClass('fileover'); $(this).removeClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
} }
function setupFileDrop() { function setupFileDrop() {
if (window.File && window.FileList && window.ProgressEvent && window.FormData) { if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] }; $.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
$('form div.box').has('input:file').each(function() { $('form div.box').has('input:file').each(function() {
$(this).on({ $(this).on({
dragover: dragOverHandler, dragover: dragOverHandler,
dragleave: dragOutHandler, dragleave: dragOutHandler,
drop: handleFileDropEvent drop: handleFileDropEvent
}); });
}); });
} }
} }
$(document).ready(setupFileDrop); $(document).ready(setupFileDrop);
$(function(){
$(".file_selector").each(function() {
deleteallfiles = $(this).data('deleteAllFiles');
var containerid = $(this).data('containerid');
if (containerid == undefined)containerid = '';
var count = $('#attachments_fields' + containerid + '>span').length;
if (count >= 1) {
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(this).data('fileCount'));
var add_attachs = $('.add_attachment').filter(function (index) {
return $(this).data('containerid') == containerid;
});
var delete_all = $('.remove_all').filter(function (index) {
return $(this).data('containerid') == containerid;
});
if (delete_all.length < 1) {
add_attachs.append($("<a>&nbsp</a>").attr({
"href": "javascript:void(0)",
'class': 'remove_all',
'data-containerid': containerid,
"onclick": "removeAll('" + containerid + "')"
}));
}
}
});
});

@ -7,6 +7,7 @@ h2, .wiki h1 {font-size: 20px;}
h3, .wiki h2 {font-size: 15px; padding-left: 5px} h3, .wiki h2 {font-size: 15px; padding-left: 5px}
h4, .wiki h3 {font-size: 13px;} h4, .wiki h3 {font-size: 13px;}
h4 {border-bottom: 1px dotted #bbb;} h4 {border-bottom: 1px dotted #bbb;}
li{list-style-type:none;}
/*huang*/ /*huang*/
/*current position*/ /*current position*/
.contest_count{ .contest_count{
@ -2779,4 +2780,4 @@ div.repos_explain{
padding-top: 20px; padding-top: 20px;
padding-bottom: 20px; padding-bottom: 20px;
} }
.upload_img img{max-width: 580px;} .upload_img img{max-width: 580px;width: 100%;}

@ -87,11 +87,11 @@ a.pro_mes_w{ height:20px; float:left;display:block; color:#999999;}
.pro_page_top{ font-size:14px; border-bottom:2px solid #64bdd9; margin-bottom:10px; padding-bottom:5px;} .pro_page_top{ font-size:14px; border-bottom:2px solid #64bdd9; margin-bottom:10px; padding-bottom:5px;}
.pro_page_tit{color:#3e4040; font-weight:bold;width:480px; float:left; font-size:14px; margin-bottom:5px;} .pro_page_tit{color:#3e4040; font-weight:bold;width:480px; float:left; font-size:14px; margin-bottom:5px;}
.pro_pic_box{ margin-left:60px; } .pro_pic_box{ margin-left:60px; }
.pro_pic{ width:100px; height:75px;line-height:73px;border:2px solid #CCC; margin:10px 0; text-align: center;} .pro_pic{ width:100px; border:2px solid #CCC; margin:10px 0;}
.pro_info_box{ margin-left:60px; background:#f0fbff; height:80px; padding:10px 0;} .pro_info_box{ margin-left:60px; border:1px dashed #CCC; height:45px; padding:10px 0;}
.pro_info_box ul{} .pro_info_box ul{}
.pro_info_box ul li{ margin-bottom:10px;} .pro_info_box ul li{ height:24px;}
.pro_info_p{ color:#0781b4 !important; float:left; width:160px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;padding-top:2.5px;} .pro_info_p{color:#0781b4 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
.edit_pro_box{overflow:hidden;display:none; margin-bottom:30px; border-bottom:1px dashed #CCC; padding-bottom:10px;} .edit_pro_box{overflow:hidden;display:none; margin-bottom:30px; border-bottom:1px dashed #CCC; padding-bottom:10px;}
/****翻页***/ /****翻页***/
ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
@ -354,6 +354,9 @@ a:hover.st_add{ color:#ff8e15;}
.newpro_box textarea{ height:150px; float:left; margin-bottom:10px;} .newpro_box textarea{ height:150px; float:left; margin-bottom:10px;}
.newpro_box select{ height:29px; float:left; margin-bottom:10px;} .newpro_box select{ height:29px; float:left; margin-bottom:10px;}
/*.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); }*/ /*.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); }*/
.label02{ width:110px; text-align:right; font-size:14px; display:block; float:left;}
.label03{ width:70px; text-align:right; display:block; float:left;}
.collapsible{ border-left:none;border-right:none;border-bottom:none; border-top:1px solid #e4e4e4; padding-top:10px; }
.icon-reload { background-image: url(../images/reload.png); } .icon-reload { background-image: url(../images/reload.png); }
.icon { .icon {
background-position: 0% 50%; background-position: 0% 50%;

@ -0,0 +1,13 @@
FactoryGirl.define do
factory :course do
name '课程名'
time '2015'
term '春季课程'
period 1
password '111'
description '课程描述'
is_public 1
open_student 1
association :teacher, factory: :user
end
end

@ -1,9 +1,9 @@
FactoryGirl.define do FactoryGirl.define do
factory :user do factory :user do
login "ExampleUser" login "factoryuser"
mail "user@example.com" mail "user@example.com"
password "foobar" password "foobar111"
password_confirmation "foobar" password_confirmation "foobar111"
end end
end end

@ -1,6 +1,22 @@
require 'rails_helper' require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "Account request", :type => :request do RSpec.describe "Account request", :type => :request do
describe "注册用户" do
include_context "create user"
it "正常注册可以成功" do
shared_register
expect(response).to redirect_to(my_account_url)
end
it "修改用户资料" do
shared_register
shared_update_user
expect(response).to redirect_to(user_url(session[:user_id]))
end
end
describe "用户登录" do describe "用户登录" do
let(:user){FactoryGirl.create(:user)} let(:user){FactoryGirl.create(:user)}
@ -10,7 +26,7 @@ RSpec.describe "Account request", :type => :request do
end end
context "正常登录" do context "正常登录" do
before{post signin_path, username: user.login, password: user.password} before{ post signin_path, username: user.login, password: user.password }
it "登录成功,正常跳转" do it "登录成功,正常跳转" do
expect(response).to redirect_to(my_account_url) expect(response).to redirect_to(my_account_url)
end end

@ -0,0 +1,46 @@
require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "课程", :type => :request do
let(:course){FactoryGirl.attributes_for(:course)}
describe "创建课程" do
include_context "create user"
before {
shared_register
shared_update_user
}
context "参数正确,成功创建课程" do
before{
uu = current_user
allow(User).to receive(:current).and_return(uu)
allow(uu).to receive(:allowed_to?).and_return(123)
post courses_path,
"course[name]"=> course[:name],
"class_period"=> course[:period],
"time"=> course[:time],
"term"=> course[:term],
"course[password]"=>course[:password],
"course[description]"=> course[:description],
"course[is_public]"=> course[:is_public],
"course[open_student]"=> course[:open_student]
}
it{
puts User.current.allowed_to?(1,2)
binding.pry
}
it{expect(response).to have_http_status(:success)}
it{expect(assigns(:course)).to be_a_new(Course)}
it{expect(response).to redirect_to(course_url(assigns(:course)))}
end
end
describe "配置课程" do
context "修改课程图片" do
it "正常图片上传成功" do
end
it "不是图片,上传失败"
end
end
end

@ -0,0 +1,6 @@
require 'rails_helper'
RSpec.describe "作业打包下载", :type => :request do
describe "单独下载某学生作业" do
end
end

@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.shared_context "create user" do
let(:user) {FactoryGirl.attributes_for(:user)}
def shared_register
post register_path, user: user
end
def shared_update_user
post my_account_url,
login: user[:login],
identity: 0,
technical_title: "教授",
no: '',
"user[lastname]" => 'lastname',
"user[firstname]" => 'firstname',
enterprise_name: '',
gender: 1,
province: '',
occupation: "",
"user[mail]" => user[:mail],
"user[language]" => "zh",
province: '',
city: '',
"user[mail_notification]" => "all",
"user_extensions[birthday]" => '',
"user_extensions[gender]" => 1,
"user_extensions[brief_introduction]" => '',
"user_extensions[location]" => '',
"user_extensions[occupation]" => '',
"user_extensions[work_experience]" => '',
"user_extensions[zip_code]" => ''
end
def shared_login
post signin_path, username: user[:login], password: user[:password]
end
def current_user
User.find(session[:user_id])
end
end
Loading…
Cancel
Save