Merge branch 'develop' into cxt_course
Conflicts: app/views/layouts/base_courses.html.erb app/views/organizations/_org_course_homework.html.erb app/views/users/_user_homework_detail.html.erb
This commit is contained in:
commit
7f7d0ac6f7
|
@ -27,7 +27,11 @@ class OrgSubfieldsController < ApplicationController
|
|||
@sort = ""
|
||||
@order = ""
|
||||
@is_remote = false
|
||||
if params[:id]
|
||||
@organization = Organization.find(params[:id])
|
||||
else
|
||||
@organization = Organization.where("domain=?",request.subdomain).first
|
||||
end
|
||||
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
|
||||
"subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
|
||||
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first
|
||||
|
|
|
@ -136,6 +136,10 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def check_uniq_domain
|
||||
@is_exist = (Organization.where("domain=?", params[:org_domain]).count > 0)
|
||||
end
|
||||
|
||||
def find_organization
|
||||
@organization = Organization.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
发帖时间:<%= format_time(activity.created_on) %>
|
||||
</div>
|
||||
<div class="homepagePostDate fl ml15">
|
||||
更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
|
||||
更新时间:<%= format_time(activity.updated_on) %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="homepagePostIntro break_word upload_img list_style maxh360 table_maxWidth" id="activity_description_<%= user_activity_id%>">
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<% if show_nav?(@course.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10 fn"%>
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f12 c_blue02 ml10 fn"%>
|
||||
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.news.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10 fn" %>
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f12 c_blue02 ml10 fn" %>
|
||||
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_file_num) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10 fn" %>
|
||||
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f12 c_blue02 ml10 fn" %>
|
||||
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||
|
@ -23,25 +23,25 @@
|
|||
<% end %>
|
||||
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10 fn" %>
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f12 c_blue02 ml10 fn" %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_feedback_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10 fn" %>
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f12 c_blue02 ml10 fn" %>
|
||||
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_poll_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10 fn"%>
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f12 c_blue02 ml10 fn"%>
|
||||
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10 fn"%>
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f12 c_blue02 ml10 fn"%>
|
||||
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -71,7 +71,7 @@
|
|||
<a href="javascript:void(0)" class="grey_btn fl ml10" onclick="nh_reset_form();" >清空</a>
|
||||
</div><!--problem_search end-->
|
||||
<%#= link_to '新建问题', new_project_issue_path(@project) , :class => "green_u_btn fr ml10" %>
|
||||
<p class="problem_p fl" ><%= l(:label_issues_sum) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.visible.all.count %></a>
|
||||
<p class="problem_p fl" ><%= l(:label_issues_sum) %>:<a href="javascript:void(0)" class="c_red"><%= @project.project_score.issue_num %></a>
|
||||
<%= l(:lable_issues_undo) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> </a>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@
|
|||
</div>
|
||||
|
||||
<div class="navHomepageNews">
|
||||
<%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon" %>
|
||||
<%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank" %>
|
||||
<% if User.current.count_new_message >0 %>
|
||||
<div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive" %></div>
|
||||
<div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %></div>
|
||||
<% end %>
|
||||
<%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>
|
||||
</div>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<% unless show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to "(#{@course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -126,6 +126,7 @@
|
|||
<%# 工具栏展开 %>
|
||||
<% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
|
||||
course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %>
|
||||
|
||||
<div class="subNav subNav_jiantou" id="expand_tools_expand"><%= l(:label_project_more) %></div>
|
||||
<ul class="navContent" id="navContentCourse">
|
||||
<%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
|
||||
|
|
|
@ -71,7 +71,11 @@
|
|||
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0?'block':'none' %>;" id="org_subfield_<%= field.id %>">
|
||||
<% if field.field_type == "Post" %>
|
||||
<% if !field.subfield_subdomain_dir.nil? %>
|
||||
<% if !request.local? and !organization.domain.nil? and Organization.where("domain is not null").map(&:domain).include?(request.subdomain) %>
|
||||
<%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
|
@ -80,7 +84,11 @@
|
|||
<% end %>
|
||||
<% else %>
|
||||
<% if !field.subfield_subdomain_dir.nil? %>
|
||||
<% if !request.local? and !organization.domain.nil? and Organization.where("domain is not null").map(&:domain).include?(request.subdomain) %>
|
||||
<%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<% if @is_exist %>
|
||||
$is_exist = true;
|
||||
<% else %>
|
||||
$is_exist = false;
|
||||
<% end %>
|
|
@ -54,13 +54,13 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||
<!--<div class="orgRow mb10"><span class="ml10">组织URL:</span>-->
|
||||
<!--<div class="w607 fr">http://-->
|
||||
<!--<input type="text" name="organization[domain]" id="domain" value="<%#= @organization.domain%>" class="orgUrlInput" />-->
|
||||
<!--.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;" onclick="apply_subdomain(<%#= @organization.id %>,$('#domain').val());">申请</a>-->
|
||||
<!--<p class="c_green f12" id="apply_hint" ></p></div>-->
|
||||
<!--<!–class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 –>-->
|
||||
<!--</div>-->
|
||||
<div class="orgRow mb10"><span class="ml10">组织URL:</span>
|
||||
<div class="w607 fr">http://
|
||||
<input type="text" name="organization[domain]" id="domain" value="<%= @organization.domain%>" class="orgUrlInput" />
|
||||
.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;" onclick="apply_subdomain(<%= @organization.id %>,$('#domain').val());">申请</a>
|
||||
<p class="c_green f12" id="apply_hint" ></p></div>
|
||||
<!--class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 -->
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开 : </span>
|
||||
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
|
||||
|
@ -115,15 +115,15 @@
|
|||
<p class="fontBlue fb mb5">新增栏目</p>
|
||||
<%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %>
|
||||
<input type="text" id="subfield_name" name="name" placeholder="栏目名称" class="orgAddSearch mb10" />
|
||||
<!--<div class="mb5">-->
|
||||
<!--<p class="fontGrey3"><span class="fb">域名目录</span>(用户自定义url,可选)</p>-->
|
||||
<!--<%# if @organization.domain %>-->
|
||||
<!--<span class="fl"><%#= @organization.domain %>.trustie.net/</span><input class="fl personalUrl ml3" type="text" name="sub_dir">-->
|
||||
<!--<%# else %>-->
|
||||
<!--<span class="fl">您还没有子域名,请先在左侧信息栏申请子域名</span>-->
|
||||
<!--<%# end %>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</div>-->
|
||||
<div class="mb5">
|
||||
<p class="fontGrey3"><span class="fb">域名目录</span>(用户自定义url,可选)</p>
|
||||
<% if @organization.domain %>
|
||||
<span class="fl"><%= @organization.domain %>.trustie.net/</span><input class="fl personalUrl ml3" type="text" name="sub_dir">
|
||||
<% else %>
|
||||
<span class="fl">您还没有子域名,请先在左侧信息栏申请子域名</span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<ul class="orgAddRole">
|
||||
<li class="fontGrey3 fb mb10">栏目类型</li>
|
||||
<li class="fl mr15">
|
||||
|
@ -149,9 +149,18 @@
|
|||
if ($("#subfield_name").val().trim() != "")
|
||||
$("#add_subfield_form").submit();
|
||||
}
|
||||
var $is_exist = false;
|
||||
function apply_subdomain(id, domain){
|
||||
var reg = new RegExp("^[a-zA-Z0-9_]{1,}$");
|
||||
if (reg.exec(domain)){
|
||||
$.ajax({
|
||||
url: "<%= check_uniq_domain_organizations_path %>",
|
||||
type: 'get',
|
||||
data:{
|
||||
org_domain:domain
|
||||
},
|
||||
success:function(){
|
||||
if(!$is_exist){
|
||||
$.ajax({
|
||||
url:"<%= apply_subdomain_organization_path %>",
|
||||
type:'post',
|
||||
|
@ -164,6 +173,12 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#apply_hint").text("您申请的子域名已存在,请重新输入");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#apply_hint").text("子域名命名不规范,只能包含字母、数字和下划线,请重新输入");
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %>
|
||||
<% projects = homework_common.student_work_projects.where("is_leader = 1") %>
|
||||
<% unless projects.empty? %>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class Subdomain
|
||||
|
||||
def matches?(request)
|
||||
o = Organization.where(domain: request.subdomain).first
|
||||
request.path_parameters[:id] = o.id if o
|
||||
!o.nil?
|
||||
end
|
||||
|
||||
end
|
|
@ -66,6 +66,7 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
collection do
|
||||
get 'check_uniq'
|
||||
get 'check_uniq_domain'
|
||||
get 'autocomplete_search'
|
||||
post 'hide_org_subfield'
|
||||
post 'show_org_subfield'
|
||||
|
@ -73,12 +74,9 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
get '/', to: 'organizations#show', constraints:lambda{|request|Organization.where("domain is not null").map(&:domain).include?(request.subdomain)}
|
||||
Organization.where("domain is not null").each do |org|
|
||||
# org_domains = []
|
||||
# org_domains << org.domain
|
||||
get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: {subdomain: org.domain}
|
||||
#get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: lambda{ |request| org_domains.include?(request.remote_ip) }
|
||||
|
||||
constraints(Subdomain.new) do
|
||||
get '/', to: 'organizations#show'
|
||||
end
|
||||
get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'}
|
||||
get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'}
|
||||
|
@ -1127,6 +1125,8 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
resources :at
|
||||
|
||||
get '/:sub_dir_name', :to => 'org_subfields#show', :as => 'show_subfield_without_id'
|
||||
|
||||
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
|
||||
file = File.join(plugin_dir, "config/routes.rb")
|
||||
if File.exists?(file)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
class UpdateBoardsAttach < ActiveRecord::Migration
|
||||
def up
|
||||
project_count = Project.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... project_count do i
|
||||
Project.page(i).per(30).each do |project|
|
||||
puts project.id
|
||||
if ProjectScore.where("project_id=?", project.id).first.nil?
|
||||
puts "create project ==>#{project.id}"
|
||||
ProjectScore.create(:project_id => project.id, :score => false)
|
||||
end
|
||||
unless project.project_score.nil?
|
||||
# update boards
|
||||
unless project.boards.first.nil?
|
||||
boards_count = project.boards.first.topics.count
|
||||
project.project_score.update_attribute(:board_num, boards_count)
|
||||
end
|
||||
# update attach
|
||||
unless project.attachments.nil?
|
||||
attachments_count = project.attachments.count
|
||||
project.project_score.update_attribute(:attach_num, attachments_count)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
class UpdateRepCommits < ActiveRecord::Migration
|
||||
def up
|
||||
project_count = Project.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... project_count do i
|
||||
Project.page(i).per(30).each do |project|
|
||||
puts project.id
|
||||
if ProjectScore.where("project_id=?", project.id).first.nil?
|
||||
puts "create project ==>#{project.id}"
|
||||
ProjectScore.create(:project_id => project.id, :score => false)
|
||||
end
|
||||
unless project.project_score.nil?
|
||||
# update boards
|
||||
unless project.gpid.nil?
|
||||
g = Gitlab.client
|
||||
begin
|
||||
puts project.id
|
||||
count = g.project(project.gpid).commit_count
|
||||
rescue
|
||||
logger.error("The project's rep is not exit!")
|
||||
end
|
||||
project.project_score.update_attribute(:changeset_num, count)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160114131753) do
|
||||
ActiveRecord::Schema.define(:version => 20160115125217) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
|
@ -1389,7 +1389,7 @@ $(function(){
|
|||
var personalized_map = cookieget(personalized_expand_key);
|
||||
if(personalized_map!=false){
|
||||
personalized_map = JSON.parse(personalized_map);
|
||||
$("*[nhtype='toggle4cookie']").each(function(){
|
||||
$("*[nhtype='toggle4cookiecourse']").each(function(){
|
||||
var personalized_id=$(this).data('id');
|
||||
var val = personalized_map[personalized_id];
|
||||
if(val!=undefined && val!=$(this).data('val')){
|
||||
|
@ -1415,7 +1415,7 @@ $(function(){
|
|||
cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
|
||||
target.toggle(timeout);
|
||||
}
|
||||
$("*[nhtype='toggle4cookie']").on('click',function(){
|
||||
$("*[nhtype='toggle4cookiecourse']").on('click',function(){
|
||||
personalized_click($(this),500);
|
||||
});
|
||||
|
||||
|
@ -1428,3 +1428,7 @@ function submit_course_feedback() {
|
|||
var flag = true
|
||||
}
|
||||
}
|
||||
|
||||
function show_more_tool(){
|
||||
$('#navContentCourse').css('display', 'block');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue