diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb
index 9f1d964ef..d051a91f7 100644
--- a/app/controllers/org_subfields_controller.rb
+++ b/app/controllers/org_subfields_controller.rb
@@ -27,7 +27,11 @@ class OrgSubfieldsController < ApplicationController
@sort = ""
@order = ""
@is_remote = false
- @organization = Organization.find(params[:id])
+ 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
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index b431678af..39ece6fbe 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -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
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
index 2c18a144c..d6ce215c6 100644
--- a/app/views/blogs/_article.html.erb
+++ b/app/views/blogs/_article.html.erb
@@ -78,7 +78,7 @@
发帖时间:<%= format_time(activity.created_on) %>
- 更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
+ 更新时间:<%= format_time(activity.updated_on) %>
diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb
index 50854cf23..3ded0cb1d 100644
--- a/app/views/courses/_tool_expand.html.erb
+++ b/app/views/courses/_tool_expand.html.erb
@@ -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) %>
- <%= 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 %>
<% end %>
<% if show_nav?(@course.news.count) %>
- <%= 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 %>
<% end %>
<% if show_nav?(course_file_num) %>
- <%= 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)) %>
@@ -23,25 +23,25 @@
<% end %>
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
- <%= 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 %>
<% end %>
<% if show_nav?(course_feedback_count) %>
- <%= 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"%>
<% end %>
<% if show_nav?(course_poll_count) %>
- <%= 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 %>
<% end %>
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
- <%= 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 %>
<% end %>
\ No newline at end of file
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index cf0428c27..4217ca44e 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -71,7 +71,7 @@
清空
<%#= link_to '新建问题', new_project_issue_path(@project) , :class => "green_u_btn fr ml10" %>
-
<%= l(:label_issues_sum) %>:<%= @project.issues.visible.all.count %>
+
<%= l(:label_issues_sum) %>:<%= @project.project_score.issue_num %>
<%= l(:lable_issues_undo) %>:<%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %>
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb
index b28e6843f..48cd4ab53 100644
--- a/app/views/layouts/_logined_header.html.erb
+++ b/app/views/layouts/_logined_header.html.erb
@@ -102,9 +102,9 @@
- <%= 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 %>
-
<%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive" %>
+
<%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %>
<% end %>
<%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 4e3d10558..c37360a3b 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -98,7 +98,7 @@
<% unless show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<%= 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 %>
<% 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 %>
+
<%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 47465bf64..50d4a07db 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -350,4 +350,4 @@
$("#moreProject_<%=user_activity_id %>").show();
});
$(description_show_hide(<%=user_activity_id %>));
-
+
\ No newline at end of file
diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb
index 7956af6d1..ffd86baa3 100644
--- a/app/views/organizations/_org_left_subfield_list.html.erb
+++ b/app/views/organizations/_org_left_subfield_list.html.erb
@@ -71,7 +71,11 @@
-
-
-
-
-
-
-
+ 组织URL:
+
http://
+
+ .trustie.net
申请
+
+
+
公开 :
class="ml3" />
@@ -115,15 +115,15 @@
新增栏目
<%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %>
-
-
-
-
-
-
-
-
-
+
+
域名目录 (用户自定义url,可选)
+ <% if @organization.domain %>
+
<%= @organization.domain %>.trustie.net/
+ <% else %>
+
您还没有子域名,请先在左侧信息栏申请子域名
+ <% end %>
+
+
栏目类型
@@ -149,18 +149,33 @@
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:"<%= apply_subdomain_organization_path %>",
- type:'post',
+ url: "<%= check_uniq_domain_organizations_path %>",
+ type: 'get',
data:{
- id:id,
- domain:domain
+ org_domain:domain
},
success:function(){
- $("#apply_hint").text("您的申请已提交,系统会以消息的形式通知您结果");
+ if(!$is_exist){
+ $.ajax({
+ url:"<%= apply_subdomain_organization_path %>",
+ type:'post',
+ data:{
+ id:id,
+ domain:domain
+ },
+ success:function(){
+ $("#apply_hint").text("您的申请已提交,系统会以消息的形式通知您结果");
+ }
+ });
+ }
+ else{
+ $("#apply_hint").text("您申请的子域名已存在,请重新输入");
+ }
}
});
}
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index b12f1c0af..652d2aca8 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -165,7 +165,7 @@
<% end %>
<% end %>
-
+
<% 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? %>
@@ -213,42 +213,42 @@
<% end %>
<% end %>
-
- <% if is_teacher%>
- <% comment_status = homework_common.homework_detail_manual.comment_status%>
-
-
-
-
-
- <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%>
-
-
- <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
-
-
- <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
-
- <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
+
+ <% if is_teacher%>
+ <% comment_status = homework_common.homework_detail_manual.comment_status%>
+
+
+
+
+
+ <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%>
+
+
+ <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
+
+
+ <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
+
+ <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
- <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true)%>
+ <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true)%>
- <% end %>
- <% if homework_common.anonymous_comment == 0%>
+ <% end %>
+ <% if homework_common.anonymous_comment == 0%>
- <%= homework_anonymous_comment(homework_common, is_in_course) %>
+ <%= homework_anonymous_comment(homework_common, is_in_course) %>
- <% end %>
- <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
-
- <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%>
-
- <% end %>
-
-
-
-
- <% end%>
+ <% end %>
+ <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
+
+ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%>
+
+ <% end %>
+
+
+
+
+ <% end%>
diff --git a/config/initializers/subdomain.rb b/config/initializers/subdomain.rb
new file mode 100644
index 000000000..b868e7e0b
--- /dev/null
+++ b/config/initializers/subdomain.rb
@@ -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
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index c7e368f0e..ccbe67004 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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)
diff --git a/db/migrate/20160115023749_update_boards_attach.rb b/db/migrate/20160115023749_update_boards_attach.rb
new file mode 100644
index 000000000..06f5097f8
--- /dev/null
+++ b/db/migrate/20160115023749_update_boards_attach.rb
@@ -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
diff --git a/db/migrate/20160115125217_update_rep_commits.rb b/db/migrate/20160115125217_update_rep_commits.rb
new file mode 100644
index 000000000..ea8e3c815
--- /dev/null
+++ b/db/migrate/20160115125217_update_rep_commits.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index e0bd1d6f6..9f8b75be4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index df04d857b..6c2f0af71 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -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');
+}